diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2023-11-09 23:03:21 +0100 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2023-11-15 19:17:57 +0100 |
| commit | d45768de3e6f7b28bfecf4d19b192ccac9ce5dc2 (patch) | |
| tree | 2d4f86ec87eb87a77f6663924aaaa9286756ce3e /src/compat.h | |
| parent | d4222ce6da2a2d7179fc79f9d0cc65fd6c09a686 (diff) | |
| download | luasystem-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.h | 27 |
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 @@ | |||
| 8 | void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup); | 8 | void 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 | ||
| 14 | typedef 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 | ||
| 18 | typedef long ssize_t; /* linux 64 bits */ | ||
| 19 | #define SSIZE_MIN LONG_MIN | ||
| 20 | #define SSIZE_MAX LONG_MAX | ||
| 21 | #elif SIZE_MAX == ULLONG_MAX | ||
| 22 | typedef 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 | ||
| 26 | typedef 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 | ||
| 30 | typedef 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 |
