aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-11-24 16:55:56 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-11-24 16:55:56 -0200
commit2f82bf6fe940557fb5258c65c03e18f097ff831f (patch)
treea58f6ae8734e2f4a298b79dc6704a1e735334afc
parent087df82a61ddcf1f86e9cffe5550a1ce0174f6e2 (diff)
downloadlua-2f82bf6fe940557fb5258c65c03e18f097ff831f.tar.gz
lua-2f82bf6fe940557fb5258c65c03e18f097ff831f.tar.bz2
lua-2f82bf6fe940557fb5258c65c03e18f097ff831f.zip
better support for 64-bit machines
-rw-r--r--lapi.c4
-rw-r--r--lgc.c4
-rw-r--r--llimits.h23
-rw-r--r--luaconf.h54
4 files changed, 46 insertions, 39 deletions
diff --git a/lapi.c b/lapi.c
index 26b2c3b5..5e57f61c 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.18 2004/08/30 13:44:44 roberto Exp roberto $ 2** $Id: lapi.c,v 2.19 2004/09/15 20:39:42 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -842,7 +842,7 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
842 g = G(L); 842 g = G(L);
843 switch (what) { 843 switch (what) {
844 case LUA_GCSTOP: { 844 case LUA_GCSTOP: {
845 g->GCthreshold = MAXLMEM; 845 g->GCthreshold = MAX_LUMEM;
846 break; 846 break;
847 } 847 }
848 case LUA_GCRESTART: { 848 case LUA_GCRESTART: {
diff --git a/lgc.c b/lgc.c
index da93007d..9ad6b037 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.14 2004/10/08 16:00:34 roberto Exp roberto $ 2** $Id: lgc.c,v 2.15 2004/11/19 15:52:40 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -555,7 +555,7 @@ static void atomic (lua_State *L) {
555 g->sweepgc = &g->rootgc; 555 g->sweepgc = &g->rootgc;
556 g->gcstate = GCSsweepstring; 556 g->gcstate = GCSsweepstring;
557 aux = g->gcgenerational; 557 aux = g->gcgenerational;
558 g->gcgenerational = (g->estimate <= 4*g->prevestimate/2); 558 g->gcgenerational = (g->estimate/2 <= g->prevestimate);
559 if (!aux) /* last collection was full? */ 559 if (!aux) /* last collection was full? */
560 g->prevestimate = g->estimate; /* keep estimate of last full collection */ 560 g->prevestimate = g->estimate; /* keep estimate of last full collection */
561 g->estimate = g->totalbytes - udsize; /* first estimate */ 561 g->estimate = g->totalbytes - udsize; /* first estimate */
diff --git a/llimits.h b/llimits.h
index a07edf92..1c9bc4e6 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.59 2004/06/23 15:57:29 roberto Exp roberto $ 2** $Id: llimits.h,v 1.60 2004/09/10 17:30:46 roberto Exp roberto $
3** Limits, basic types, and some other `installation-dependent' definitions 3** Limits, basic types, and some other `installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -18,22 +18,9 @@
18 18
19typedef LUA_UINT32 lu_int32; 19typedef LUA_UINT32 lu_int32;
20 20
21typedef LUA_INT32 l_int32; 21typedef LU_MEM lu_mem;
22 22
23 23typedef L_MEM l_mem;
24/*
25** an unsigned integer big enough to count the total memory used by Lua;
26** it should be at least as large as `size_t'
27*/
28typedef lu_int32 lu_mem;
29
30
31/*
32** a signed integer big enough to count the total memory used by Lua;
33** it should be at least as large as `size_t'
34*/
35typedef l_int32 l_mem;
36#define MAXLMEM LUA_MAXINT32
37 24
38 25
39 26
@@ -43,6 +30,8 @@ typedef unsigned char lu_byte;
43 30
44#define MAX_SIZET ((size_t)(~(size_t)0)-2) 31#define MAX_SIZET ((size_t)(~(size_t)0)-2)
45 32
33#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
34
46 35
47#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ 36#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
48 37
@@ -51,7 +40,7 @@ typedef unsigned char lu_byte;
51** this is for hashing only; there is no problem if the integer 40** this is for hashing only; there is no problem if the integer
52** cannot hold the whole pointer value 41** cannot hold the whole pointer value
53*/ 42*/
54#define IntPoint(p) ((unsigned int)(p)) 43#define IntPoint(p) ((unsigned int)(lu_mem)(p))
55 44
56 45
57 46
diff --git a/luaconf.h b/luaconf.h
index 46c4998c..389cb521 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.15 2004/10/18 18:07:31 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.16 2004/11/18 19:53:49 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*/
@@ -46,8 +46,11 @@
46#define LUA_NUMBER_FMT "%.14g" 46#define LUA_NUMBER_FMT "%.14g"
47 47
48 48
49/* type for integer functions */ 49/*
50#define LUA_INTEGER long 50** type for integer functions
51** on most machines, `ptrdiff_t' gives a reasonable size for integers
52*/
53#define LUA_INTEGER ptrdiff_t
51 54
52 55
53/* mark for all API functions */ 56/* mark for all API functions */
@@ -130,12 +133,38 @@
130#define api_check(L,o) lua_assert(o) 133#define api_check(L,o) lua_assert(o)
131 134
132 135
133/* an unsigned integer with at least 32 bits */ 136/* number of bits in an `int' */
134#define LUA_UINT32 unsigned long 137/* avoid overflows in comparison */
138#if INT_MAX-20 < 32760
139#define LUA_BITSINT 16
140#elif INT_MAX > 2147483640L
141/* `int' has at least 32 bits */
142#define LUA_BITSINT 32
143#else
144#error "you must define LUA_BITSINT with number of bits in an integer"
145#endif
146
135 147
136/* a signed integer with at least 32 bits */ 148/*
149** L_UINT32: unsigned integer with at least 32 bits
150** L_INT32: signed integer with at least 32 bits
151** LU_MEM: an unsigned integer big enough to count the total memory used by Lua
152** L_MEM: a signed integer big enough to count the total memory used by Lua
153*/
154#if LUA_BITSINT >= 32
155#define LUA_UINT32 unsigned int
156#define LUA_INT32 int
157#define LUA_MAXINT32 INT_MAX
158#define LU_MEM size_t
159#define L_MEM ptrdiff_t
160#else
161/* 16-bit ints */
162#define LUA_UINT32 unsigned long
137#define LUA_INT32 long 163#define LUA_INT32 long
138#define LUA_MAXINT32 LONG_MAX 164#define LUA_MAXINT32 LONG_MAX
165#define LU_MEM LUA_UINT32
166#define L_MEM ptrdiff_t
167#endif
139 168
140 169
141/* maximum depth for calls (unsigned short) */ 170/* maximum depth for calls (unsigned short) */
@@ -174,7 +203,7 @@
174/* function to convert a lua_Number to int (with any rounding method) */ 203/* function to convert a lua_Number to int (with any rounding method) */
175#if defined(__GNUC__) && defined(__i386) 204#if defined(__GNUC__) && defined(__i386)
176#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") 205#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
177#elif 0 206#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L)
178/* on machines compliant with C99, you can try `lrint' */ 207/* on machines compliant with C99, you can try `lrint' */
179#include <math.h> 208#include <math.h>
180#define lua_number2int(i,d) ((i)=lrint(d)) 209#define lua_number2int(i,d) ((i)=lrint(d))
@@ -199,17 +228,6 @@
199#define LUA_UACNUMBER double 228#define LUA_UACNUMBER double
200 229
201 230
202/* number of bits in an `int' */
203/* avoid overflows in comparison */
204#if INT_MAX-20 < 32760
205#define LUA_BITSINT 16
206#elif INT_MAX > 2147483640L
207/* machine has at least 32 bits */
208#define LUA_BITSINT 32
209#else
210#error "you must define LUA_BITSINT with number of bits in an integer"
211#endif
212
213 231
214/* type to ensure maximum alignment */ 232/* type to ensure maximum alignment */
215#define LUSER_ALIGNMENT_T union { double u; void *s; long l; } 233#define LUSER_ALIGNMENT_T union { double u; void *s; long l; }