llimits.h 2.3 KB

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