luaconf.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /*
  2. ** $Id: luaconf.h,v 1.24 2005/01/07 20:00:33 roberto Exp roberto $
  3. ** Configuration file for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lconfig_h
  7. #define lconfig_h
  8. #include <limits.h>
  9. #include <stddef.h>
  10. /*
  11. ** {======================================================
  12. ** Index (search for keyword to find corresponding entry)
  13. ** =======================================================
  14. */
  15. /* }====================================================== */
  16. /*
  17. ** {======================================================
  18. ** Generic configuration
  19. ** =======================================================
  20. */
  21. /* default path */
  22. #if defined(_WIN32)
  23. #define LUA_ROOT "C:\\Program Files\\Lua51"
  24. #define LUA_LDIR LUA_ROOT "\\lua"
  25. #define LUA_CDIR LUA_ROOT "\\dll"
  26. #define LUA_PATH_DEFAULT \
  27. "?.lua;" LUA_LDIR "\\?.lua;" LUA_LDIR "\\?\\init.lua"
  28. #define LUA_CPATH_DEFAULT "?.dll;" LUA_CDIR "\\?.dll"
  29. #else
  30. #define LUA_ROOT "/usr/local"
  31. #define LUA_LDIR LUA_ROOT "/share/lua/5.1"
  32. #define LUA_CDIR LUA_ROOT "/lib/lua/5.1"
  33. #define LUA_PATH_DEFAULT \
  34. "./?.lua;" LUA_LDIR "/?.lua;" LUA_LDIR "/?/init.lua"
  35. #define LUA_CPATH_DEFAULT "./?.so;" LUA_CDIR "/?.so"
  36. #endif
  37. /* type of numbers in Lua */
  38. #define LUA_NUMBER double
  39. /* formats for Lua numbers */
  40. #define LUA_NUMBER_SCAN "%lf"
  41. #define LUA_NUMBER_FMT "%.14g"
  42. /*
  43. ** type for integer functions
  44. ** on most machines, `ptrdiff_t' gives a reasonable size for integers
  45. */
  46. #define LUA_INTEGER ptrdiff_t
  47. /* mark for all API functions */
  48. #define LUA_API extern
  49. /* mark for auxlib functions */
  50. #define LUALIB_API extern
  51. /* buffer size used by lauxlib buffer system */
  52. #define LUAL_BUFFERSIZE BUFSIZ
  53. /* assertions in Lua (mainly for internal debugging) */
  54. #define lua_assert(c) ((void)0)
  55. /* }====================================================== */
  56. /*
  57. ** {======================================================
  58. ** Stand-alone configuration
  59. ** =======================================================
  60. */
  61. #ifdef lua_c
  62. /* definition of `isatty' */
  63. #ifdef _POSIX_C_SOURCE
  64. #include <unistd.h>
  65. #define stdin_is_tty() isatty(0)
  66. #elif defined(_WIN32)
  67. #include <io.h>
  68. #include <stdio.h>
  69. #define stdin_is_tty() _isatty(_fileno(stdin))
  70. #else
  71. #define stdin_is_tty() 1 /* assume stdin is a tty */
  72. #endif
  73. #define PROMPT "> "
  74. #define PROMPT2 ">> "
  75. #define PROGNAME "lua"
  76. /*
  77. ** this macro can be used by some `history' system to save lines
  78. ** read in manual input
  79. */
  80. #define lua_saveline(L,line) /* empty */
  81. #endif
  82. /* }====================================================== */
  83. /*
  84. ** {======================================================
  85. ** Core configuration
  86. ** =======================================================
  87. */
  88. #ifdef LUA_CORE
  89. /* LUA-C API assertions */
  90. #define api_check(L,o) lua_assert(o)
  91. /* number of bits in an `int' */
  92. /* avoid overflows in comparison */
  93. #if INT_MAX-20 < 32760
  94. #define LUA_BITSINT 16
  95. #elif INT_MAX > 2147483640L
  96. /* `int' has at least 32 bits */
  97. #define LUA_BITSINT 32
  98. #else
  99. #error "you must define LUA_BITSINT with number of bits in an integer"
  100. #endif
  101. /*
  102. ** L_UINT32: unsigned integer with at least 32 bits
  103. ** L_INT32: signed integer with at least 32 bits
  104. ** LU_MEM: an unsigned integer big enough to count the total memory used by Lua
  105. ** L_MEM: a signed integer big enough to count the total memory used by Lua
  106. */
  107. #if LUA_BITSINT >= 32
  108. #define LUA_UINT32 unsigned int
  109. #define LUA_INT32 int
  110. #define LUA_MAXINT32 INT_MAX
  111. #define LU_MEM size_t
  112. #define L_MEM ptrdiff_t
  113. #else
  114. /* 16-bit ints */
  115. #define LUA_UINT32 unsigned long
  116. #define LUA_INT32 long
  117. #define LUA_MAXINT32 LONG_MAX
  118. #define LU_MEM LUA_UINT32
  119. #define L_MEM ptrdiff_t
  120. #endif
  121. /* maximum depth for calls (unsigned short) */
  122. #define LUA_MAXCALLS 10000
  123. /*
  124. ** maximum depth for C calls (unsigned short): Not too big, or may
  125. ** overflow the C stack...
  126. */
  127. #define LUA_MAXCCALLS 200
  128. /* maximum size for the virtual stack of a C function */
  129. #define MAXCSTACK 2048
  130. /*
  131. ** maximum number of syntactical nested non-terminals: Not too big,
  132. ** or may overflow the C stack...
  133. */
  134. #define LUA_MAXPARSERLEVEL 200
  135. /* maximum number of variables declared in a function */
  136. #define MAXVARS 200 /* <MAXSTACK */
  137. /* maximum number of upvalues per function */
  138. #define MAXUPVALUES 60 /* <MAXSTACK */
  139. /* maximum size of expressions for optimizing `while' code */
  140. #define MAXEXPWHILE 100
  141. /* function to convert a lua_Number to int (with any rounding method) */
  142. #if defined(__GNUC__) && defined(__i386)
  143. #define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
  144. #elif defined(_MSC_VER) && defined(_M_IX86)
  145. #pragma warning(disable: 4514)
  146. __inline int l_lrint (double flt)
  147. { int i;
  148. _asm {
  149. fld flt
  150. fistp i
  151. };
  152. return i;
  153. }
  154. #define lua_number2int(i,d) ((i)=l_lrint((d)))
  155. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L)
  156. /* on machines compliant with C99, you can try `lrint' */
  157. #include <math.h>
  158. #define lua_number2int(i,d) ((i)=lrint(d))
  159. #else
  160. #define lua_number2int(i,d) ((i)=(int)(d))
  161. #endif
  162. /* function to convert a lua_Number to lua_Integer (with any rounding method) */
  163. #define lua_number2integer(i,n) lua_number2int((i), (n))
  164. /* function to convert a lua_Number to a string */
  165. #include <stdio.h>
  166. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  167. /* function to convert a string to a lua_Number */
  168. #define lua_str2number(s,p) strtod((s), (p))
  169. /* result of a `usual argument conversion' over lua_Number */
  170. #define LUA_UACNUMBER double
  171. /* primitive `^' operator for numbers */
  172. #include <math.h>
  173. #define lua_pow(a,b) pow(a,b)
  174. /* type to ensure maximum alignment */
  175. #define LUSER_ALIGNMENT_T union { double u; void *s; long l; }
  176. /* exception handling */
  177. #ifndef __cplusplus
  178. /* default handling with long jumps */
  179. #include <setjmp.h>
  180. #define L_THROW(L,c) longjmp((c)->b, 1)
  181. #define L_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
  182. #define l_jmpbuf jmp_buf
  183. #else
  184. /* C++ exceptions */
  185. #define L_THROW(L,c) throw(c)
  186. #define L_TRY(L,c,a) try { a } catch(...) \
  187. { if ((c)->status == 0) (c)->status = -1; }
  188. #define l_jmpbuf int /* dummy variable */
  189. #endif
  190. /*
  191. ** macros for thread synchronization inside Lua core machine:
  192. ** all accesses to the global state and to global objects are synchronized.
  193. ** Because threads can read the stack of other threads
  194. ** (when running garbage collection),
  195. ** a thread must also synchronize any write-access to its own stack.
  196. ** Unsynchronized accesses are allowed only when reading its own stack,
  197. ** or when reading immutable fields from global objects
  198. ** (such as string values and udata values).
  199. */
  200. #define lua_lock(L) ((void) 0)
  201. #define lua_unlock(L) ((void) 0)
  202. /*
  203. ** this macro allows a thread switch in appropriate places in the Lua
  204. ** core
  205. */
  206. #define lua_threadyield(L) {lua_unlock(L); lua_lock(L);}
  207. /* allows user-specific initialization on new threads */
  208. #define lua_userstateopen(L) /* empty */
  209. #endif
  210. /* }====================================================== */
  211. /*
  212. ** {======================================================
  213. ** Library configuration
  214. ** =======================================================
  215. */
  216. #ifdef LUA_LIB
  217. /* `assert' options */
  218. /* environment variables that hold the search path for packages */
  219. #define LUA_PATH "LUA_PATH"
  220. #define LUA_CPATH "LUA_CPATH"
  221. /* prefix for open functions in C libraries */
  222. #define LUA_POF "luaopen_"
  223. /* separator for open functions in C libraries */
  224. #define LUA_OFSEP ""
  225. /* directory separator (for submodules) */
  226. #if defined(_WIN32)
  227. #define LUA_DIRSEP "\\"
  228. #else
  229. #define LUA_DIRSEP "/"
  230. #endif
  231. /* separator of templates in a path */
  232. #define LUA_PATH_SEP ';'
  233. /* wild char in each template */
  234. #define LUA_PATH_MARK "?"
  235. /* maximum number of captures in pattern-matching */
  236. #define MAX_CAPTURES 32 /* arbitrary limit */
  237. /*
  238. ** by default, gcc does not get `tmpname'
  239. */
  240. #ifdef __GNUC__
  241. #define USE_TMPNAME 0
  242. #else
  243. #define USE_TMPNAME 1
  244. #endif
  245. /*
  246. ** Configuration for loadlib
  247. */
  248. #if defined(_WIN32)
  249. #define USE_DLL
  250. #elif defined(__APPLE__) && defined(__MACH__)
  251. #define USE_DYLD
  252. #elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD)
  253. #define USE_DLOPEN
  254. #endif
  255. #endif
  256. /* }====================================================== */
  257. /* Local configuration */
  258. #undef USE_TMPNAME
  259. #define USE_TMPNAME 1
  260. #endif