-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathluasocket.patch
More file actions
81 lines (77 loc) · 2.75 KB
/
luasocket.patch
File metadata and controls
81 lines (77 loc) · 2.75 KB
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
--- a/src/socket.lua 2021-02-14 16:11:00.198125139 -0500
+++ b/src/socket.lua 2021-02-14 16:12:20.958616941 -0500
@@ -9,7 +9,13 @@
local base = _G
local string = require("string")
local math = require("math")
-local socket = require("socket.core")
+local lib = 'socket.core'
+if OS == 'macos' then
+ lib = lib .. 'osx'
+elseif OS == 'linux' and io.popen('uname -m'):read() == 'aarch64' then
+ lib = lib .. 'arm'
+end
+local socket = require(lib)
local _M = socket
--- a/src/luasocket.c 2021-02-14 17:09:14.466231703 -0500
+++ b/src/luasocket.c 2021-02-14 17:09:31.922343447 -0500
@@ -64,7 +64,7 @@
* Skip a few arguments
\*-------------------------------------------------------------------------*/
static int global_skip(lua_State *L) {
- int amount = luaL_checkint(L, 1);
+ int amount = luaL_checkinteger(L, 1);
int ret = lua_gettop(L) - amount - 1;
return ret >= 0 ? ret : 0;
}
@@ -124,3 +124,10 @@
for (i = 0; mod[i].name; i++) mod[i].func(L);
return 1;
}
+
+LUASOCKET_API int luaopen_socket_coreosx(lua_State *L) {
+ return luaopen_socket_core(L);
+}
+LUASOCKET_API int luaopen_socket_corearm(lua_State *L) {
+ return luaopen_socket_core(L);
+}
--- a/src/luasocket.h 2022-01-06 14:56:30.000000000 -0500
+++ b/src/luasocket.h 2022-01-06 14:57:15.000000000 -0500
@@ -18,7 +18,11 @@
* This macro prefixes all exported API functions
\*-------------------------------------------------------------------------*/
#ifndef LUASOCKET_API
-#define LUASOCKET_API extern
+#if !_WIN32
+#define LUASOCKET_API __attribute__((visibility("default")))
+#else
+#define LUASOCKET_API __declspec(dllexport)
+#endif
#endif
/*-------------------------------------------------------------------------*\
@@ -25,5 +25,6 @@
* Initializes the library.
\*-------------------------------------------------------------------------*/
LUASOCKET_API int luaopen_socket_core(lua_State *L);
+LUASOCKET_API int luaopen_socket_coreosx(lua_State *L);
#endif /* LUASOCKET_H */
--- a/src/buffer.c 2022-03-02 15:27:17.369303209 -0500
+++ b/src/buffer.c 2022-03-02 15:28:24.992010340 -0500
@@ -107,13 +107,16 @@
* object:receive() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_receive(lua_State *L, p_buffer buf) {
- int err = IO_DONE, top = lua_gettop(L);
+ int err = IO_DONE, top;
luaL_Buffer b;
size_t size;
const char *part = luaL_optlstring(L, 3, "", &size);
#ifdef LUASOCKET_DEBUG
p_timeout tm = timeout_markstart(buf->tm);
#endif
+ /* make sure we don't confuse buffer stuff with arguments */
+ lua_settop(L, 3);
+ top = lua_gettop(L);
/* initialize buffer with optional extra prefix
* (useful for concatenating previous partial results) */
luaL_buffinit(L, &b);