luaconf.h 6.5 KB

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