luaconf.h 7.6 KB

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