luaconf.h 6.3 KB

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