aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-03-18 15:02:04 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-03-18 15:02:04 -0300
commitd3a6d95b9af04359c77aed1eed39615b56141356 (patch)
treeabde9a939eddd0e8338e28427036360459d6a9eb
parent47984a0cc2aae6a806d9d831f2393340a1df676a (diff)
downloadlua-d3a6d95b9af04359c77aed1eed39615b56141356.tar.gz
lua-d3a6d95b9af04359c77aed1eed39615b56141356.tar.bz2
lua-d3a6d95b9af04359c77aed1eed39615b56141356.zip
more cleaning on configurations
-rw-r--r--loslib.c15
-rw-r--r--lstate.c19
-rw-r--r--luaconf.h432
3 files changed, 303 insertions, 163 deletions
diff --git a/loslib.c b/loslib.c
index 728ee1d8..034acd5f 100644
--- a/loslib.c
+++ b/loslib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loslib.c,v 1.5 2005/03/08 20:10:05 roberto Exp roberto $ 2** $Id: loslib.c,v 1.6 2005/03/09 16:28:07 roberto Exp roberto $
3** Standard Operating System library 3** Standard Operating System library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -57,16 +57,13 @@ static int io_rename (lua_State *L) {
57 57
58 58
59static int io_tmpname (lua_State *L) { 59static int io_tmpname (lua_State *L) {
60#if !LUA_USE_TMPNAME 60 char buff[LUA_TMPNAMBUFSIZE];
61 luaL_error(L, "`tmpname' not supported"); 61 int err;
62 return 0; 62 lua_tmpnam(buff, err);
63#else 63 if (err)
64 char buff[L_tmpnam]; 64 return luaL_error(L, "unable to generate a unique filename");
65 if (tmpnam(buff) != buff)
66 return luaL_error(L, "unable to generate a unique filename in `tmpname'");
67 lua_pushstring(L, buff); 65 lua_pushstring(L, buff);
68 return 1; 66 return 1;
69#endif
70} 67}
71 68
72 69
diff --git a/lstate.c b/lstate.c
index 7c1042a0..7779f544 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.24 2005/02/10 13:25:02 roberto Exp roberto $ 2** $Id: lstate.c,v 2.25 2005/02/23 17:30:22 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -24,20 +24,9 @@
24#include "ltm.h" 24#include "ltm.h"
25 25
26 26
27/* 27#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
28** macro to allow the inclusion of user information in Lua state 28#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
29*/ 29#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
30#ifndef LUA_USERSTATE
31#define EXTRASPACE 0
32#else
33union UEXTRASPACE {L_Umaxalign a; LUA_USERSTATE b;};
34#define EXTRASPACE (sizeof(union UEXTRASPACE))
35#endif
36
37
38#define state_size(x) (sizeof(x) + EXTRASPACE)
39#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + EXTRASPACE))
40#define fromstate(l) (cast(lu_byte *, (l)) - EXTRASPACE)
41 30
42 31
43/* 32/*
diff --git a/luaconf.h b/luaconf.h
index 5f59897e..17ea3046 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.34 2005/03/08 20:10:05 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.35 2005/03/09 16:28:07 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*/
@@ -13,24 +13,25 @@
13 13
14 14
15/* 15/*
16** {====================================================== 16** {==================================================================
17** Index (search for keyword to find corresponding entry) 17** Index (search for keyword to find corresponding entry)
18** ======================================================= 18** ===================================================================
19*/ 19*/
20 20
21 21
22/* }====================================================== */ 22/* }================================================================== */
23
24 23
25 24
26 25
27/* 26/*
28** {====================================================== 27*@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
29** Generic configuration 28** Lua libraries.
30** ======================================================= 29*@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
30** C libraries.
31** CHANGE them if your machine has a non-conventional directory
32** hierarchy or if you want to install your libraries in
33** non-conventional directories.
31*/ 34*/
32
33/* CONFIG: default path */
34#if defined(_WIN32) 35#if defined(_WIN32)
35#define LUA_ROOT "C:\\Program Files\\Lua51" 36#define LUA_ROOT "C:\\Program Files\\Lua51"
36#define LUA_LDIR LUA_ROOT "\\lua" 37#define LUA_LDIR LUA_ROOT "\\lua"
@@ -51,7 +52,11 @@
51#endif 52#endif
52 53
53 54
54/* CONFIG: directory separator (for submodules) */ 55/*
56*@ LUA_DIRSEP is the directory separator (for submodules).
57** CHANGE it if your machine does not use "/" as the directory separator
58** and is not Windows. (On Windows Lua automatically uses "\".)
59*/
55#if defined(_WIN32) 60#if defined(_WIN32)
56#define LUA_DIRSEP "\\" 61#define LUA_DIRSEP "\\"
57#else 62#else
@@ -59,65 +64,73 @@
59#endif 64#endif
60 65
61 66
62/* CONFIG: environment variables that hold the search path for packages */ 67/*
63#define LUA_PATH "LUA_PATH" 68*@ LUA_PATHSEP is the character that separates templates in a path.
64#define LUA_CPATH "LUA_CPATH" 69** CHANGE it if for some reason your system cannot use a
65 70** semicolon. (E.g., a semicolon may be a too common character in
66/* CONFIG: prefix for open functions in C libraries */ 71** file/directory names.) Probably you do not need to change this.
67#define LUA_POF "luaopen_" 72*/
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 ';' 73#define LUA_PATHSEP ';'
74 74
75/* CONFIG: wild char in each template */
76#define LUA_PATH_MARK "?"
77
78
79
80/* CONFIG: type of numbers in Lua */
81#define LUA_NUMBER double
82 75
83/* CONFIG: formats for Lua numbers */ 76/*
84#define LUA_NUMBER_SCAN "%lf" 77*@ LUA_PATH_MARK is ths string that marks the substitution points in a
85#define LUA_NUMBER_FMT "%.14g" 78** template.
79** CHANGE it if for some reason your system cannot use an interogation
80** mark. (E.g., an interogation mark may be a too common character in
81** file/directory names.) Probably you do not need to change this.
82*/
83#define LUA_PATH_MARK "?"
86 84
87 85
88/* 86/*
89** CONFIG: type for integer functions 87*@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
90** on most machines, `ptrdiff_t' gives a reasonable size for integers 88** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
89** machines, ptrdiff_t gives a good choice between int or long.)
91*/ 90*/
92#define LUA_INTEGER ptrdiff_t 91#define LUA_INTEGER ptrdiff_t
93 92
94 93
95/* CONFIG: mark for all API functions */ 94/*
95*@ LUA_API is a mark for all core API functions.
96*@ LUALIB_API is a mark for all standard library functions.
97** CHANGE them if you need to define those functions in some special way.
98** For instance, if you want to create two Windows DLLs, one with the
99** core, the other with the libraries, you may want to use the following
100** definition:
101**
102** #ifdef LUA_CORE
103** #define LUA_API __declspec(__dllexport)
104** #else
105** #define LUA_API __declspec(__dllimport)
106** #endif
107** #ifdef LUA_LIB
108** #define LUALIB_API __declspec(__dllexport)
109** #else
110** #define LUALIB_API __declspec(__dllimport)
111** #endif
112*/
96#define LUA_API extern 113#define LUA_API extern
97
98/* CONFIG: mark for auxlib functions */
99#define LUALIB_API extern 114#define LUALIB_API extern
100 115
101/* CONFIG: buffer size used by lauxlib buffer system */
102#define LUAL_BUFFERSIZE BUFSIZ
103
104 116
105/* CONFIG: assertions in Lua (mainly for internal debugging) */ 117/*
118*@ lua_assert describes the internal assertions in Lua.
119** CHANGE that only if you need to debug Lua.
120*/
106#define lua_assert(c) ((void)0) 121#define lua_assert(c) ((void)0)
107 122
108/* }====================================================== */
109
110 123
111 124
112/* 125/*
113** {====================================================== 126** {==================================================================
114** Stand-alone configuration 127** Stand-alone configuration
115** ======================================================= 128** ===================================================================
116*/ 129*/
117 130
118#ifdef lua_c 131#ifdef lua_c
119 132
120/* CONFIG: definition of `isatty' */ 133/* CONFIG: definition of isatty */
121#ifdef _POSIX_C_SOURCE 134#ifdef _POSIX_C_SOURCE
122#include <unistd.h> 135#include <unistd.h>
123#define stdin_is_tty() isatty(0) 136#define stdin_is_tty() isatty(0)
@@ -138,7 +151,7 @@
138 151
139 152
140/* 153/*
141** CONFIG: this macro can be used by some `history' system to save lines 154** CONFIG: this macro can be used by some history system to save lines
142** read in manual input 155** read in manual input
143*/ 156*/
144#define lua_saveline(L,line) /* empty */ 157#define lua_saveline(L,line) /* empty */
@@ -147,20 +160,41 @@
147 160
148#endif 161#endif
149 162
150/* }====================================================== */ 163/* }================================================================== */
151 164
152 165
166/*
167** CHANGE here (undefining both luaL_getn and luaL_setn) if you want
168** exact compatibility with the behavior of setn/getn in Lua 5.0.
169*/
170#define luaL_getn(L,i) lua_objsize(L, i)
171#define luaL_setn(L,i,j) ((void)0) /* no op! */
172
153 173
154/* CONFIG: LUA-C API assertions */ 174/*
175** CHANGE luai_apicheck if you want Lua to perform some checks in the
176** parameters it gets from API calls. This may slow down the interpreter
177** a bit, but may be quite useful when debugging C code that interfaces
178** with Lua. A useful redefinition may be like this:
179**
180** #include <assert.h>
181** #define luai_apicheck(L,o) assert(o)
182**
183** (By default lua_assert is empty, so luai_apicheck is also empty.)
184*/
155#define luai_apicheck(L,o) lua_assert(o) 185#define luai_apicheck(L,o) lua_assert(o)
156 186
157 187
158/* number of bits in an `int' */ 188/*
189** CHANGE here if Lua cannot automatically detect the number of bits of
190** your machine. (In that case, simply define LUA_BITSINT.) Probably you
191** do not need to change this.
192*/
159/* avoid overflows in comparison */ 193/* avoid overflows in comparison */
160#if INT_MAX-20 < 32760 194#if INT_MAX-20 < 32760
161#define LUAI_BITSINT 16 195#define LUAI_BITSINT 16
162#elif INT_MAX > 2147483640L 196#elif INT_MAX > 2147483640L
163/* `int' has at least 32 bits */ 197/* int has at least 32 bits */
164#define LUAI_BITSINT 32 198#define LUAI_BITSINT 32
165#else 199#else
166#error "you must define LUA_BITSINT with number of bits in an integer" 200#error "you must define LUA_BITSINT with number of bits in an integer"
@@ -168,66 +202,122 @@
168 202
169 203
170/* 204/*
171** CONFIG: 205*@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
172** LUAI_UINT32: unsigned integer with at least 32 bits 206*@ LUAI_INT32 is an signed integer with at least 32 bits.
173** LUAI_INT32: signed integer with at least 32 bits 207*@ LUAI_UMEM is an an unsigned integer big enough to count the total
174** LUAI_UMEM: an unsigned integer big enough to count the total memory 208** memory used by Lua.
175** used by Lua 209*@ LUAI_MEM is an a signed integer big enough to count the total memory
176** LUAI_MEM: a signed integer big enough to count the total memory used by Lua 210** used by Lua.
211** CHANGE here if for some weird reason the default definitions are not
212** good enough for your machine. The `else' definition always works, but
213** may waste space on machines with 64-bit longs. Probably you do not
214** need to change this.
177*/ 215*/
178#if LUAI_BITSINT >= 32 216#if LUAI_BITSINT >= 32
179#define LUAI_UINT32 unsigned int 217#define LUAI_UINT32 unsigned int
180#define LUAI_INT32 int 218#define LUAI_INT32 int
181#define LUAI_MAXINT32 INT_MAX 219#define LUAI_MAXINT32 INT_MAX
182#define LUAI_UMEM size_t 220#define LUAI_UMEM size_t
183#define LUAI_MEM ptrdiff_t 221#define LUAI_MEM ptrdiff_t
184#else 222#else
185/* 16-bit ints */ 223/* 16-bit ints */
186#define LUAI_UINT32 unsigned long 224#define LUAI_UINT32 unsigned long
187#define LUAI_INT32 long 225#define LUAI_INT32 long
188#define LUAI_MAXINT32 LONG_MAX 226#define LUAI_MAXINT32 LONG_MAX
189#define LUAI_UMEM LUAI_UINT32 227#define LUAI_UMEM unsigned long
190#define LUAI_MEM ptrdiff_t 228#define LUAI_MEM long
191#endif 229#endif
192 230
193 231
194/* CONFIG: maximum depth for calls (unsigned short) */
195#define LUAI_MAXCALLS 10000
196
197/* 232/*
198** CONFIG: maximum depth for C calls (unsigned short): Not too big, or may 233*@ LUAI_MAXCALLS limits the number of nested calls.
199** overflow the C stack... 234** CHANGE it if you need really deep recursive calls. This limit is
235** arbitrary; its only purpose is to stop infinite recursion before
236** exhausting memory. (This value must fit in an unsigned short.)
200*/ 237*/
201#define LUAI_MAXCCALLS 200 238#define LUAI_MAXCALLS 40000
202 239
203 240
204/* CONFIG: maximum size for the virtual stack of a C function */ 241/*
242*@ LUAI_MAXCSTACK limits the number of slots that a C function can use.
243** CHANGE it if you need lots of (Lua) stack space for your C
244** functions. This limit is arbitrary; its only purpose is to stop C
245** functions to consume unlimited stack space.
246*/
205#define LUAI_MAXCSTACK 2048 247#define LUAI_MAXCSTACK 2048
206 248
207 249
250
251/*
252** {==================================================================
253** CHANGE (to smaller values) the following definitions if your system
254** has a small C stack. (Or you may want to change them to larger
255** values if your system has a large C stack and these limits are
256** too rigid for you.) Some of these constants control the size of
257** stack-allocated arrays used by the compiler or the interpreter, while
258** others limit the maximum number of recursive calls that the compiler
259** or the interpreter can perform. Values too large may cause a C stack
260** overflow for some forms of deep constructs.
261** ===================================================================
262*/
263
264
265/*
266*@ LUAI_MAXCCALLS is the maximum depth for nested C calls (unsigned short).
267*/
268#define LUAI_MAXCCALLS 200
269
270
208/* 271/*
209** CONFIG: maximum number of syntactical nested non-terminals: Not too big, 272*@ LUAI_MAXPARSERLEVEL is the maximum number of syntactical nested
210** or may overflow the C stack... 273** non-terminals in a program.
211*/ 274*/
212#define LUAI_MAXPARSERLEVEL 200 275#define LUAI_MAXPARSERLEVEL 200
213 276
214 277
215/* CONFIG: maximum number of variables declared in a function */ 278/*
216#define LUAI_MAXVARS 200 /* <MAXSTACK */ 279*@ LUAI_MAXVARS is the maximum number of local variables per function
280** (must be smaller than 250).
281*/
282#define LUAI_MAXVARS 200
217 283
218 284
219/* CONFIG: maximum number of upvalues per function */ 285/*
220#define LUAI_MAXUPVALUES 60 /* <MAXSTACK */ 286*@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
287** (must be smaller than 250).
288*/
289#define LUAI_MAXUPVALUES 60
221 290
222 291
223/* CONFIG: maximum size of expressions for optimizing `while' code */ 292/*
293*@ LUAI_MAXEXPWHILE is the maximum size of code for expressions
294** controling a `while' loop.
295*/
224#define LUAI_MAXEXPWHILE 100 296#define LUAI_MAXEXPWHILE 100
225 297
226 298
227/* CONFIG: function to convert a lua_Number to int (with any rounding method) */ 299/*
300*@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
301*/
302#define LUAL_BUFFERSIZE BUFSIZ
303
304/* }================================================================== */
305
306
307
308/*
309*@ lua_number2int is a macro to convert lua_Number to int.
310** CHANGE that if you know a faster way to convert a lua_Number to
311** int (with any rounding method and without throwing errors) in your
312** system. In Pentium machines, a naive typecast from doulbe to int
313** in C is extremely slow, so any alternative is worth trying.
314*/
315
316/* On a GNU/Pentium, resort to assembler */
228#if defined(__GNUC__) && defined(__i386) 317#if defined(__GNUC__) && defined(__i386)
229#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") 318#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
230 319
320/* On Windows/Pentium, resort to assembler */
231#elif defined(_MSC_VER) && defined(_M_IX86) 321#elif defined(_MSC_VER) && defined(_M_IX86)
232#pragma warning(disable: 4514) 322#pragma warning(disable: 4514)
233__inline int l_lrint (double flt) 323__inline int l_lrint (double flt)
@@ -240,57 +330,98 @@ __inline int l_lrint (double flt)
240} 330}
241#define lua_number2int(i,d) ((i)=l_lrint((d))) 331#define lua_number2int(i,d) ((i)=l_lrint((d)))
242 332
243#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L) 333/* on Pentium machines compliant with C99, you can try lrint */
244/* on machines compliant with C99, you can try `lrint' */ 334#elif defined (__i386) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L)
245#define lua_number2int(i,d) ((i)=lrint(d)) 335#define lua_number2int(i,d) ((i)=lrint(d))
246 336
337/* this option always work, but may be slow */
247#else 338#else
248#define lua_number2int(i,d) ((i)=(int)(d)) 339#define lua_number2int(i,d) ((i)=(int)(d))
249 340
250#endif 341#endif
251 342
252 343
253/* CONFIG: function to convert a lua_Number to lua_Integer (with any rounding method) */ 344/*
345*@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
346** CHANGE (see lua_number2int).
347*/
348/* On a GNU or Windows/Pentium, resort to assembler */
349#if (defined(__GNUC__) && defined(__i386)) || \
350 (defined(_MSC_VER) && defined(_M_IX86))
254#define lua_number2integer(i,n) lua_number2int((i), (n)) 351#define lua_number2integer(i,n) lua_number2int((i), (n))
255 352
353/* this option always work, but may be slow */
354#else
355#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
256 356
257/* CONFIG: function to convert a lua_Number to a string */ 357#endif
258#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
259/* maximum size of previous conversion */
260#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
261 358
262/* CONFIG: function to convert a string to a lua_Number */
263#define lua_str2number(s,p) strtod((s), (p))
264 359
265 360
361/*
362** {==================================================================
363** CHANGE the following definitions only if you want to build Lua
364** with a number type different from double. You may also need to
365** change lua_number2int & lua_number2integer.
366** ===================================================================
367*/
266 368
267/* CONFIG: result of a `usual argument conversion' over lua_Number */ 369
268#define LUAI_UACNUMBER double 370/*
371*@ LUA_NUMBER is the type of numbers in Lua.
372*@ LUAI_UACNUMBER is the result of an `usual argument conversion'
373** over a number.
374*/
375#define LUA_NUMBER double
376#define LUAI_UACNUMBER LUA_NUMBER
269 377
270 378
271/* CONFIG: primitive operators for numbers */ 379/*
380*@ LUA_NUMBER_SCAN is the format for reading numbers.
381*@ LUA_NUMBER_FMT is the format for writing numbers.
382*@ lua_number2str converts a number to a string.
383*@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
384*@ lua_str2number converts a string to a number.
385*/
386#define LUA_NUMBER_SCAN "%lf"
387#define LUA_NUMBER_FMT "%.14g"
388#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
389#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
390#define lua_str2number(s,p) strtod((s), (p))
391
392
393/*
394*@ The luai_num* macros define the primitive operations over numbers.
395*/
272#define luai_numadd(a,b) ((a)+(b)) 396#define luai_numadd(a,b) ((a)+(b))
273#define luai_numsub(a,b) ((a)-(b)) 397#define luai_numsub(a,b) ((a)-(b))
274#define luai_nummul(a,b) ((a)*(b)) 398#define luai_nummul(a,b) ((a)*(b))
275#define luai_numdiv(a,b) ((a)/(b)) 399#define luai_numdiv(a,b) ((a)/(b))
400#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
401#define luai_numpow(a,b) pow(a,b)
276#define luai_numunm(a) (-(a)) 402#define luai_numunm(a) (-(a))
277#define luai_numeq(a,b) ((a)==(b)) 403#define luai_numeq(a,b) ((a)==(b))
278#define luai_numlt(a,b) ((a)<(b)) 404#define luai_numlt(a,b) ((a)<(b))
279#define luai_numle(a,b) ((a)<=(b)) 405#define luai_numle(a,b) ((a)<=(b))
280#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
281#define luai_numpow(a,b) pow(a,b)
282 406
407/* }================================================================== */
283 408
284 409
285/* CONFIG: type to ensure maximum alignment */ 410/*
411*@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
412** CHANGE it if your system requires alignments larger than double. (For
413** instance, if your system supports long double and those long doubles
414** must be aligned in 16-byte boundaries, then you should add long
415** double in the union.) Probably you do not need to change this.
416*/
286#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } 417#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
287 418
288 419
289/* 420/*
290** CONFIG: exception handling: by default, Lua handles errors with 421*@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
291** longjmp/setjmp when compiling as C code and with exceptions 422** CHANGE them if you prefer to use longjmp/setjmp even with C++. By
292** when compiling as C++ code. Change that if you prefer to use 423** default, Lua handles errors with longjmp/setjmp when compiling as C
293** longjmp/setjmp even with C++. 424** code and with exceptions when compiling as C++ code.
294*/ 425*/
295#ifndef __cplusplus 426#ifndef __cplusplus
296/* default handling with long jumps */ 427/* default handling with long jumps */
@@ -307,60 +438,44 @@ __inline int l_lrint (double flt)
307#endif 438#endif
308 439
309 440
310
311/*
312** CONFIG: macros for thread synchronization inside Lua core
313** machine: This is an attempt to simplify the implementation of a
314** multithreaded version of Lua. Do not change that unless you know
315** what you are doing. all accesses to the global state and to global
316** objects are synchronized. Because threads can read the stack of
317** other threads (when running garbage collection), a thread must also
318** synchronize any write-access to its own stack. Unsynchronized
319** accesses are allowed only when reading its own stack, or when reading
320** immutable fields from global objects (such as string values and udata
321** values).
322*/
323#define lua_lock(L) ((void) 0)
324#define lua_unlock(L) ((void) 0)
325
326
327/* 441/*
328** CONFIG: this macro allows a thread switch in appropriate places in 442*@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
329** the Lua core 443** can do during pattern-matching.
444** CHANGE it if you need more captures. This limit is arbitrary.
330*/ 445*/
331#define lua_threadyield(L) {lua_unlock(L); lua_lock(L);}
332
333
334
335/* CONFIG: allows user-specific initialization on new threads */
336#define lua_userstateopen(L) ((void)0)
337
338
339
340
341
342/* CONFIG: maximum number of captures in pattern-matching (arbitrary limit) */
343#define LUA_MAXCAPTURES 32 446#define LUA_MAXCAPTURES 32
344 447
345 448
346/* 449/*
347** CONFIG: by default, gcc does not get `os.tmpname', because it 450*@ lua_tmpnam is the function that the OS library uses to create a
348** generates a warning when using `tmpname'. Change that if you really 451** temporary name.
349** want (or do not want) `os.tmpname' available. 452** CHANGE it if you have an alternative to tmpnam (which is considered
453** insecure) or if you want the original tmpnam anyway. By default,
454** Lua uses tmpnam except when compiled when POSIX is available, where
455** it uses mkstemp.
350*/ 456*/
351#ifdef __GNUC__ 457#ifdef _POSIX_C_SOURCE
352#define LUA_USE_TMPNAME 0 458#include <unistd.h>
459#define LUA_TMPNAMBUFSIZE 32
460#define lua_tmpnam(b,e) { \
461 strcpy(b, "/tmp/lua_XXXXXX"); \
462 e = mkstemp(b); \
463 if (e != -1) close(e); \
464 e = (e == -1); }
353#else 465#else
354#define LUA_USE_TMPNAME 1 466#define LUA_TMPNAMBUFSIZE L_tmpnam
467#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
355#endif 468#endif
356 469
357 470
358/* 471/*
359** CONFIG: Configuration for loadlib: Lua tries to guess the 472*@ LUA_USE_* define which dynamic-library system Lua should use.
360** dynamic-library system that your platform uses (either Windows' DLL, 473** CHANGE here if Lua has problems choosing the appropriate
361** Mac's dyld, or dlopen). If your system is some kind of Unix, there is 474** dynamic-library system for your platform (either Windows' DLL, Mac's
362** a good chance that LUA_USE_DLOPEN will work for it. You may need to adapt 475** dyld, or Unix's dlopen). If your system is some kind of Unix, there
363** also the makefile. 476** is a good chance that LUA_USE_DLOPEN will work for it. (You may need
477** to adapt also the makefile.) If you do not want any kind of dynamic
478** library, undefine all these options (or just remove these definitions).
364*/ 479*/
365#if defined(_WIN32) 480#if defined(_WIN32)
366#define LUA_USE_DLL 481#define LUA_USE_DLL
@@ -371,12 +486,51 @@ __inline int l_lrint (double flt)
371#endif 486#endif
372 487
373 488
489/*
490*@ lua_lock/lua_unlock are macros for thread synchronization inside the
491** Lua core. This is an attempt to simplify the implementation of a
492** multithreaded version of Lua.
493** CHANGE them only if you know what you are doing. all accesses to
494** the global state and to global objects are synchronized. Because
495** threads can read the stack of other threads (when running garbage
496** collection), a thread must also synchronize any write-access to its
497** own stack. Unsynchronized accesses are allowed only when reading its
498** own stack, or when reading immutable fields from global objects (such
499** as string values and udata values).
500*/
501#define lua_lock(L) ((void) 0)
502#define lua_unlock(L) ((void) 0)
503
504
505/*
506*@ lua_threadyield allows a thread switch in appropriate places in the core.
507** CHANGE it only if you know what you are doing. (See lua_lock.)
508*/
509#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
510
511
512/*
513*@ LUA_EXTRASPACE allows you to add user-specific data in a lua_State
514** (the data goes just *before* the lua_State pointer).
515** CHANGE (define) this if you really need that. This value must be
516** a multiple of the maximum alignment required for your machine.
517*/
518#define LUAI_EXTRASPACE 0
519
520
521/*
522*@ lua_userstateopen allows user-specific initialization on new threads.
523** CHANGE it if you defined LUA_EXTRASPACE and need to initialize that
524** data whenever a new lua_State is created.
525*/
526#define luai_userstateopen(L) ((void)0)
527
374 528
375/* ======================================================= */ 529
530/* =================================================================== */
376 531
377/* Local configuration */ 532/* Local configuration */
378 533
379#undef LUA_USE_TMPNAME 534
380#define LUA_USE_TMPNAME 1
381 535
382#endif 536#endif