lua/llimits.h

189 lines
3.4 KiB
C
Raw Normal View History

/*
2003-04-28 23:57:50 +04:00
** $Id: llimits.h,v 1.53 2003/04/28 19:26:16 roberto Exp roberto $
2001-02-23 20:17:25 +03:00
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
2000-03-24 22:49:23 +03:00
#ifndef llimits_h
#define llimits_h
#include <limits.h>
2000-05-24 17:54:49 +04:00
#include <stddef.h>
#include "lua.h"
/*
** try to find number of bits in an integer
*/
#ifndef BITS_INT
/* avoid overflows in comparison */
#if INT_MAX-20 < 32760
#define BITS_INT 16
#else
#if INT_MAX > 2147483640L
/* machine has at least 32 bits */
#define BITS_INT 32
#else
#error "you must define BITS_INT with number of bits in an integer"
#endif
#endif
#endif
2001-02-20 21:15:33 +03:00
/*
** the following types define integer types for values that may not
2001-02-23 20:17:25 +03:00
** fit in a `small int' (16 bits), but may waste space in a
** `large long' (64 bits). The current definitions should work in
2001-02-20 21:15:33 +03:00
** any machine, but may not be optimal.
*/
/*
** an unsigned integer with at least 32 bits
*/
#ifndef LUA_UINT32
#define LUA_UINT32 unsigned long
#endif
typedef LUA_UINT32 lu_int32;
2001-02-20 21:15:33 +03:00
2003-02-20 23:12:39 +03:00
/*
** 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;
2001-02-20 21:15:33 +03:00
2002-11-22 21:01:46 +03:00
/* chars used as small naturals (so that `char' is reserved for characters) */
2001-02-20 21:15:33 +03:00
typedef unsigned char lu_byte;
2000-05-24 17:54:49 +04:00
#define MAX_SIZET ((size_t)(~(size_t)0)-2)
2000-05-24 17:54:49 +04:00
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
/*
2001-02-20 21:15:33 +03:00
** conversion of pointer to integer
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
#define IntPoint(p) ((unsigned int)(p))
2000-03-31 20:28:45 +04:00
2000-10-26 16:47:05 +04:00
/* type to ensure maximum alignment */
#ifndef LUSER_ALIGNMENT_T
typedef union { double u; void *s; long l; } L_Umaxalign;
#else
typedef LUSER_ALIGNMENT_T L_Umaxalign;
#endif
2002-11-22 21:01:46 +03:00
/* result of `usual argument conversion' over lua_Number */
#ifndef LUA_UACNUMBER
typedef double l_uacNumber;
#else
typedef LUA_UACNUMBER l_uacNumber;
#endif
2000-10-26 16:47:05 +04:00
#ifndef lua_assert
#define lua_assert(c) /* empty */
#endif
#ifndef check_exp
#define check_exp(c,e) (e)
#endif
#ifndef UNUSED
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
#endif
#ifndef cast
#define cast(t, exp) ((t)(exp))
#endif
2000-10-26 16:47:05 +04:00
/*
** type for virtual-machine instructions
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
*/
typedef lu_int32 Instruction;
/* maximum depth for calls (unsigned short) */
2002-03-26 23:46:10 +03:00
#ifndef LUA_MAXCALLS
2002-04-23 18:59:35 +04:00
#define LUA_MAXCALLS 4096
2002-03-26 23:46:10 +03:00
#endif
/*
** maximum depth for C calls (unsigned short): Not too big, or may
** overflow the C stack...
*/
#ifndef LUA_MAXCCALLS
#define LUA_MAXCCALLS 200
#endif
2003-04-28 23:57:50 +04:00
/* maximum size for the virtual stack of a C function */
2002-03-26 23:46:10 +03:00
#ifndef LUA_MAXCSTACK
#define LUA_MAXCSTACK 2048
2002-03-07 21:11:51 +03:00
#endif
/* maximum stack for a Lua function */
#define MAXSTACK 250
2002-03-14 21:01:52 +03:00
/* maximum number of variables declared in a function */
#ifndef MAXVARS
2003-04-28 23:57:50 +04:00
#define MAXVARS 200 /* <MAXSTACK */
#endif
2001-10-02 20:45:03 +04:00
/* maximum number of upvalues per function */
#ifndef MAXUPVALUES
2003-04-28 23:57:50 +04:00
#define MAXUPVALUES 32 /* <MAXSTACK */
#endif
/* maximum number of parameters in a function */
#ifndef MAXPARAMS
2003-04-28 23:57:50 +04:00
#define MAXPARAMS 100 /* <MAXLOCALS */
#endif
2002-03-07 21:11:51 +03:00
/* minimum size for the string table (must be power of 2) */
#ifndef MINSTRTABSIZE
2002-03-07 21:11:51 +03:00
#define MINSTRTABSIZE 32
#endif
/* minimum size for string buffer */
#ifndef LUA_MINBUFFER
#define LUA_MINBUFFER 32
#endif
/*
** maximum number of syntactical nested non-terminals: Not too big,
** or may overflow the C stack...
*/
2002-11-22 19:35:20 +03:00
#ifndef LUA_MAXPARSERLEVEL
#define LUA_MAXPARSERLEVEL 200
#endif
#endif