llimits.h 2.2 KB

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