summaryrefslogtreecommitdiff
path: root/src/luaconf.h
blob: 7ea477e23aa5f046c345c66ba767bdf4d42352a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/*
** $Id: luaconf.h,v 1.22 2004/12/27 15:58:15 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/


#ifndef lconfig_h
#define lconfig_h

#include <limits.h>
#include <stddef.h>


/*
** {======================================================
** Index (search for keyword to find corresponding entry)
** =======================================================
*/


/* }====================================================== */




/*
** {======================================================
** Generic configuration
** =======================================================
*/

/* default path */
#if defined(_WIN32)
#define LUA_ROOT	"C:\\Program Files\\Lua51"
#define LUA_LDIR	LUA_ROOT "\\lua"
#define LUA_CDIR	LUA_ROOT "\\dll"
#define LUA_PATH_DEFAULT  \
		"?.lua;" LUA_LDIR "\\?.lua;" LUA_LDIR "\\?\\init.lua"
#define LUA_CPATH_DEFAULT	"?.dll;" LUA_CDIR "\\?.dll"

#else
#define LUA_ROOT	"/usr/local"
#define LUA_LDIR	LUA_ROOT "/share/lua/5.1"
#define LUA_CDIR	LUA_ROOT "/lib/lua/5.1"
#define LUA_PATH_DEFAULT  \
		"./?.lua;" LUA_LDIR "/?.lua;" LUA_LDIR "/?/init.lua"
#define LUA_CPATH_DEFAULT	"./?.so;" LUA_CDIR "/?.so"
#endif



/* type of numbers in Lua */
#define LUA_NUMBER	double

/* formats for Lua numbers */
#define LUA_NUMBER_SCAN		"%lf"
#define LUA_NUMBER_FMT		"%.14g"


/*
** type for integer functions
** on most machines, `ptrdiff_t' gives a reasonable size for integers
*/
#define LUA_INTEGER	ptrdiff_t


/* mark for all API functions */
#define LUA_API		extern

/* mark for auxlib functions */
#define LUALIB_API	extern

/* buffer size used by lauxlib buffer system */
#define LUAL_BUFFERSIZE		BUFSIZ


/* assertions in Lua (mainly for internal debugging) */
#define lua_assert(c)		((void)0)

/* }====================================================== */



/*
** {======================================================
** Stand-alone configuration
** =======================================================
*/

#ifdef lua_c

/* definition of `isatty' */
#ifdef _POSIX_C_SOURCE
#include <unistd.h>
#define stdin_is_tty()		isatty(0)
#elif defined(_WIN32)
#include <io.h>
#include <fcntl.h>
#define stdin_is_tty()		_isatty(_fileno(stdin))
#else
#define stdin_is_tty()		1  /* assume stdin is a tty */
#endif


#define PROMPT		"> "
#define PROMPT2		">> "
#define PROGNAME	"lua"


/*
** this macro allows you to open other libraries when starting the
** stand-alone interpreter
*/
#define lua_userinit(L)		luaopen_stdlibs(L)
/*
** #define lua_userinit(L)  { int luaopen_mylibs(lua_State *L); \
**				luaopen_stdlibs(L); luaopen_mylibs(L); }
*/



/*
** this macro can be used by some `history' system to save lines
** read in manual input
*/
#define lua_saveline(L,line)	/* empty */



#endif

/* }====================================================== */



/*
** {======================================================
** Core configuration
** =======================================================
*/

#ifdef LUA_CORE

/* LUA-C API assertions */
#define api_check(L,o)		lua_assert(o)


/* number of bits in an `int' */
/* avoid overflows in comparison */
#if INT_MAX-20 < 32760
#define LUA_BITSINT	16
#elif INT_MAX > 2147483640L
/* `int' has at least 32 bits */
#define LUA_BITSINT	32
#else
#error "you must define LUA_BITSINT with number of bits in an integer"
#endif


/*
** L_UINT32: unsigned integer with at least 32 bits
** L_INT32: signed integer with at least 32 bits
** LU_MEM: an unsigned integer big enough to count the total memory used by Lua
** L_MEM: a signed integer big enough to count the total memory used by Lua
*/
#if LUA_BITSINT >= 32
#define LUA_UINT32	unsigned int
#define LUA_INT32	int
#define LUA_MAXINT32	INT_MAX
#define LU_MEM		size_t
#define L_MEM		ptrdiff_t
#else
/* 16-bit ints */
#define LUA_UINT32	unsigned long
#define LUA_INT32	long
#define LUA_MAXINT32	LONG_MAX
#define LU_MEM		LUA_UINT32
#define L_MEM		ptrdiff_t
#endif


/* maximum depth for calls (unsigned short) */
#define LUA_MAXCALLS	10000

