llimits.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
  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 "c_limits.h"
  9. #include "lua.h"
  10. typedef LUAI_UINT32 lu_int32;
  11. typedef LUAI_UMEM lu_mem;
  12. typedef LUAI_MEM l_mem;
  13. /* chars used as small naturals (so that `char' is reserved for characters) */
  14. typedef unsigned char lu_byte;
  15. #define MAX_SIZET ((size_t)(~(size_t)0)-2)
  16. #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
  17. #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
  18. /*
  19. ** conversion of pointer to integer
  20. ** this is for hashing only; there is no problem if the integer
  21. ** cannot hold the whole pointer value
  22. */
  23. #define IntPoint(p) ((unsigned int)(lu_mem)(p))
  24. /* type to ensure maximum alignment */
  25. typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
  26. /* result of a `usual argument conversion' over lua_Number */
  27. typedef LUAI_UACNUMBER l_uacNumber;
  28. /* internal assertions for in-house debugging */
  29. #ifdef lua_assert
  30. #define check_exp(c,e) (lua_assert(c), (e))
  31. #define api_check(l,e) lua_assert(e)
  32. #else
  33. #define lua_assert(c) ((void)0)
  34. #define check_exp(c,e) (e)
  35. #define api_check luai_apicheck
  36. #endif
  37. #ifndef UNUSED
  38. #define UNUSED(x) ((void)(x)) /* to avoid warnings */
  39. #endif
  40. #ifndef cast
  41. #define cast(t, exp) ((t)(exp))
  42. #endif
  43. #define cast_byte(i) cast(lu_byte, (i))
  44. #define cast_num(i) cast(lua_Number, (i))
  45. #define cast_int(i) cast(int, (i))
  46. /*
  47. ** type for virtual-machine instructions
  48. ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
  49. */
  50. typedef lu_int32 Instruction;
  51. /* maximum stack for a Lua function */
  52. #define MAXSTACK 250
  53. /* minimum size for the string table (must be power of 2) */
  54. #ifndef MINSTRTABSIZE
  55. #define MINSTRTABSIZE 32
  56. #endif
  57. /* minimum size for string buffer */
  58. #ifndef LUA_MINBUFFER
  59. #define LUA_MINBUFFER 32
  60. #endif
  61. #ifndef lua_lock
  62. #define lua_lock(L) ((void) 0)
  63. #define lua_unlock(L) ((void) 0)
  64. #endif
  65. #ifndef luai_threadyield
  66. #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
  67. #endif
  68. /*
  69. ** macro to control inclusion of some hard tests on stack reallocation
  70. */
  71. #ifndef HARDSTACKTESTS
  72. #define condhardstacktests(x) ((void)0)
  73. #else
  74. #define condhardstacktests(x) x
  75. #endif
  76. #endif