~ubuntu-branches/ubuntu/intrepid/enigma/intrepid

« back to all changes in this revision

Viewing changes to lib-src/lua/llimits.h

  • Committer: Bazaar Package Importer
  • Author(s): Erich Schubert
  • Date: 2005-08-28 15:30:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050828153009-sky64kb6tcq37xt5
Tags: 0.92.1-1
* New upstream subversion checkout
* Remove menu.s3m, which we are allowed to distributed but not to modify
  also copyright notice is confusing... (Closes: #321669)
* Rebuild with new libzipios (Closes: #325405)
  I hope this works without a versioned build-dependency
* Added "enigma replaces enigma-data" for upgrades (Closes: #308558)
* Added notes about the fonts copyright.
* updated to policy 3.6.2.1 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
** $Id: llimits.h,v 1.1 2003/02/09 21:30:32 dheck 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
 
 
16
 
/*
17
 
** try to find number of bits in an integer
18
 
*/
19
 
#ifndef BITS_INT
20
 
/* avoid overflows in comparison */
21
 
#if INT_MAX-20 < 32760
22
 
#define BITS_INT        16
23
 
#else
24
 
#if INT_MAX > 2147483640L
25
 
/* machine has at least 32 bits */
26
 
#define BITS_INT        32
27
 
#else
28
 
#error "you must define BITS_INT with number of bits in an integer"
29
 
#endif
30
 
#endif
31
 
#endif
32
 
 
33
 
 
34
 
/*
35
 
** Define the type `number' of Lua
36
 
** GREP LUA_NUMBER to change that
37
 
*/
38
 
#ifndef LUA_NUM_TYPE
39
 
#define LUA_NUM_TYPE double
40
 
#endif
41
 
 
42
 
typedef LUA_NUM_TYPE Number;
43
 
 
44
 
/* function to convert a Number to a string */
45
 
#define NUMBER_FMT      "%.16g"         /* LUA_NUMBER */
46
 
#define lua_number2str(s,n)     sprintf((s), NUMBER_FMT, (n))
47
 
 
48
 
/* function to convert a string to a Number */
49
 
#define lua_str2number(s,p)     strtod((s), (p))
50
 
 
51
 
 
52
 
 
53
 
typedef unsigned long lint32;  /* unsigned int with at least 32 bits */
54
 
 
55
 
 
56
 
#define MAX_SIZET       ((size_t)(~(size_t)0)-2)
57
 
 
58
 
 
59
 
#define MAX_INT (INT_MAX-2)  /* maximum value of an int (-2 for safety) */
60
 
 
61
 
/*
62
 
** conversion of pointer to int (for hashing only)
63
 
** (the shift removes bits that are usually 0 because of alignment)
64
 
*/
65
 
#define IntPoint(p)  (((unsigned long)(p)) >> 3)
66
 
 
67
 
 
68
 
 
69
 
#define MINPOWER2       4       /* minimum size for "growing" vectors */
70
 
 
71
 
 
72
 
 
73
 
#ifndef DEFAULT_STACK_SIZE
74
 
#define DEFAULT_STACK_SIZE      1024
75
 
#endif
76
 
 
77
 
 
78
 
 
79
 
/* type to ensure maximum alignment */
80
 
union L_Umaxalign { double d; char *s; long l; };
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
 
** For a very small machine, you may change that to 2 bytes (and adjust
88
 
** the following limits accordingly)
89
 
*/
90
 
typedef unsigned long Instruction;
91
 
 
92
 
 
93
 
/*
94
 
** size and position of opcode arguments.
95
 
** For an instruction with 2 bytes, size is 16, and size_b can be 5
96
 
** (accordingly, size_u will be 10, and size_a will be 5)
97
 
*/
98
 
#define SIZE_INSTRUCTION        32
99
 
#define SIZE_B          9
100
 
 
101
 
#define SIZE_OP         6
102
 
#define SIZE_U          (SIZE_INSTRUCTION-SIZE_OP)
103
 
#define POS_U           SIZE_OP
104
 
#define POS_B           SIZE_OP
105
 
#define SIZE_A          (SIZE_INSTRUCTION-(SIZE_OP+SIZE_B))
106
 
#define POS_A           (SIZE_OP+SIZE_B)
107
 
 
108
 
 
109
 
/*
110
 
** limits for opcode arguments.
111
 
** we use (signed) int to manipulate most arguments,
112
 
** so they must fit in BITS_INT-1 bits (-1 for sign)
113
 
*/
114
 
#if SIZE_U < BITS_INT-1
115
 
#define MAXARG_U        ((1<<SIZE_U)-1)
116
 
#define MAXARG_S        (MAXARG_U>>1)           /* `S' is signed */
117
 
#else
118
 
#define MAXARG_U        MAX_INT
119
 
#define MAXARG_S        MAX_INT
120
 
#endif
121
 
 
122
 
#if SIZE_A < BITS_INT-1
123
 
#define MAXARG_A        ((1<<SIZE_A)-1)
124
 
#else
125
 
#define MAXARG_A        MAX_INT
126
 
#endif
127
 
 
128
 
#if SIZE_B < BITS_INT-1
129
 
#define MAXARG_B        ((1<<SIZE_B)-1)
130
 
#else
131
 
#define MAXARG_B        MAX_INT
132
 
#endif
133
 
 
134
 
 
135
 
/* maximum stack size in a function */
136
 
#ifndef MAXSTACK
137
 
#define MAXSTACK        250
138
 
#endif
139
 
 
140
 
#if MAXSTACK > MAXARG_B
141
 
#undef MAXSTACK
142
 
#define MAXSTACK        MAXARG_B
143
 
#endif
144
 
 
145
 
 
146
 
/* maximum number of local variables */
147
 
#ifndef MAXLOCALS
148
 
#define MAXLOCALS 200           /* arbitrary limit (<MAXSTACK) */
149
 
#endif
150
 
#if MAXLOCALS>=MAXSTACK
151
 
#undef MAXLOCALS
152
 
#define MAXLOCALS       (MAXSTACK-1)
153
 
#endif
154
 
 
155
 
 
156
 
/* maximum number of upvalues */
157
 
#ifndef MAXUPVALUES
158
 
#define MAXUPVALUES 32          /* arbitrary limit (<=MAXARG_B) */
159
 
#endif
160
 
#if MAXUPVALUES>MAXARG_B
161
 
#undef MAXUPVALUES
162
 
#define MAXUPVALUES     MAXARG_B
163
 
#endif
164
 
 
165
 
 
166
 
/* maximum number of variables in the left side of an assignment */
167
 
#ifndef MAXVARSLH
168
 
#define MAXVARSLH 100           /* arbitrary limit (<MULT_RET) */
169
 
#endif
170
 
#if MAXVARSLH>=MULT_RET
171
 
#undef MAXVARSLH
172
 
#define MAXVARSLH       (MULT_RET-1)
173
 
#endif
174
 
 
175
 
 
176
 
/* maximum number of parameters in a function */
177
 
#ifndef MAXPARAMS
178
 
#define MAXPARAMS 100           /* arbitrary limit (<MAXLOCALS) */
179
 
#endif
180
 
#if MAXPARAMS>=MAXLOCALS
181
 
#undef MAXPARAMS
182
 
#define MAXPARAMS       (MAXLOCALS-1)
183
 
#endif
184
 
 
185
 
 
186
 
/* number of list items to accumulate before a SETLIST instruction */
187
 
#define LFIELDS_PER_FLUSH       64
188
 
#if LFIELDS_PER_FLUSH>(MAXSTACK/4)
189
 
#undef LFIELDS_PER_FLUSH
190
 
#define LFIELDS_PER_FLUSH       (MAXSTACK/4)
191
 
#endif
192
 
 
193
 
/* number of record items to accumulate before a SETMAP instruction */
194
 
/* (each item counts 2 elements on the stack: an index and a value) */
195
 
#define RFIELDS_PER_FLUSH       (LFIELDS_PER_FLUSH/2)
196
 
 
197
 
 
198
 
/* maximum lookback to find a real constant (for code generation) */
199
 
#ifndef LOOKBACKNUMS
200
 
#define LOOKBACKNUMS    20      /* arbitrary constant */
201
 
#endif
202
 
 
203
 
 
204
 
#endif