forked from benpop/lua-int64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
int64.h
93 lines (72 loc) · 3.09 KB
/
int64.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef l_int64_h
#define l_int64_h
#include "lua.h"
#include "lauxlib.h"
/* Definition of (u)int64_t { */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <stdint.h>
#elif defined(_MSC_VER)
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif /* } */
int luaopen_int64 (lua_State *L);
/*
** no error => 0
** errcode = type tag + 2
** e.g.:
** LUA_TNONE (-1) => 1
** LUA_TTHREAD (8) => 10
*/
LUALIB_API void luaL_i64pushstrerror (lua_State *L, int errcode);
#define luaL_u64pushstrerror luaL_i64pushstrerror /* XXX? */
LUALIB_API int64_t luaL_toi64be (lua_State *L, int idx, int base,
int *errcode);
LUALIB_API uint64_t luaL_tou64be (lua_State *L, int idx, int base,
int *errcode);
LUALIB_API int64_t luaL_toi64bx (lua_State *L, int idx, int base,
int *isnum);
LUALIB_API uint64_t luaL_tou64bx (lua_State *L, int idx, int base,
int *isnum);
#define luaL_toi64b(L,idx,base) luaL_toi64be(L, (idx), (base), NULL)
#define luaL_tou64b(L,idx,base) luaL_tou64be(L, (idx), (base), NULL)
#define luaL_toi64x(L,idx,isnum) luaL_toi64bx(L, (idx), 0, (isnum))
#define luaL_tou64x(L,idx,isnum) luaL_tou64bx(L, (idx), 0, (isnum))
#define luaL_toi64(L,idx) luaL_toi64be(L, (idx), 0, NULL)
#define luaL_tou64(L,idx) luaL_tou64be(L, (idx), 0, NULL)
LUALIB_API void luaL_i64pushstring (lua_State *L, int64_t n);
LUALIB_API void luaL_u64pushstring (lua_State *L, uint64_t n);
LUALIB_API void luaL_i64pushhex (lua_State *L, int64_t n);
LUALIB_API void luaL_u64pushhex (lua_State *L, uint64_t n);
/*
** {=================================================================
** Test whether types are at least 64 bits wide.
** ==================================================================
*/
LUALIB_API int luaL_integeris64 (lua_State *L);
LUALIB_API int luaL_numberis64 (lua_State *L);
LUALIB_API int luaL_pointeris64 (lua_State *L);
/* }================================================================= */
/*
** {=================================================================
** This is incredibly hacky and may not even work.
** Fit a 64-bit into the bit field of a double, if this Lua
** defined lua_Number as double.
** !! UNDEFINED BEHAVIOR / IMPLEMENTATION-DEFINED / NOT GUARANTEED !!
** ==================================================================
*/
LUALIB_API void luaL_i64pushnumber (lua_State *L, int64_t n);
LUALIB_API void luaL_u64pushnumber (lua_State *L, uint64_t n);
/* }================================================================= */
/*
** {=================================================================
** Throw error if can't fit 64-bit int into light userdatum.
** ==> Throw error on 32-bit systems.
** ==================================================================
*/
LUALIB_API void luaL_i64pushaddress (lua_State *L, int64_t n);
LUALIB_API void luaL_u64pushaddress (lua_State *L, uint64_t n);
/* }================================================================= */
#endif