sqconfig.h 3.3 KB

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