sqconfig.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifdef _SQ64
  2. typedef short SQInt16;
  3. typedef unsigned short SQUnsignedInt16;
  4. #ifdef _MSC_VER
  5. typedef __int64 SQInteger;
  6. typedef unsigned __int64 SQUnsignedInteger;
  7. typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
  8. #else
  9. typedef long long SQInteger;
  10. typedef unsigned long long SQUnsignedInteger;
  11. typedef unsigned long long SQHash; /*should be the same size of a pointer*/
  12. #endif
  13. typedef int SQInt32;
  14. typedef unsigned int SQUnsignedInteger32;
  15. #else
  16. typedef int SQInteger;
  17. typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
  18. typedef unsigned int SQUnsignedInteger32; /*must be 32 bits(also on 64bits processors)*/
  19. typedef unsigned int SQUnsignedInteger;
  20. typedef short SQInt16;
  21. typedef unsigned short SQUnsignedInt16;
  22. typedef unsigned int /*ptrdiff_t*/ SQHash; /*should be the same size of a pointer*/
  23. #endif
  24. #ifdef SQUSEDOUBLE
  25. typedef double SQFloat;
  26. #else
  27. typedef float SQFloat;
  28. #endif
  29. #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
  30. #ifdef _MSC_VER
  31. typedef __int64 SQRawObjectVal; //must be 64bits
  32. #else
  33. typedef long long SQRawObjectVal; //must be 64bits
  34. #endif
  35. #define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
  36. #else
  37. typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
  38. #define SQ_OBJECT_RAWINIT()
  39. #endif
  40. #ifndef SQ_ALIGNMENT // SQ_ALIGNMENT shall be less than or equal to SQ_MALLOC alignments, and its value shall be power of 2.
  41. #if defined(SQUSEDOUBLE) || defined(_SQ64)
  42. #define SQ_ALIGNMENT 8
  43. #else
  44. #define SQ_ALIGNMENT 4
  45. #endif
  46. #endif
  47. typedef void* SQUserPointer;
  48. typedef SQUnsignedInteger SQBool;
  49. typedef SQInteger SQRESULT;
  50. #ifdef SQUNICODE
  51. #include <wchar.h>
  52. #include <wctype.h>
  53. typedef wchar_t SQChar;
  54. typedef unsigned wchar_t SQUChar;
  55. #define scstrcmp wcscmp
  56. #ifdef _WIN32
  57. #define scsprintf _snwprintf
  58. #define scvfprintf _vfwprintf
  59. #define scfprintf fwprintf
  60. #define scvprintf vfwprintf
  61. #define scfopen _wfopen
  62. #else
  63. #define scsprintf swprintf
  64. #define scvfprintf vfwprintf
  65. #define scfprintf fwprintf
  66. #define scvprintf vfwprintf
  67. #define scfopen wfopen
  68. #endif
  69. #define scstrlen wcslen
  70. #define scstrcpy wcstrcpy
  71. #define scstrtod wcstod
  72. #ifdef _SQ64
  73. #define scstrtol wcstoll
  74. #else
  75. #define scstrtol wcstol
  76. #endif
  77. #define scstrtoul wcstoul
  78. #define scvsprintf vswprintf
  79. #define scstrstr wcsstr
  80. #define scstrchr wcschr
  81. #define scstrpbrk wcspbrk
  82. #define scstrtok wcstrtok
  83. #define scprintf wprintf
  84. #ifdef _WIN32
  85. #define WCHAR_SIZE 2
  86. #define WCHAR_SHIFT_MUL 1
  87. #define MAX_CHAR 0xFFFF
  88. #else
  89. #define WCHAR_SIZE 4
  90. #define WCHAR_SHIFT_MUL 2
  91. #define MAX_CHAR 0xFFFFFFFF
  92. #endif
  93. #define _SC(a) L##a
  94. #define scisspace iswspace
  95. #define scisdigit iswdigit
  96. #define scisprint iswprint
  97. #define scisxdigit iswxdigit
  98. #define scisalpha iswalpha
  99. #define sciscntrl iswcntrl
  100. #define scisalnum iswalnum
  101. #define sq_rsl(l) ((l)<<WCHAR_SHIFT_MUL)
  102. #else
  103. typedef char SQChar;
  104. typedef unsigned char SQUChar;
  105. #define _SC(a) a
  106. #define scstrcmp strcmp
  107. #ifdef _MSC_VER
  108. #define scsprintf _snprintf
  109. #define scvfprintf _vfprintf
  110. #define scfprintf fprintf
  111. #define scvprintf vfprintf
  112. #define scfopen fopen
  113. #else
  114. #define scsprintf snprintf
  115. #define scvfprintf vfprintf
  116. #define scfprintf fprintf
  117. #define scvprintf vfprintf
  118. #define scfopen fopen
  119. #endif
  120. #define scstrlen strlen
  121. #define scstrcpy strcpy
  122. #define scstrtod strtod
  123. #ifdef _SQ64
  124. #ifdef _MSC_VER
  125. #define scstrtol _strtoi64
  126. #else
  127. #define scstrtol strtoll
  128. #endif
  129. #else
  130. #define scstrtol strtol
  131. #endif
  132. #define scstrtoul strtoul
  133. #define scvsprintf vsnprintf
  134. #define scstrstr strstr
  135. #define scstrpbrk strpbrk
  136. #define scstrchr strchr
  137. #define scstrtok strtok
  138. #define scisspace isspace
  139. #define scisdigit isdigit
  140. #define scisprint isprint
  141. #define scisxdigit isxdigit
  142. #define sciscntrl iscntrl
  143. #define scisalpha isalpha
  144. #define scisalnum isalnum
  145. #define scprintf printf
  146. #define MAX_CHAR 0xFF
  147. #define sq_rsl(l) (l)
  148. #endif
  149. #ifdef _SQ64
  150. #define _PRINT_INT_PREC _SC("ll")
  151. #define _PRINT_INT_FMT _SC("%lld")
  152. #else
  153. #define _PRINT_INT_FMT _SC("%d")
  154. #endif