/*
** maximum depth for C calls (unsigned short): Not too big, or may
** overflow the C stack...
*/
#define LUA_MAXCCALLS	200


/* maximum size for the virtual stack of a C function */
#define MAXCSTACK	2048


/*
** maximum number of syntactical nested non-terminals: Not too big,
** or may overflow the C stack...
*/
#define LUA_MAXPARSERLEVEL	200


/* maximum number of variables declared in a function */
#define MAXVARS	200		/* <MAXSTACK */


/* maximum number of upvalues per function */
#define MAXUPVALUES		60	/* <MAXSTACK */


/* maximum size of expressions for optimizing `while' code */
#define MAXEXPWHILE		100


/* function to convert a lua_Number to int (with any rounding method) */
#if defined(__GNUC__) && defined(__i386)
#define lua_number2int(i,d)	__asm__ ("fistpl %0":"=m"(i):"t"(d):"st")

#elif defined(_WIN32) && defined(_M_IX86)
#include <math.h>
#pragma warning(disable: 4514)
__inline int l_lrint (double flt)
{     int i;
      _asm {
      fld flt
      fistp i
      };
      return i;
}
#define lua_number2int(i,d)   ((i)=l_lrint((d)))

#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L)
/* on machines compliant with C99, you can try `lrint' */
#include <math.h>
#define lua_number2int(i,d)	((i)=lrint(d))

#else
#define lua_number2int(i,d)	((i)=(int)(d))

#endif


/* function to convert a lua_Number to lua_Integer (with any rounding method) */
#define lua_number2integer(i,n)		lua_number2int((i), (n))


/* function to convert a lua_Number to a string */
#include <stdio.h>
#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))

/* function to convert a string to a lua_Number */
#define lua_str2number(s,p)	strtod((s), (p))



/* result of a `usual argument conversion' over lua_Number */
#define LUA_UACNUMBER	double



/* type to ensure maximum alignment */
#define LUSER_ALIGNMENT_T	union { double u; void *s; long l; }


/* exception handling */
#ifndef __cplusplus
/* default handling with long jumps */
#include <setjmp.h>
#define L_THROW(L,c)	longjmp((c)->b, 1)
#define L_TRY(L,c,a)	if (setjmp((c)->b) == 0) { a }
#define l_jmpbuf	jmp_buf

#else
/* C++ exceptions */
#define L_THROW(L,c)	throw(c)
#define L_TRY(L,c,a)	try { a } catch(...) \
	{ if ((c)->status == 0) (c)->status = -1; }
#define l_jmpbuf	int  /* dummy variable */
#endif



/*
** macros for thread synchronization inside Lua core machine:
** all accesses to the global state and to global objects are synchronized.
** Because threads can read the stack of other threads
** (when running garbage collection),
** a thread must also synchronize any write-access to its own stack.
** Unsynchronized accesses are allowed only when reading its own stack,
** or when reading immutable fields from global objects
** (such as string values and udata values).
*/
#define lua_lock(L)	((void) 0)
#define lua_unlock(L)	((void) 0)

/*
** this macro allows a thread switch in appropriate places in the Lua
** core
*/
#define lua_threadyield(L)	{lua_unlock(L); lua_lock(L);}



/* allows user-specific initialization on new threads */
#define lua_userstateopen(L)	/* empty */


#endif

/* }====================================================== */



/*
** {======================================================
** Library configuration
** =======================================================
*/

#ifdef LUA_LIB



/* `assert' options */

/* environment variables that hold the search path for packages */
#define LUA_PATH	"LUA_PATH"
#define LUA_CPATH	"LUA_CPATH"

/* prefix for open functions in C libraries */
#define LUA_POF		"luaopen_"

/* separator for open functions in C libraries */
#define LUA_OFSEP	""

/* directory separator (for submodules) */
#if defined(_WIN32)
#define LUA_DIRSEP	"\\"
#else
#define LUA_DIRSEP	"/"
#endif

/* separator of templates in a path */
#define LUA_PATH_SEP	';'

/* wild char in each template */
#define LUA_PATH_MARK	"?"


/* maximum number of captures in pattern-matching */
#define MAX_CAPTURES	32  /* arbitrary limit */


/*
** by default, gcc does not get `tmpname'
*/
#ifdef __GNUC__
#define USE_TMPNAME	0
#else
#define USE_TMPNAME	1 
#endif


/*
** Configuration for loadlib
*/
#if defined(_WIN32)
#define USE_DLL
#elif defined(__APPLE__) && defined(__MACH__)
#define USE_DYLD
#elif defined(__linux) || defined(sun) || defined(sgi) || defined(BSD)
#define USE_DLOPEN
#endif


#endif

/* }====================================================== */




/* Local configuration */

#endif