2812
|
1 |
/*
|
|
2 |
** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
|
|
3 |
** Limits, basic types, and some other `installation-dependent' definitions
|
|
4 |
** See Copyright Notice in lua.h
|
|
5 |
*/
|
|
6 |
|
|
7 |
#ifndef llimits_h
|
|
8 |
#define llimits_h
|
|
9 |
|
|
10 |
|
|
11 |
#include <limits.h>
|
|
12 |
#include <stddef.h>
|
|
13 |
|
|
14 |
|
|
15 |
#include "lua.h"
|
|
16 |
|
|
17 |
|
|
18 |
typedef LUAI_UINT32 lu_int32;
|
|
19 |
|
|
20 |
typedef LUAI_UMEM lu_mem;
|
|
21 |
|
|
22 |
typedef LUAI_MEM l_mem;
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/* chars used as small naturals (so that `char' is reserved for characters) */
|
|
27 |
typedef unsigned char lu_byte;
|
|
28 |
|
|
29 |
|
10017
|
30 |
#define MAX_SIZET ((size_t)(~(size_t)0)-2)
|
2812
|
31 |
|
10017
|
32 |
#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
|
2812
|
33 |
|
|
34 |
|
|
35 |
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
|
|
36 |
|
|
37 |
/*
|
|
38 |
** conversion of pointer to integer
|
|
39 |
** this is for hashing only; there is no problem if the integer
|
|
40 |
** cannot hold the whole pointer value
|
|
41 |
*/
|
|
42 |
#define IntPoint(p) ((unsigned int)(lu_mem)(p))
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
/* type to ensure maximum alignment */
|
|
47 |
typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
|
|
48 |
|
|
49 |
|
|
50 |
/* result of a `usual argument conversion' over lua_Number */
|
|
51 |
typedef LUAI_UACNUMBER l_uacNumber;
|
|
52 |
|
|
53 |
|
|
54 |
/* internal assertions for in-house debugging */
|
|
55 |
#ifdef lua_assert
|
|
56 |
|
10017
|
57 |
#define check_exp(c,e) (lua_assert(c), (e))
|
|
58 |
#define api_check(l,e) lua_assert(e)
|
2812
|
59 |
|
|
60 |
#else
|
|
61 |
|
10017
|
62 |
#define lua_assert(c) ((void)0)
|
|
63 |
#define check_exp(c,e) (e)
|
|
64 |
#define api_check luai_apicheck
|
2812
|
65 |
|
|
66 |
#endif
|
|
67 |
|
|
68 |
|
|
69 |
#ifndef UNUSED
|
10017
|
70 |
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
|
2812
|
71 |
#endif
|
|
72 |
|
|
73 |
|
|
74 |
#ifndef cast
|
10017
|
75 |
#define cast(t, exp) ((t)(exp))
|
2812
|
76 |
#endif
|
|
77 |
|
10017
|
78 |
#define cast_byte(i) cast(lu_byte, (i))
|
|
79 |
#define cast_num(i) cast(lua_Number, (i))
|
|
80 |
#define cast_int(i) cast(int, (i))
|
2812
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
/*
|
|
85 |
** type for virtual-machine instructions
|
|
86 |
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
|
|
87 |
*/
|
|
88 |
typedef lu_int32 Instruction;
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
/* maximum stack for a Lua function */
|
10017
|
93 |
#define MAXSTACK 250
|
2812
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
/* minimum size for the string table (must be power of 2) */
|
|
98 |
#ifndef MINSTRTABSIZE
|
10017
|
99 |
#define MINSTRTABSIZE 32
|
2812
|
100 |
#endif
|
|
101 |
|
|
102 |
|
|
103 |
/* minimum size for string buffer */
|
|
104 |
#ifndef LUA_MINBUFFER
|
10017
|
105 |
#define LUA_MINBUFFER 32
|
2812
|
106 |
#endif
|
|
107 |
|
|
108 |
|
|
109 |
#ifndef lua_lock
|
3697
|
110 |
#define lua_lock(L) ((void) 0)
|
2812
|
111 |
#define lua_unlock(L) ((void) 0)
|
|
112 |
#endif
|
|
113 |
|
|
114 |
#ifndef luai_threadyield
|
|
115 |
#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
|
|
116 |
#endif
|
|
117 |
|
|
118 |
|
|
119 |
/*
|
|
120 |
** macro to control inclusion of some hard tests on stack reallocation
|
3697
|
121 |
*/
|
2812
|
122 |
#ifndef HARDSTACKTESTS
|
10017
|
123 |
#define condhardstacktests(x) ((void)0)
|
2812
|
124 |
#else
|
10017
|
125 |
#define condhardstacktests(x) x
|
2812
|
126 |
#endif
|
|
127 |
|
|
128 |
#endif
|