luaconf.h 6.2 KB

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