llimits.h 2.0 KB

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