Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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