aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-03-08 17:10:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-03-08 17:10:05 -0300
commitf8df21bd2071c4e3729d37d1552f54ca2742551a (patch)
tree6d85e7fd9f86bfb6879c0edd60780b1f40325027 /luaconf.h
parentd3902cfa81021bca0a8c30b3ad79a1e2367f6621 (diff)
downloadlua-f8df21bd2071c4e3729d37d1552f54ca2742551a.tar.gz
lua-f8df21bd2071c4e3729d37d1552f54ca2742551a.tar.bz2
lua-f8df21bd2071c4e3729d37d1552f54ca2742551a.zip
`luaconf.h´ exports all its definitions always (so all of them
must have a lua/LUA prefix).
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h283
1 files changed, 132 insertions, 151 deletions
diff --git a/luaconf.h b/luaconf.h
index 62665d0d..73091967 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.32 2005/03/08 18:00:16 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.33 2005/03/08 18:09:16 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -30,7 +30,7 @@
30** ======================================================= 30** =======================================================
31*/ 31*/
32 32
33/* default path */ 33/* CONFIG: default path */
34#if defined(_WIN32) 34#if defined(_WIN32)
35#define LUA_ROOT "C:\\Program Files\\Lua51" 35#define LUA_ROOT "C:\\Program Files\\Lua51"
36#define LUA_LDIR LUA_ROOT "\\lua" 36#define LUA_LDIR LUA_ROOT "\\lua"
@@ -51,33 +51,58 @@
51#endif 51#endif
52 52
53 53
54/* CONFIG: directory separator (for submodules) */
55#if defined(_WIN32)
56#define LUA_DIRSEP "\\"
57#else
58#define LUA_DIRSEP "/"
59#endif
60
61
62/* CONFIG: environment variables that hold the search path for packages */
63#define LUA_PATH "LUA_PATH"
64#define LUA_CPATH "LUA_CPATH"
65
66/* CONFIG: prefix for open functions in C libraries */
67#define LUA_POF "luaopen_"
68
69/* CONFIG: separator for open functions in C libraries */
70#define LUA_OFSEP "_"
71
72/* CONFIG: separator of templates in a path */
73#define LUA_PATHSEP ';'
54 74
55/* type of numbers in Lua */ 75/* CONFIG: wild char in each template */
76#define LUA_PATH_MARK "?"
77
78
79
80/* CONFIG: type of numbers in Lua */
56#define LUA_NUMBER double 81#define LUA_NUMBER double
57 82
58/* formats for Lua numbers */ 83/* CONFIG: formats for Lua numbers */
59#define LUA_NUMBER_SCAN "%lf" 84#define LUA_NUMBER_SCAN "%lf"
60#define LUA_NUMBER_FMT "%.14g" 85#define LUA_NUMBER_FMT "%.14g"
61 86
62 87
63/* 88/*
64** type for integer functions 89** CONFIG: type for integer functions
65** on most machines, `ptrdiff_t' gives a reasonable size for integers 90** on most machines, `ptrdiff_t' gives a reasonable size for integers
66*/ 91*/
67#define LUA_INTEGER ptrdiff_t 92#define LUA_INTEGER ptrdiff_t
68 93
69 94
70/* mark for all API functions */ 95/* CONFIG: mark for all API functions */
71#define LUA_API extern 96#define LUA_API extern
72 97
73/* mark for auxlib functions */ 98/* CONFIG: mark for auxlib functions */
74#define LUALIB_API extern 99#define LUALIB_API extern
75 100
76/* buffer size used by lauxlib buffer system */ 101/* CONFIG: buffer size used by lauxlib buffer system */
77#define LUAL_BUFFERSIZE BUFSIZ 102#define LUAL_BUFFERSIZE BUFSIZ
78 103
79 104
80/* assertions in Lua (mainly for internal debugging) */ 105/* CONFIG: assertions in Lua (mainly for internal debugging) */
81#define lua_assert(c) ((void)0) 106#define lua_assert(c) ((void)0)
82 107
83/* }====================================================== */ 108/* }====================================================== */
@@ -92,7 +117,7 @@
92 117
93#ifdef lua_c 118#ifdef lua_c
94 119
95/* definition of `isatty' */ 120/* CONFIG: definition of `isatty' */
96#ifdef _POSIX_C_SOURCE 121#ifdef _POSIX_C_SOURCE
97#include <unistd.h> 122#include <unistd.h>
98#define stdin_is_tty() isatty(0) 123#define stdin_is_tty() isatty(0)
@@ -113,7 +138,7 @@
113 138
114 139
115/* 140/*
116** this macro can be used by some `history' system to save lines 141** CONFIG: this macro can be used by some `history' system to save lines
117** read in manual input 142** read in manual input
118*/ 143*/
119#define lua_saveline(L,line) /* empty */ 144#define lua_saveline(L,line) /* empty */
@@ -126,86 +151,80 @@
126 151
127 152
128 153
129/* 154/* CONFIG: LUA-C API assertions */
130** {====================================================== 155#define luac_apicheck(L,o) lua_assert(o)
131** Core configuration
132** =======================================================
133*/
134
135#ifdef LUA_CORE
136
137/* LUA-C API assertions */
138#define api_check(L,o) lua_assert(o)
139 156
140 157
141/* number of bits in an `int' */ 158/* number of bits in an `int' */
142/* avoid overflows in comparison */ 159/* avoid overflows in comparison */
143#if INT_MAX-20 < 32760 160#if INT_MAX-20 < 32760
144#define LUA_BITSINT 16 161#define LUAC_BITSINT 16
145#elif INT_MAX > 2147483640L 162#elif INT_MAX > 2147483640L
146/* `int' has at least 32 bits */ 163/* `int' has at least 32 bits */
147#define LUA_BITSINT 32 164#define LUAC_BITSINT 32
148#else 165#else
149#error "you must define LUA_BITSINT with number of bits in an integer" 166#error "you must define LUA_BITSINT with number of bits in an integer"
150#endif 167#endif
151 168
152 169
153/* 170/*
154** L_UINT32: unsigned integer with at least 32 bits 171** CONFIG:
155** L_INT32: signed integer with at least 32 bits 172** LUAC_UINT32: unsigned integer with at least 32 bits
156** LU_MEM: an unsigned integer big enough to count the total memory used by Lua 173** LUAC_INT32: signed integer with at least 32 bits
157** L_MEM: a signed integer big enough to count the total memory used by Lua 174** LUAC_UMEM: an unsigned integer big enough to count the total memory
175** used by Lua
176** LUAC_MEM: a signed integer big enough to count the total memory used by Lua
158*/ 177*/
159#if LUA_BITSINT >= 32 178#if LUAC_BITSINT >= 32
160#define LUA_UINT32 unsigned int 179#define LUAC_UINT32 unsigned int
161#define LUA_INT32 int 180#define LUAC_INT32 int
162#define LUA_MAXINT32 INT_MAX 181#define LUAC_MAXINT32 INT_MAX
163#define LU_MEM size_t 182#define LUAC_UMEM size_t
164#define L_MEM ptrdiff_t 183#define LUAC_MEM ptrdiff_t
165#else 184#else
166/* 16-bit ints */ 185/* 16-bit ints */
167#define LUA_UINT32 unsigned long 186#define LUAC_UINT32 unsigned long
168#define LUA_INT32 long 187#define LUAC_INT32 long
169#define LUA_MAXINT32 LONG_MAX 188#define LUAC_MAXINT32 LONG_MAX
170#define LU_MEM LUA_UINT32 189#define LUAC_UMEM LUAC_UINT32
171#define L_MEM ptrdiff_t 190#define LUAC_MEM ptrdiff_t
172#endif 191#endif
173 192
174 193
175/* maximum depth for calls (unsigned short) */ 194/* CONFIG: maximum depth for calls (unsigned short) */
176#define LUA_MAXCALLS 10000 195#define LUAC_MAXCALLS 10000
177 196
178/* 197/*
179** maximum depth for C calls (unsigned short): Not too big, or may 198** CONFIG: maximum depth for C calls (unsigned short): Not too big, or may
180** overflow the C stack... 199** overflow the C stack...
181*/ 200*/
182#define LUA_MAXCCALLS 200 201#define LUAC_MAXCCALLS 200
183 202
184 203
185/* maximum size for the virtual stack of a C function */ 204/* CONFIG: maximum size for the virtual stack of a C function */
186#define MAXCSTACK 2048 205#define LUAC_MAXCSTACK 2048
187 206
188 207
189/* 208/*
190** maximum number of syntactical nested non-terminals: Not too big, 209** CONFIG: maximum number of syntactical nested non-terminals: Not too big,
191** or may overflow the C stack... 210** or may overflow the C stack...
192*/ 211*/
193#define LUA_MAXPARSERLEVEL 200 212#define LUAC_MAXPARSERLEVEL 200
194 213
195 214
196/* maximum number of variables declared in a function */ 215/* CONFIG: maximum number of variables declared in a function */
197#define MAXVARS 200 /* <MAXSTACK */ 216#define LUAC_MAXVARS 200 /* <MAXSTACK */
198 217
199 218
200/* maximum number of upvalues per function */ 219/* CONFIG: maximum number of upvalues per function */
201#define MAXUPVALUES 60 /* <MAXSTACK */ 220#define LUAC_MAXUPVALUES 60 /* <MAXSTACK */
202 221
203 222
204/* maximum size of expressions for optimizing `while' code */ 223/* CONFIG: maximum size of expressions for optimizing `while' code */
205#define MAXEXPWHILE 100 224#define LUAC_MAXEXPWHILE 100
206 225
207 226
208/* function to convert a lua_Number to int (with any rounding method) */ 227/* CONFIG: function to convert a lua_Number to int (with any rounding method) */
209#if defined(__GNUC__) && defined(__i386) 228#if defined(__GNUC__) && defined(__i386)
210#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") 229#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
211 230
@@ -231,171 +250,133 @@ __inline int l_lrint (double flt)
231#endif 250#endif
232 251
233 252
234/* function to convert a lua_Number to lua_Integer (with any rounding method) */ 253/* CONFIG: function to convert a lua_Number to lua_Integer (with any rounding method) */
235#define lua_number2integer(i,n) lua_number2int((i), (n)) 254#define lua_number2integer(i,n) lua_number2int((i), (n))
236 255
237 256
238/* function to convert a lua_Number to a string */ 257/* CONFIG: function to convert a lua_Number to a string */
239#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 258#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
240/* maximum size of previous conversion */ 259/* maximum size of previous conversion */
241#define MAX_NUMBER2STR 32 /* 16 digits, sign, point and \0 (+ some extra) */ 260#define LUAC_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
242 261
243/* function to convert a string to a lua_Number */ 262/* CONFIG: function to convert a string to a lua_Number */
244#define lua_str2number(s,p) strtod((s), (p)) 263#define lua_str2number(s,p) strtod((s), (p))
245 264
246 265
247 266
248/* result of a `usual argument conversion' over lua_Number */ 267/* CONFIG: result of a `usual argument conversion' over lua_Number */
249#define LUA_UACNUMBER double 268#define LUAC_UACNUMBER double
250 269
251 270
252/* primitive operators for numbers */ 271/* CONFIG: primitive operators for numbers */
253#define num_add(a,b) ((a)+(b)) 272#define luac_numadd(a,b) ((a)+(b))
254#define num_sub(a,b) ((a)-(b)) 273#define luac_numsub(a,b) ((a)-(b))
255#define num_mul(a,b) ((a)*(b)) 274#define luac_nummul(a,b) ((a)*(b))
256#define num_div(a,b) ((a)/(b)) 275#define luac_numdiv(a,b) ((a)/(b))
257#define num_unm(a) (-(a)) 276#define luac_numunm(a) (-(a))
258#define num_eq(a,b) ((a)==(b)) 277#define luac_numeq(a,b) ((a)==(b))
259#define num_lt(a,b) ((a)<(b)) 278#define luac_numlt(a,b) ((a)<(b))
260#define num_le(a,b) ((a)<=(b)) 279#define luac_numle(a,b) ((a)<=(b))
261#define num_mod(a,b) ((a) - floor((a)/(b))*(b)) 280#define luac_nummod(a,b) ((a) - floor((a)/(b))*(b))
262#define num_pow(a,b) pow(a,b) 281#define luac_numpow(a,b) pow(a,b)
263 282
264 283
265 284
266/* type to ensure maximum alignment */ 285/* CONFIG: type to ensure maximum alignment */
267#define LUSER_ALIGNMENT_T union { double u; void *s; long l; } 286#define LUAC_USER_ALIGNMENT_T union { double u; void *s; long l; }
268 287
269 288
270/* 289/*
271** exception handling: by default, Lua handles errors with longjmp/setjmp 290** CONFIG: exception handling: by default, Lua handles errors with
272** when compiling as C code and with exceptions when compiling as C++ code. 291** longjmp/setjmp when compiling as C code and with exceptions
273** Change that if you prefer to use longjmp/setjmp even with C++. 292** when compiling as C++ code. Change that if you prefer to use
293** longjmp/setjmp even with C++.
274*/ 294*/
275#ifndef __cplusplus 295#ifndef __cplusplus
276/* default handling with long jumps */ 296/* default handling with long jumps */
277#define L_THROW(L,c) longjmp((c)->b, 1) 297#define LUAC_THROW(L,c) longjmp((c)->b, 1)
278#define L_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } 298#define LUAC_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
279#define l_jmpbuf jmp_buf 299#define luac_jmpbuf jmp_buf
280 300
281#else 301#else
282/* C++ exceptions */ 302/* C++ exceptions */
283#define L_THROW(L,c) throw(c) 303#define LUAC_THROW(L,c) throw(c)
284#define L_TRY(L,c,a) try { a } catch(...) \ 304#define LUAC_TRY(L,c,a) try { a } catch(...) \
285 { if ((c)->status == 0) (c)->status = -1; } 305 { if ((c)->status == 0) (c)->status = -1; }
286#define l_jmpbuf int /* dummy variable */ 306#define luac_jmpbuf int /* dummy variable */
287#endif 307#endif
288 308
289 309
290 310
291/* 311/*
292** macros for thread synchronization inside Lua core machine: This is 312** CONFIG: macros for thread synchronization inside Lua core
293** an attempt to simplify the implementation of a multithreaded version 313** machine: This is an attempt to simplify the implementation of a
294** of Lua. Do not change that unless you know what you are doing. all 314** multithreaded version of Lua. Do not change that unless you know
295** accesses to the global state and to global objects are synchronized. 315** what you are doing. all accesses to the global state and to global
296** Because threads can read the stack of other threads (when running 316** objects are synchronized. Because threads can read the stack of
297** garbage collection), a thread must also synchronize any write-access 317** other threads (when running garbage collection), a thread must also
298** to its own stack. Unsynchronized accesses are allowed only when 318** synchronize any write-access to its own stack. Unsynchronized
299** reading its own stack, or when reading immutable fields from global 319** accesses are allowed only when reading its own stack, or when reading
300** objects (such as string values and udata values). 320** immutable fields from global objects (such as string values and udata
321** values).
301*/ 322*/
302#define lua_lock(L) ((void) 0) 323#define lua_lock(L) ((void) 0)
303#define lua_unlock(L) ((void) 0) 324#define lua_unlock(L) ((void) 0)
304 325
305 326
306/* 327/*
307** this macro allows a thread switch in appropriate places in the Lua 328** CONFIG: this macro allows a thread switch in appropriate places in
308** core 329** the Lua core
309*/ 330*/
310#define lua_threadyield(L) {lua_unlock(L); lua_lock(L);} 331#define lua_threadyield(L) {lua_unlock(L); lua_lock(L);}
311 332
312 333
313 334
314/* allows user-specific initialization on new threads */ 335/* CONFIG: allows user-specific initialization on new threads */
315#define lua_userstateopen(L) ((void)0) 336#define lua_userstateopen(L) ((void)0)
316 337
317 338
318#endif
319
320/* }====================================================== */
321
322
323 339
324/*
325** {======================================================
326** Library configuration
327** =======================================================
328*/
329 340
330#ifdef LUA_LIB
331 341
332 342/* CONFIG: maximum number of captures in pattern-matching (arbitrary limit) */
333/* environment variables that hold the search path for packages */ 343#define LUA_MAXCAPTURES 32
334#define LUA_PATH "LUA_PATH"
335#define LUA_CPATH "LUA_CPATH"
336
337/* prefix for open functions in C libraries */
338#define LUA_POF "luaopen_"
339
340/* separator for open functions in C libraries */
341#define LUA_OFSEP "_"
342
343/* directory separator (for submodules) */
344#if defined(_WIN32)
345#define LUA_DIRSEP "\\"
346#else
347#define LUA_DIRSEP "/"
348#endif
349
350/* separator of templates in a path */
351#define LUA_PATHSEP ';'
352
353/* wild char in each template */
354#define LUA_PATH_MARK "?"
355
356
357/* maximum number of captures in pattern-matching (arbitrary limit) */
358#define MAX_CAPTURES 32
359 344
360 345
361/* 346/*
362** by default, gcc does not get `os.tmpname', because it generates a warning 347** CONFIG: by default, gcc does not get `os.tmpname', because it
363** when using `tmpname'. Change that if you really want (or do not want) 348** generates a warning when using `tmpname'. Change that if you really
364** `os.tmpname' available. 349** want (or do not want) `os.tmpname' available.
365*/ 350*/
366#ifdef __GNUC__ 351#ifdef __GNUC__
367#define USE_TMPNAME 0 352#define LUA_USETMPNAME 0
368#else 353#else
369#define USE_TMPNAME 1 354#define LUA_USETMPNAME 1
370#endif 355#endif
371 356
372 357
373/* 358/*
374** Configuration for loadlib: Lua tries to guess the dynamic-library 359** CONFIG: Configuration for loadlib: Lua tries to guess the
375** system that your platform uses (either Windows' DLL, Mac's dyld, or 360** dynamic-library system that your platform uses (either Windows' DLL,
376** dlopen). If your system is some kind of Unix, there is a good chance 361** Mac's dyld, or dlopen). If your system is some kind of Unix, there is
377** that USE_DLOPEN will work for it. You may need to adapt also the 362** a good chance that LUA_USEDLOPEN will work for it. You may need to adapt
378** makefile. 363** also the makefile.
379*/ 364*/
380#if defined(_WIN32) 365#if defined(_WIN32)
381#define USE_DLL 366#define LUA_USEDLL
382#elif defined(__APPLE__) && defined(__MACH__) 367#elif defined(__APPLE__) && defined(__MACH__)
383#define USE_DYLD 368#define LUA_USEDYLD
384#elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD) 369#elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD)
385#define USE_DLOPEN 370#define LUA_USEDLOPEN
386#endif 371#endif
387 372
388 373
389#endif
390
391/* }====================================================== */
392
393
394 374
375/* ======================================================= */
395 376
396/* Local configuration */ 377/* Local configuration */
397 378
398#undef USE_TMPNAME 379#undef LUA_USETMPNAME
399#define USE_TMPNAME 1 380#define LUA_USETMPNAME 1
400 381
401#endif 382#endif