llimits.h 2.4 KB

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