aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2023-11-09 23:03:21 +0100
committerThijs Schreijer <thijs@thijsschreijer.nl>2023-11-15 19:17:57 +0100
commitd45768de3e6f7b28bfecf4d19b192ccac9ce5dc2 (patch)
tree2d4f86ec87eb87a77f6663924aaaa9286756ce3e /src/compat.h
parentd4222ce6da2a2d7179fc79f9d0cc65fd6c09a686 (diff)
downloadluasystem-d45768de3e6f7b28bfecf4d19b192ccac9ce5dc2.tar.gz
luasystem-d45768de3e6f7b28bfecf4d19b192ccac9ce5dc2.tar.bz2
luasystem-d45768de3e6f7b28bfecf4d19b192ccac9ce5dc2.zip
feat(*): add environment variable and random functions
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h
index f523fd9..5aca6df 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -8,4 +8,31 @@
8void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup); 8void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
9#endif 9#endif
10 10
11// Windows doesn't have ssize_t, so we define it here
12#ifdef _WIN32
13#if SIZE_MAX == UINT_MAX
14typedef int ssize_t; /* common 32 bit case */
15#define SSIZE_MIN INT_MIN
16#define SSIZE_MAX INT_MAX
17#elif SIZE_MAX == ULONG_MAX
18typedef long ssize_t; /* linux 64 bits */
19#define SSIZE_MIN LONG_MIN
20#define SSIZE_MAX LONG_MAX
21#elif SIZE_MAX == ULLONG_MAX
22typedef long long ssize_t; /* windows 64 bits */
23#define SSIZE_MIN LLONG_MIN
24#define SSIZE_MAX LLONG_MAX
25#elif SIZE_MAX == USHRT_MAX
26typedef short ssize_t; /* is this even possible? */
27#define SSIZE_MIN SHRT_MIN
28#define SSIZE_MAX SHRT_MAX
29#elif SIZE_MAX == UINTMAX_MAX
30typedef intmax_t ssize_t; /* last resort, chux suggestion */
31#define SSIZE_MIN INTMAX_MIN
32#define SSIZE_MAX INTMAX_MAX
33#else
34#error platform has exotic SIZE_MAX
35#endif
36#endif
37
11#endif 38#endif