Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2. ** $Id: luaconf.h,v 1.151 2010/11/12 15:48:30 roberto Exp $
  3. ** Configuration file for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6.  
  7.  
  8. #ifndef lconfig_h
  9. #define lconfig_h
  10.  
  11. #include <limits.h>
  12. #include <stddef.h>
  13.  
  14.  
  15. /*
  16. ** ==================================================================
  17. ** Search for "@@" to find all configurable definitions.
  18. ** ===================================================================
  19. */
  20.  
  21.  
  22. /*
  23. @@ LUA_ANSI controls the use of non-ansi features.
  24. ** CHANGE it (define it) if you want Lua to avoid the use of any
  25. ** non-ansi feature or library.
  26. */
  27. #if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
  28. #define LUA_ANSI
  29. #endif
  30.  
  31.  
  32. #if !defined(LUA_ANSI) && defined(_WIN32)
  33. #define LUA_WIN
  34. #endif
  35.  
  36. #if defined(LUA_WIN)
  37. #define LUA_DL_DLL
  38. #endif
  39.  
  40.  
  41.  
  42. #if defined(LUA_USE_LINUX)
  43. #define LUA_USE_POSIX
  44. #define LUA_USE_DLOPEN          /* needs an extra library: -ldl */
  45. #define LUA_USE_READLINE        /* needs some extra libraries */
  46. #endif
  47.  
  48. #if defined(LUA_USE_MACOSX)
  49. #define LUA_USE_POSIX
  50. #define LUA_USE_DLOPEN          /* does not need -ldl */
  51. #define LUA_USE_READLINE        /* needs an extra library: -lreadline */
  52. #endif
  53.  
  54.  
  55.  
  56. /*
  57. @@ LUA_USE_POSIX includes all functionality listed as X/Open System
  58. @* Interfaces Extension (XSI).
  59. ** CHANGE it (define it) if your system is XSI compatible.
  60. */
  61. #if defined(LUA_USE_POSIX)
  62. #define LUA_USE_MKSTEMP
  63. #define LUA_USE_ISATTY
  64. #define LUA_USE_POPEN
  65. #define LUA_USE_ULONGJMP
  66. #endif
  67.  
  68.  
  69.  
  70. /*
  71. @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
  72. @* Lua libraries.
  73. @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
  74. @* C libraries.
  75. ** CHANGE them if your machine has a non-conventional directory
  76. ** hierarchy or if you want to install your libraries in
  77. ** non-conventional directories.
  78. */
  79. #if defined(_WIN32)     /* { */
  80. /*
  81. ** In Windows, any exclamation mark ('!') in the path is replaced by the
  82. ** path of the directory of the executable file of the current process.
  83. */
  84. #define LUA_LDIR        "!\\lua\\"
  85. #define LUA_CDIR        "!\\"
  86. #define LUA_PATH_DEFAULT  \
  87.                 LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
  88.                 LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" ".\\?.lua"
  89. #define LUA_CPATH_DEFAULT \
  90.                 LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
  91.  
  92. #else                   /* }{ */
  93.  
  94. #define LUA_VDIR        LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
  95. #define LUA_ROOT        "/usr/local/"
  96. #define LUA_LDIR        LUA_ROOT "share/lua/" LUA_VDIR
  97. #define LUA_CDIR        LUA_ROOT "lib/lua/" LUA_VDIR
  98. #define LUA_PATH_DEFAULT  \
  99.                 LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
  100.                 LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" "./?.lua"
  101. #define LUA_CPATH_DEFAULT \
  102.                 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
  103. #endif                  /* } */
  104.  
  105.  
  106. /*
  107. @@ LUA_DIRSEP is the directory separator (for submodules).
  108. ** CHANGE it if your machine does not use "/" as the directory separator
  109. ** and is not Windows. (On Windows Lua automatically uses "\".)
  110. */
  111. #if defined(_WIN32)
  112. #define LUA_DIRSEP      "\\"
  113. #else
  114. #define LUA_DIRSEP      "/"
  115. #endif
  116.  
  117.  
  118. /*
  119. @@ LUA_ENV is the name of the variable that holds the current
  120. @@ environment, used to access global names.
  121. ** CHANGE it if you do not like this name.
  122. */
  123. #define LUA_ENV         "_ENV"
  124.  
  125.  
  126. /*
  127. @@ LUA_API is a mark for all core API functions.
  128. @@ LUALIB_API is a mark for all auxiliary library functions.
  129. @@ LUAMOD_API is a mark for all standard library opening functions.
  130. ** CHANGE them if you need to define those functions in some special way.
  131. ** For instance, if you want to create one Windows DLL with the core and
  132. ** the libraries, you may want to use the following definition (define
  133. ** LUA_BUILD_AS_DLL to get it).
  134. */
  135. #if defined(LUA_BUILD_AS_DLL)   /* { */
  136.  
  137. #if defined(LUA_CORE) || defined(LUA_LIB)       /* { */
  138. #define LUA_API __declspec(dllexport)
  139. #else                                           /* }{ */
  140. #define LUA_API __declspec(dllimport)
  141. #endif                                          /* } */
  142.  
  143. #else                           /* }{ */
  144.  
  145. #define LUA_API         extern
  146.  
  147. #endif                          /* } */
  148.  
  149.  
  150. /* more often than not the libs go together with the core */
  151. #define LUALIB_API      LUA_API
  152. #define LUAMOD_API      LUALIB_API
  153.  
  154.  
  155. /*
  156. @@ LUAI_FUNC is a mark for all extern functions that are not to be
  157. @* exported to outside modules.
  158. @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
  159. @* that are not to be exported to outside modules (LUAI_DDEF for
  160. @* definitions and LUAI_DDEC for declarations).
  161. ** CHANGE them if you need to mark them in some special way. Elf/gcc
  162. ** (versions 3.2 and later) mark them as "hidden" to optimize access
  163. ** when Lua is compiled as a shared library. Not all elf targets support
  164. ** this attribute. Unfortunately, gcc does not offer a way to check
  165. ** whether the target offers that support, and those without support
  166. ** give a warning about it. To avoid these warnings, change to the
  167. ** default definition.
  168. */
  169. #if defined(luaall_c)           /* { */
  170. #define LUAI_FUNC       static
  171. #define LUAI_DDEC       static
  172. #define LUAI_DDEF       static
  173.  
  174. #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
  175.       defined(__ELF__)
  176. #define LUAI_FUNC       __attribute__((visibility("hidden"))) extern
  177. #define LUAI_DDEC       LUAI_FUNC
  178. #define LUAI_DDEF       /* empty */
  179.  
  180. #else                           /* }{ */
  181. #define LUAI_FUNC       extern
  182. #define LUAI_DDEC       extern
  183. #define LUAI_DDEF       /* empty */
  184. #endif                          /* } */
  185.  
  186.  
  187.  
  188. /*
  189. @@ LUA_QL describes how error messages quote program elements.
  190. ** CHANGE it if you want a different appearance.
  191. */
  192. #define LUA_QL(x)       "'" x "'"
  193. #define LUA_QS          LUA_QL("%s")
  194.  
  195.  
  196. /*
  197. @@ LUA_IDSIZE gives the maximum size for the description of the source
  198. @* of a function in debug information.
  199. ** CHANGE it if you want a different size.
  200. */
  201. #define LUA_IDSIZE      60
  202.  
  203.  
  204. /*
  205. @@ luai_writestring defines how 'print' prints its results.
  206. */
  207. #include <stdio.h>
  208. #define luai_writestring(s,l)   fwrite((s), sizeof(char), (l), stdout)
  209.  
  210. /*
  211. @@ luai_writestringerror defines how to print error messages.
  212. ** (A format string with one argument is enough for Lua...)
  213. */
  214. #define luai_writestringerror(s,p) \
  215.         (fprintf(stderr, (s), (p)), fflush(stderr))
  216.  
  217.  
  218.  
  219.  
  220.  
  221. /*
  222. ** {==================================================================
  223. ** Compatibility with previous versions
  224. ** ===================================================================
  225. */
  226.  
  227. /*
  228. @@ LUA_COMPAT_ALL controls all compatibility options.
  229. ** You can define it to get all options, or change specific options
  230. ** to fit your specific needs.
  231. */
  232. #if defined(LUA_COMPAT_ALL)     /* { */
  233.  
  234. /*
  235. @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
  236. ** You can replace it with 'table.unpack'.
  237. */
  238. #define LUA_COMPAT_UNPACK
  239.  
  240. /*
  241. @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
  242. ** You can call your C function directly (with light C functions).
  243. */
  244. #define lua_cpcall(L,f,u)  \
  245.         (lua_pushcfunction(L, (f)), \
  246.          lua_pushlightuserdata(L,(u)), \
  247.          lua_pcall(L,1,0,0))
  248.  
  249.  
  250. /*
  251. @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
  252. ** You can rewrite 'log10(x)' as 'log(x, 10)'.
  253. */
  254. #define LUA_COMPAT_LOG10
  255.  
  256. /*
  257. @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
  258. */
  259. #define LUA_COMPAT_MAXN
  260.  
  261. /*
  262. @@ The following macros supply trivial compatibility for some
  263. ** changes in the API. The macros themselves document how to
  264. ** change your code to avoid using them.
  265. */
  266. #define lua_strlen(L,i)         lua_rawlen(L, (i))
  267.  
  268. #define lua_objlen(L,i)         lua_rawlen(L, (i))
  269.  
  270. #define lua_equal(L,idx1,idx2)          lua_compare(L,(idx1),(idx2),LUA_OPEQ)
  271. #define lua_lessthan(L,idx1,idx2)       lua_compare(L,(idx1),(idx2),LUA_OPLT)
  272.  
  273. /*
  274. @@ LUA_COMPAT_MODULE controls compatibility with previous
  275. ** module functions 'module' (Lua) and 'luaL_register' (C).
  276. */
  277. #define LUA_COMPAT_MODULE
  278.  
  279. #endif                          /* } */
  280.  
  281. /* }================================================================== */
  282.  
  283.  
  284.  
  285. /*
  286. @@ LUAI_BITSINT defines the number of bits in an int.
  287. ** CHANGE here if Lua cannot automatically detect the number of bits of
  288. ** your machine. Probably you do not need to change this.
  289. */
  290. /* avoid overflows in comparison */
  291. #if INT_MAX-20 < 32760          /* { */
  292. #define LUAI_BITSINT    16
  293. #elif INT_MAX > 2147483640L     /* }{ */
  294. /* int has at least 32 bits */
  295. #define LUAI_BITSINT    32
  296. #else                           /* }{ */
  297. #error "you must define LUA_BITSINT with number of bits in an integer"
  298. #endif                          /* } */
  299.  
  300.  
  301. /*
  302. @@ LUA_INT32 is an signed integer with exactly 32 bits.
  303. @@ LUAI_UMEM is an unsigned integer big enough to count the total
  304. @* memory used by Lua.
  305. @@ LUAI_MEM is a signed integer big enough to count the total memory
  306. @* used by Lua.
  307. ** CHANGE here if for some weird reason the default definitions are not
  308. ** good enough for your machine. Probably you do not need to change
  309. ** this.
  310. */
  311. #if LUAI_BITSINT >= 32          /* { */
  312. #define LUA_INT32       int
  313. #define LUAI_UMEM       size_t
  314. #define LUAI_MEM        ptrdiff_t
  315. #else                           /* }{ */
  316. /* 16-bit ints */
  317. #define LUA_INT32       long
  318. #define LUAI_UMEM       unsigned long
  319. #define LUAI_MEM        long
  320. #endif                          /* } */
  321.  
  322.  
  323. /*
  324. @@ LUAI_MAXSTACK limits the size of the Lua stack.
  325. ** CHANGE it if you need a different limit. This limit is arbitrary;
  326. ** its only purpose is to stop Lua to consume unlimited stack
  327. ** space (and to reserve some numbers for pseudo-indices).
  328. */
  329. #if LUAI_BITSINT >= 32
  330. #define LUAI_MAXSTACK           1000000
  331. #else
  332. #define LUAI_MAXSTACK           15000
  333. #endif
  334.  
  335. /* reserve some space for error handling */
  336. #define LUAI_FIRSTPSEUDOIDX     (-LUAI_MAXSTACK - 1000)
  337.  
  338.  
  339.  
  340.  
  341. /*
  342. @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
  343. ** CHANGE it if it uses too much C-stack space.
  344. */
  345. #define LUAL_BUFFERSIZE         BUFSIZ
  346.  
  347.  
  348.  
  349.  
  350. /*
  351. ** {==================================================================
  352. @@ LUA_NUMBER is the type of numbers in Lua.
  353. ** CHANGE the following definitions only if you want to build Lua
  354. ** with a number type different from double. You may also need to
  355. ** change lua_number2int & lua_number2integer.
  356. ** ===================================================================
  357. */
  358.  
  359. #define LUA_NUMBER_DOUBLE
  360. #define LUA_NUMBER      double
  361.  
  362. /*
  363. @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
  364. @* over a number.
  365. */
  366. #define LUAI_UACNUMBER  double
  367.  
  368.  
  369. /*
  370. @@ LUA_NUMBER_SCAN is the format for reading numbers.
  371. @@ LUA_NUMBER_FMT is the format for writing numbers.
  372. @@ lua_number2str converts a number to a string.
  373. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
  374. @@ lua_str2number converts a string to a number.
  375. */
  376. #define LUA_NUMBER_SCAN         "%lf"
  377. #define LUA_NUMBER_FMT          "%.14g"
  378. #define lua_number2str(s,n)     sprintf((s), LUA_NUMBER_FMT, (n))
  379. #define LUAI_MAXNUMBER2STR      32 /* 16 digits, sign, point, and \0 */
  380. #define lua_str2number(s,p)     strtod((s), (p))
  381.  
  382.  
  383. /*
  384. @@ The luai_num* macros define the primitive operations over numbers.
  385. */
  386.  
  387. /* the following operations need the math library */
  388. #if defined(lobject_c) || defined(lvm_c) || defined(luaall_c)
  389. #include <math.h>
  390. #define luai_nummod(L,a,b)      ((a) - floor((a)/(b))*(b))
  391. #define luai_numpow(L,a,b)      (pow(a,b))
  392. #endif
  393.  
  394. /* these are quite standard operations */
  395. #if defined(LUA_CORE)
  396. #define luai_numadd(L,a,b)      ((a)+(b))
  397. #define luai_numsub(L,a,b)      ((a)-(b))
  398. #define luai_nummul(L,a,b)      ((a)*(b))
  399. #define luai_numdiv(L,a,b)      ((a)/(b))
  400. #define luai_numunm(L,a)        (-(a))
  401. #define luai_numeq(a,b)         ((a)==(b))
  402. #define luai_numlt(L,a,b)       ((a)<(b))
  403. #define luai_numle(L,a,b)       ((a)<=(b))
  404. #define luai_numisnan(L,a)      (!luai_numeq((a), (a)))
  405. #endif
  406.  
  407.  
  408.  
  409. /*
  410. @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
  411. ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
  412. ** machines, ptrdiff_t gives a good choice between int or long.)
  413. */
  414. #define LUA_INTEGER     ptrdiff_t
  415.  
  416. /*
  417. @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
  418. ** It must have at least 32 bits.
  419. */
  420. #define LUA_UNSIGNED    unsigned LUA_INT32
  421.  
  422.  
  423. #if defined(LUA_CORE)           /* { */
  424.  
  425. #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)    /* { */
  426.  
  427. /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes
  428.    with a DirectX idiosyncrasy */
  429. #if defined(_MSC_VER) && defined(M_IX86)                /* { */
  430.  
  431. #define MS_ASMTRICK
  432.  
  433. #else                           /* }{ */
  434. /* the next definition uses a trick that should work on any machine
  435.    using IEEE754 with a 32-bit integer type */
  436.  
  437. #define LUA_IEEE754TRICK
  438.  
  439. /*
  440. @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
  441. @@ (0 for little endian, 1 for big endian); if not defined, Lua will
  442. @@ check it dynamically.
  443. */
  444. /* check for known architectures */
  445. #if defined(__i386__) || defined(__i386) || defined(i386) || \
  446.     defined (__x86_64)
  447. #define LUA_IEEEENDIAN  0
  448. #elif defined(__POWERPC__) || defined(__ppc__)
  449. #define LUA_IEEEENDIAN  1
  450. #endif
  451.  
  452. #endif                          /* } */
  453.  
  454. #endif                  /* } */
  455.  
  456. #endif                  /* } */
  457.  
  458. /* }================================================================== */
  459.  
  460.  
  461.  
  462.  
  463. /* =================================================================== */
  464.  
  465. /*
  466. ** Local configuration. You can use this space to add your redefinitions
  467. ** without modifying the main part of the file.
  468. */
  469.  
  470.  
  471.  
  472. #endif
  473.  
  474.