project_files/hwc/rtl/misc.h
author unc0rr
Sat, 15 Jun 2013 23:44:37 +0400
branchwebgl
changeset 9164 d923ba9d1145
parent 7983 02f36c3e7f6c
child 10015 4feced261c68
permissions -rw-r--r--
Allow building with modern 'base' package
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     1
#ifndef _FPCRTL_MISC_H_
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     2
#define _FPCRTL_MISC_H_
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     3
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     4
#include "pas2c.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     5
#include <assert.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     6
#include <stdbool.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     7
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     8
#ifdef EMSCRIPTEN
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     9
#include <GL/gl.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    10
#else
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    11
#include <GL/glew.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    12
#endif
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    13
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    14
#define     VA_NUM_ARGS(...)                        VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    15
#define     VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...)  N
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    16
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    17
#define     macro_dispatcher(func, ...)             macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    18
#define     macro_dispatcher_(func, nargs)          macro_dispatcher__(func, nargs)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    19
#define     macro_dispatcher__(func, nargs)         func ## nargs
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    20
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    21
#define     FPCRTL_DEBUG
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    22
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    23
#define     FIX_STRING(s)                           (s.str[s.len] = 0)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    24
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    25
//#define fpcrtl_check_string(s)     do{ if(strlen((s).str) != (s).len){ \
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    26
//                                        printf("String %s internal inconsistency error. Length should be %d but actually is %d.\n", (s).str, strlen((s).str), (s).len); \
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    27
//                                        assert(0);\
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    28
//                                    }}while(0)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    29
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    30
void        fpcrtl_assert(int);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    31
void        fpcrtl_print_trace (void);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    32
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    33
int         fpcrtl_round(double number);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    34
void        fpcrtl_printf(const char* format, ...);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    35
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    36
string255   fpcrtl_make_string(const char* s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    37
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    38
string255   fpcrtl_strconcat(string255 str1, string255 str2);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    39
string255   fpcrtl_strappend(string255 s, char c);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    40
string255   fpcrtl_strprepend(char c, string255 s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    41
string255   fpcrtl_chrconcat(char a, char b);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    42
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    43
// return true if str1 == str2
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    44
bool        fpcrtl_strcompare(string255 str1, string255 str2);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    45
bool        fpcrtl_strcomparec(string255 a, char b);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    46
bool        fpcrtl_strncompare(string255 a, string255 b);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    47
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    48
#define     fpcrtl__pchar(s)                        ((s).str)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    49
string255   fpcrtl_pchar2str(char *s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    50
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    51
#define     fpcrtl_TypeInfo                         sizeof // dummy
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    52
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    53
#ifdef EMSCRIPTEN
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    54
#define     GLEW_OK                                 1
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    55
GLenum      glewInit();
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    56
#endif
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    57
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    58
#endif