luaconf.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. ** Configuration header.
  3. ** Copyright (C) 2005-2009 Mike Pall. See Copyright Notice in luajit.h
  4. */
  5. #ifndef luaconf_h
  6. #define luaconf_h
  7. #include <limits.h>
  8. #include <stddef.h>
  9. /* Try to determine supported features for a couple of standard platforms. */
  10. #if defined(_WIN32)
  11. #define LUA_USE_WIN
  12. #define LUA_DL_DLL
  13. #elif defined(__linux__) || defined(__solaris__) || defined(__CYGWIN__) || \
  14. defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
  15. (defined(__MACH__) && defined(__APPLE__))
  16. #define LUA_USE_POSIX
  17. #define LUA_DL_DLOPEN
  18. #endif
  19. /* Default path for loading Lua and C modules with require(). */
  20. #ifdef LUA_USE_WIN
  21. /*
  22. ** In Windows, any exclamation mark ('!') in the path is replaced by the
  23. ** path of the directory of the executable file of the current process.
  24. */
  25. #define LUA_LDIR "!\\lua\\"
  26. #define LUA_CDIR "!\\"
  27. #define LUA_PATH_DEFAULT \
  28. ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;"
  29. #define LUA_CPATH_DEFAULT \
  30. ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
  31. #else
  32. #define LUA_ROOT "/usr/local/"
  33. #define LUA_LDIR LUA_ROOT "share/lua/5.1/"
  34. #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
  35. #ifdef LUA_XROOT
  36. #define LUA_JDIR LUA_XROOT "share/luajit-2.0.0-beta2/"
  37. #define LUA_XPATH \
  38. ";" LUA_XROOT "share/lua/5.1/?.lua;" LUA_XROOT "share/lua/5.1/?/init.lua"
  39. #define LUA_XCPATH LUA_XROOT "lib/lua/5.1/?.so;"
  40. #else
  41. #define LUA_JDIR LUA_ROOT "share/luajit-2.0.0-beta2/"
  42. #define LUA_XPATH
  43. #define LUA_XCPATH
  44. #endif
  45. #define LUA_PATH_DEFAULT \
  46. "./?.lua;" LUA_JDIR"?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua" LUA_XPATH
  47. #define LUA_CPATH_DEFAULT \
  48. "./?.so;" LUA_CDIR"?.so;" LUA_XCPATH LUA_CDIR"loadall.so"
  49. #endif
  50. /* Environment variable names for path overrides and initialization code. */
  51. #define LUA_PATH "LUA_PATH"
  52. #define LUA_CPATH "LUA_CPATH"
  53. #define LUA_INIT "LUA_INIT"
  54. /* Special file system characters. */
  55. #ifdef LUA_USE_WIN
  56. #define LUA_DIRSEP "\\"
  57. #else
  58. #define LUA_DIRSEP "/"
  59. #endif
  60. #define LUA_PATHSEP ";"
  61. #define LUA_PATH_MARK "?"
  62. #define LUA_EXECDIR "!"
  63. #define LUA_IGMARK "-"
  64. #define LUA_PATH_CONFIG \
  65. LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \
  66. LUA_EXECDIR "\n" LUA_IGMARK
  67. /* Quoting in error messages. */
  68. #define LUA_QL(x) "'" x "'"
  69. #define LUA_QS LUA_QL("%s")
  70. /* Various tunables. */
  71. #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */
  72. #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */
  73. #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */
  74. #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */
  75. #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */
  76. /* Compatibility with older library function names. */
  77. #define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */
  78. #define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */
  79. /* Configuration for the frontend (the luajit executable). */
  80. #if defined(luajit_c)
  81. #define LUA_PROGNAME "luajit" /* Fallback frontend name. */
  82. #define LUA_PROMPT "> " /* Interactive prompt. */
  83. #define LUA_PROMPT2 ">> " /* Continuation prompt. */
  84. #define LUA_MAXINPUT 512 /* Max. input line length. */
  85. #endif
  86. /* Note: changing the following defines breaks the Lua 5.1 ABI. */
  87. #define LUA_INTEGER ptrdiff_t
  88. #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */
  89. #define LUAL_BUFFERSIZE BUFSIZ /* Size of lauxlib and io.* buffers. */
  90. /* The following defines are here only for compatibility with luaconf.h
  91. ** from the standard Lua distribution. They must not be changed for LuaJIT.
  92. */
  93. #define LUA_NUMBER_DOUBLE
  94. #define LUA_NUMBER double
  95. #define LUAI_UACNUMBER double
  96. #define LUA_NUMBER_SCAN "%lf"
  97. #define LUA_NUMBER_FMT "%.14g"
  98. #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n))
  99. #define LUAI_MAXNUMBER2STR 32
  100. #define lua_str2number(s, p) strtod((s), (p))
  101. #define LUA_INTFRMLEN "l"
  102. #define LUA_INTFRM_T long
  103. /* Linkage of public API functions. */
  104. #if defined(LUA_BUILD_AS_DLL)
  105. #if defined(LUA_CORE) || defined(LUA_LIB)
  106. #define LUA_API __declspec(dllexport)
  107. #else
  108. #define LUA_API __declspec(dllimport)
  109. #endif
  110. #else
  111. #define LUA_API extern
  112. #endif
  113. #define LUALIB_API LUA_API
  114. /* Support for internal assertions. */
  115. #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK)
  116. #include <assert.h>
  117. #endif
  118. #ifdef LUA_USE_ASSERT
  119. #define lua_assert(x) assert(x)
  120. #endif
  121. #ifdef LUA_USE_APICHECK
  122. #define luai_apicheck(L, o) { (void)L; assert(o); }
  123. #else
  124. #define luai_apicheck(L, o) { (void)L; }
  125. #endif
  126. #endif