Browse Source

better support for 64-bit machines

v5-2
Roberto Ierusalimschy 20 years ago
parent
commit
2f82bf6fe9
  1. 4
      lapi.c
  2. 4
      lgc.c
  3. 23
      llimits.h
  4. 54
      luaconf.h

4
lapi.c

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.18 2004/08/30 13:44:44 roberto Exp roberto $
** $Id: lapi.c,v 2.19 2004/09/15 20:39:42 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -842,7 +842,7 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
g = G(L);
switch (what) {
case LUA_GCSTOP: {
g->GCthreshold = MAXLMEM;
g->GCthreshold = MAX_LUMEM;
break;
}
case LUA_GCRESTART: {

4
lgc.c

@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.14 2004/10/08 16:00:34 roberto Exp roberto $
** $Id: lgc.c,v 2.15 2004/11/19 15:52:40 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -555,7 +555,7 @@ static void atomic (lua_State *L) {
g->sweepgc = &g->rootgc;
g->gcstate = GCSsweepstring;
aux = g->gcgenerational;
g->gcgenerational = (g->estimate <= 4*g->prevestimate/2);
g->gcgenerational = (g->estimate/2 <= g->prevestimate);
if (!aux) /* last collection was full? */
g->prevestimate = g->estimate; /* keep estimate of last full collection */
g->estimate = g->totalbytes - udsize; /* first estimate */

23
llimits.h

@ -1,5 +1,5 @@
/*
** $Id: llimits.h,v 1.59 2004/06/23 15:57:29 roberto Exp roberto $
** $Id: llimits.h,v 1.60 2004/09/10 17:30:46 roberto Exp roberto $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@ -18,22 +18,9 @@
typedef LUA_UINT32 lu_int32;
typedef LUA_INT32 l_int32;
typedef LU_MEM lu_mem;
/*
** an unsigned integer big enough to count the total memory used by Lua;
** it should be at least as large as `size_t'
*/
typedef lu_int32 lu_mem;
/*
** a signed integer big enough to count the total memory used by Lua;
** it should be at least as large as `size_t'
*/
typedef l_int32 l_mem;
#define MAXLMEM LUA_MAXINT32
typedef L_MEM l_mem;
@ -43,6 +30,8 @@ typedef unsigned char lu_byte;
#define MAX_SIZET ((size_t)(~(size_t)0)-2)
#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
@ -51,7 +40,7 @@ typedef unsigned char lu_byte;
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
#define IntPoint(p) ((unsigned int)(p))
#define IntPoint(p) ((unsigned int)(lu_mem)(p))

54
luaconf.h

@ -1,5 +1,5 @@
/*
** $Id: luaconf.h,v 1.15 2004/10/18 18:07:31 roberto Exp roberto $
** $Id: luaconf.h,v 1.16 2004/11/18 19:53:49 roberto Exp roberto $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@ -46,8 +46,11 @@
#define LUA_NUMBER_FMT "%.14g"
/* type for integer functions */
#define LUA_INTEGER long
/*
** 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 */
@ -130,12 +133,38 @@
#define api_check(L,o) lua_assert(o)
/* an unsigned integer with at least 32 bits */
#define LUA_UINT32 unsigned long
/* 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
/* a signed integer with at least 32 bits */
/*
** 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) */
@ -174,7 +203,7 @@
/* 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 0
#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))
@ -199,17 +228,6 @@
#define LUA_UACNUMBER double
/* number of bits in an `int' */
/* avoid overflows in comparison */
#if INT_MAX-20 < 32760
#define LUA_BITSINT 16
#elif INT_MAX > 2147483640L
/* machine has at least 32 bits */
#define LUA_BITSINT 32
#else
#error "you must define LUA_BITSINT with number of bits in an integer"
#endif
/* type to ensure maximum alignment */
#define LUSER_ALIGNMENT_T union { double u; void *s; long l; }

Loading…
Cancel
Save