diff options
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 |