luaconf.h 6.5 KB

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