lua/llimits.h

131 lines
2.8 KiB
C
Raw Normal View History

/*
** $Id: llimits.h,v 1.28 2001/03/26 14:31:49 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 to hold hash values */
typedef unsigned int lu_hash;
/* its signed equivalent */
typedef int ls_hash;
/* an unsigned integer big enough to count the total memory used by Lua */
2001-02-20 21:15:33 +03:00
typedef unsigned long lu_mem;
/* an integer big enough to count the number of strings in use */
typedef long ls_nstr;
/* chars used as small naturals (so that `char' is reserved for characteres) */
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
** (the shift removes bits that are usually 0 because of alignment)
*/
2001-02-20 21:15:33 +03:00
#define IntPoint(p) ((((lu_hash)(p)) >> 4) ^ (lu_hash)(p))
2001-02-23 20:17:25 +03:00
#define MINPOWER2 4 /* minimum size for `growing' vectors */
2000-03-31 20:28:45 +04:00
#ifndef DEFAULT_STACK_SIZE
#define DEFAULT_STACK_SIZE 1024
#endif
2000-10-26 16:47:05 +04:00
/* type to ensure maximum alignment */
2001-02-20 21:15:33 +03:00
union L_Umaxalign { double d; void *s; long l; };
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)
*/
2001-02-20 21:15:33 +03:00
typedef unsigned long Instruction;
/* maximum stack for a Lua function */
#define MAXSTACK 250
/* maximum number of local variables */
#ifndef MAXLOCALS
#define MAXLOCALS 200 /* arbitrary limit (<MAXSTACK) */
#endif
/* maximum number of upvalues */
#ifndef MAXUPVALUES
#define MAXUPVALUES 32 /* arbitrary limit (<MAXSTACK) */
#endif
/* maximum number of parameters in a function */
#ifndef MAXPARAMS
#define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */
#endif
/* number of list items to accumulate before a SETLIST instruction */
/* (must be a power of 2) */
2000-03-31 20:28:45 +04:00
#define LFIELDS_PER_FLUSH 64
/* maximum lookback to find a real constant (for code generation) */
#ifndef LOOKBACKNUMS
#define LOOKBACKNUMS 40 /* arbitrary constant */
#endif
#endif