lua/llimits.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: llimits.h,v 1.1 2004/03/16 21:58:30 niemeyer Exp $
00003 ** Limits, basic types, and some other `installation-dependent' definitions
00004 ** See Copyright Notice in lua.h
00005 */
00006 
00007 #ifndef llimits_h
00008 #define llimits_h
00009 
00010 
00011 #include <limits.h>
00012 #include <stddef.h>
00013 
00014 
00015 #include "lua.h"
00016 
00017 
00018 /*
00019 ** try to find number of bits in an integer
00020 */
00021 #ifndef BITS_INT
00022 /* avoid overflows in comparison */
00023 #if INT_MAX-20 < 32760
00024 #define BITS_INT        16
00025 #else
00026 #if INT_MAX > 2147483640L
00027 /* machine has at least 32 bits */
00028 #define BITS_INT        32
00029 #else
00030 #error "you must define BITS_INT with number of bits in an integer"
00031 #endif
00032 #endif
00033 #endif
00034 
00035 
00036 /*
00037 ** the following types define integer types for values that may not
00038 ** fit in a `small int' (16 bits), but may waste space in a
00039 ** `large long' (64 bits). The current definitions should work in
00040 ** any machine, but may not be optimal.
00041 */
00042 
00043 /* an unsigned integer to hold hash values */
00044 typedef unsigned int lu_hash;
00045 /* its signed equivalent */
00046 typedef int ls_hash;
00047 
00048 /* an unsigned integer big enough to count the total memory used by Lua; */
00049 /* it should be at least as large as size_t */
00050 typedef unsigned long lu_mem;
00051 
00052 #define MAX_LUMEM       ULONG_MAX
00053 
00054 
00055 /* an integer big enough to count the number of strings in use */
00056 typedef long ls_nstr;
00057 
00058 /* chars used as small naturals (so that `char' is reserved for characters) */
00059 typedef unsigned char lu_byte;
00060 
00061 
00062 #define MAX_SIZET       ((size_t)(~(size_t)0)-2)
00063 
00064 
00065 #define MAX_INT (INT_MAX-2)  /* maximum value of an int (-2 for safety) */
00066 
00067 /*
00068 ** conversion of pointer to integer
00069 ** this is for hashing only; there is no problem if the integer
00070 ** cannot hold the whole pointer value
00071 */
00072 #define IntPoint(p)  ((lu_hash)(p))
00073 
00074 
00075 
00076 /* type to ensure maximum alignment */
00077 #ifndef LUSER_ALIGNMENT_T
00078 typedef union { double u; void *s; long l; } L_Umaxalign;
00079 #else
00080 typedef LUSER_ALIGNMENT_T L_Umaxalign;
00081 #endif
00082 
00083 
00084 /* result of `usual argument conversion' over lua_Number */
00085 #ifndef LUA_UACNUMBER
00086 typedef double l_uacNumber;
00087 #else
00088 typedef LUA_UACNUMBER l_uacNumber;
00089 #endif
00090 
00091 
00092 #ifndef lua_assert
00093 #define lua_assert(c)           /* empty */
00094 #endif
00095 
00096 
00097 #ifndef check_exp
00098 #define check_exp(c,e)  (e)
00099 #endif
00100 
00101 
00102 #ifndef UNUSED
00103 #define UNUSED(x)       ((void)(x))     /* to avoid warnings */
00104 #endif
00105 
00106 
00107 #ifndef cast
00108 #define cast(t, exp)    ((t)(exp))
00109 #endif
00110 
00111 
00112 
00113 /*
00114 ** type for virtual-machine instructions
00115 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
00116 */
00117 typedef unsigned long Instruction;
00118 
00119 
00120 /* maximum depth for calls (unsigned short) */
00121 #ifndef LUA_MAXCALLS
00122 #define LUA_MAXCALLS        4096
00123 #endif
00124 
00125 
00126 /*
00127 ** maximum depth for C calls (unsigned short): Not too big, or may
00128 ** overflow the C stack...
00129 */
00130 
00131 #ifndef LUA_MAXCCALLS
00132 #define LUA_MAXCCALLS        200
00133 #endif
00134 
00135 
00136 /* maximum size for the C stack */
00137 #ifndef LUA_MAXCSTACK
00138 #define LUA_MAXCSTACK        2048
00139 #endif
00140 
00141 
00142 /* maximum stack for a Lua function */
00143 #define MAXSTACK        250
00144 
00145 
00146 /* maximum number of variables declared in a function */
00147 #ifndef MAXVARS
00148 #define MAXVARS 200           /* arbitrary limit (<MAXSTACK) */
00149 #endif
00150 
00151 
00152 /* maximum number of upvalues per function */
00153 #ifndef MAXUPVALUES
00154 #define MAXUPVALUES     32
00155 #endif
00156 
00157 
00158 /* maximum number of parameters in a function */
00159 #ifndef MAXPARAMS
00160 #define MAXPARAMS 100           /* arbitrary limit (<MAXLOCALS) */
00161 #endif
00162 
00163 
00164 /* minimum size for the string table (must be power of 2) */
00165 #ifndef MINSTRTABSIZE
00166 #define MINSTRTABSIZE   32
00167 #endif
00168 
00169 
00170 /* minimum size for string buffer */
00171 #ifndef LUA_MINBUFFER
00172 #define LUA_MINBUFFER   32
00173 #endif
00174 
00175 
00176 /*
00177 ** maximum number of syntactical nested non-terminals: Not too big,
00178 ** or may overflow the C stack...
00179 */
00180 #ifndef LUA_MAXPARSERLEVEL
00181 #define LUA_MAXPARSERLEVEL      200
00182 #endif
00183 
00184 
00185 #endif

Generated on Fri Oct 12 08:44:54 2007 for rpm by  doxygen 1.5.2