luaconf.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. ** $Id: luaconf.h,v 1.3 2004/05/10 17:50:51 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__("fldl %1\nfistpl %0":"=m"(i):"m"(d))
  98. #else
  99. #define lua_number2int(i,n) ((i)=(int)(n))
  100. #endif
  101. /* function to convert a lua_Number to lua_Integer (with any rounding method) */
  102. #define lua_number2integer(i,n) lua_number2int(i,n)
  103. /* function to convert a lua_Number to a string */
  104. #include <stdio.h>
  105. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  106. /* function to convert a string to a lua_Number */
  107. #define lua_str2number(s,p) strtod((s), (p))
  108. /* result of a `usual argument conversion' over lua_Number */
  109. #define LUA_UACNUMBER double
  110. /* number of bits in an `int' */
  111. /* avoid overflows in comparison */
  112. #if INT_MAX-20 < 32760
  113. #define LUA_BITSINT 16
  114. #elif INT_MAX > 2147483640L
  115. /* machine has at least 32 bits */
  116. #define LUA_BITSINT 32
  117. #else
  118. #error "you must define LUA_BITSINT with number of bits in an integer"
  119. #endif
  120. /* type to ensure maximum alignment */
  121. #define LUSER_ALIGNMENT_T union { double u; void *s; long l; }
  122. /* exception handling */
  123. #ifndef __cplusplus
  124. /* default handling with long jumps */
  125. #include <setjmp.h>
  126. #define L_THROW(c) longjmp((c)->b, 1)
  127. #define L_TRY(c,a) if (setjmp((c)->b) == 0) { a }
  128. #define l_jmpbuf jmp_buf
  129. #else
  130. /* C++ exceptions */
  131. #define L_THROW(c) throw(c)
  132. #define L_TRY(c,a) try { a } catch(...) \
  133. { if ((c)->status == 0) (c)->status = -1; }
  134. #define l_jmpbuf int /* dummy variable */
  135. #endif
  136. #endif
  137. /* }====================================================== */
  138. /*
  139. ** {======================================================
  140. ** Library configuration
  141. ** =======================================================
  142. */
  143. #ifdef LUA_LIB
  144. /* `assert' options */
  145. /* name of global that holds table with loaded packages */
  146. #define REQTAB "_LOADED"
  147. /* name of global that holds the search path for packages */
  148. #define LUA_PATH "LUA_PATH"
  149. /* separator of templates in a path */
  150. #define LUA_PATH_SEP ';'
  151. /* wild char in each template */
  152. #define LUA_PATH_MARK '?'
  153. /* default path */
  154. #define LUA_PATH_DEFAULT "?;?.lua"
  155. /* maximum number of captures in pattern-matching */
  156. #define MAX_CAPTURES 32 /* arbitrary limit */
  157. /*
  158. ** by default, gcc does not get `tmpname'
  159. */
  160. #ifdef __GNUC__
  161. #define USE_TMPNAME 0
  162. #else
  163. #define USE_TMPNAME 1
  164. #endif
  165. #endif
  166. /* }====================================================== */
  167. /* Local configuration */
  168. #undef USE_TMPNAME
  169. #define USE_TMPNAME 1
  170. #endif