llimits.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. ** $Id: llimits.h,v 1.54 2003/04/28 19:57:50 roberto Exp roberto $
  3. ** Limits, basic types, and some other `installation-dependent' definitions
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef llimits_h
  7. #define llimits_h
  8. #include <limits.h>
  9. #include <stddef.h>
  10. #include "lua.h"
  11. /*
  12. ** try to find number of bits in an integer
  13. */
  14. #ifndef BITS_INT
  15. /* avoid overflows in comparison */
  16. #if INT_MAX-20 < 32760
  17. #define BITS_INT 16
  18. #elif INT_MAX > 2147483640L
  19. /* machine has at least 32 bits */
  20. #define BITS_INT 32
  21. #else
  22. #error "you must define BITS_INT with number of bits in an integer"
  23. #endif
  24. #endif
  25. /*
  26. ** the following types define integer types for values that may not
  27. ** fit in a `small int' (16 bits), but may waste space in a
  28. ** `large long' (64 bits). The current definitions should work in
  29. ** any machine, but may not be optimal.
  30. */
  31. /*
  32. ** an unsigned integer with at least 32 bits
  33. */
  34. #ifndef LUA_UINT32
  35. #define LUA_UINT32 unsigned long
  36. #endif
  37. typedef LUA_UINT32 lu_int32;
  38. /*
  39. ** an unsigned integer big enough to count the total memory used by Lua;
  40. ** it should be at least as large as `size_t'
  41. */
  42. typedef lu_int32 lu_mem;
  43. /* chars used as small naturals (so that `char' is reserved for characters) */
  44. typedef unsigned char lu_byte;
  45. #define MAX_SIZET ((size_t)(~(size_t)0)-2)
  46. #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
  47. /*
  48. ** conversion of pointer to integer
  49. ** this is for hashing only; there is no problem if the integer
  50. ** cannot hold the whole pointer value
  51. */
  52. #define IntPoint(p) ((unsigned int)(p))
  53. /* type to ensure maximum alignment */
  54. #ifndef LUSER_ALIGNMENT_T
  55. typedef union { double u; void *s; long l; } L_Umaxalign;
  56. #else
  57. typedef LUSER_ALIGNMENT_T L_Umaxalign;
  58. #endif
  59. /* result of `usual argument conversion' over lua_Number */
  60. #ifndef LUA_UACNUMBER
  61. typedef double l_uacNumber;
  62. #else
  63. typedef LUA_UACNUMBER l_uacNumber;
  64. #endif
  65. #ifndef lua_assert
  66. #define lua_assert(c) /* empty */
  67. #endif
  68. #ifndef check_exp
  69. #define check_exp(c,e) (e)
  70. #endif
  71. #ifndef UNUSED
  72. #define UNUSED(x) ((void)(x)) /* to avoid warnings */
  73. #endif
  74. #ifndef cast
  75. #define cast(t, exp) ((t)(exp))
  76. #endif
  77. /*
  78. ** type for virtual-machine instructions
  79. ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
  80. */
  81. typedef lu_int32 Instruction;
  82. /* maximum depth for calls (unsigned short) */
  83. #ifndef LUA_MAXCALLS
  84. #define LUA_MAXCALLS 4096
  85. #endif
  86. /*
  87. ** maximum depth for C calls (unsigned short): Not too big, or may
  88. ** overflow the C stack...
  89. */
  90. #ifndef LUA_MAXCCALLS
  91. #define LUA_MAXCCALLS 200
  92. #endif
  93. /* maximum size for the virtual stack of a C function */
  94. #ifndef LUA_MAXCSTACK
  95. #define LUA_MAXCSTACK 2048
  96. #endif
  97. /* maximum stack for a Lua function */
  98. #define MAXSTACK 250
  99. /* maximum number of variables declared in a function */
  100. #ifndef MAXVARS
  101. #define MAXVARS 200 /* <MAXSTACK */
  102. #endif
  103. /* maximum number of upvalues per function */
  104. #ifndef MAXUPVALUES
  105. #define MAXUPVALUES 32 /* <MAXSTACK */
  106. #endif
  107. /* maximum number of parameters in a function */
  108. #ifndef MAXPARAMS
  109. #define MAXPARAMS 100 /* <MAXLOCALS */
  110. #endif
  111. /* minimum size for the string table (must be power of 2) */
  112. #ifndef MINSTRTABSIZE
  113. #define MINSTRTABSIZE 32
  114. #endif
  115. /* minimum size for string buffer */
  116. #ifndef LUA_MINBUFFER
  117. #define LUA_MINBUFFER 32
  118. #endif
  119. /*
  120. ** maximum number of syntactical nested non-terminals: Not too big,
  121. ** or may overflow the C stack...
  122. */
  123. #ifndef LUA_MAXPARSERLEVEL
  124. #define LUA_MAXPARSERLEVEL 200
  125. #endif
  126. #endif