Skip to content

Commit 03b115b

Browse files
committed
Merge branch '5.4'
2 parents 2ae0a68 + 1baeacb commit 03b115b

17 files changed

+513
-28
lines changed

GNUmakefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all: # default target
1212
#
1313
# G N U M A K E F U N C T I O N S
1414
#
15-
KNOWN_APIS = 5.1 5.2 5.3
15+
KNOWN_APIS = 5.1 5.2 5.3 5.4
1616

1717
# template for invoking luapath script
1818
LUAPATH := $(d)/mk/luapath
@@ -40,6 +40,9 @@ lua52cpath ?= $(libdir)/lua/5.2
4040
lua52path ?= $(datadir)/lua/5.2
4141
lua53cpath ?= $(libdir)/lua/5.3
4242
lua53path ?= $(datadir)/lua/5.3
43+
lua54cpath ?= $(libdir)/lua/5.4
44+
lua54path ?= $(datadir)/lua/5.4
45+
4346

4447
AR ?= ar
4548
RANLIB ?= ranlib
@@ -64,7 +67,7 @@ PRINT_$(d) = printf "%s = %s\n" '$(1)' '$(subst ',\\',$(2))' | $(TEE_A) '$(3)'
6467

6568
LAZY_$(d) = \
6669
prefix includedir libdir datadir bindir \
67-
lua51cpath lua51path lua52cpath lua52path lua53cpath lua53path \
70+
lua51cpath lua51path lua52cpath lua52path lua53cpath lua53path lua54cpath lua54path \
6871
CC ALL_CPPFLAGS CPPFLAGS ALL_CFLAGS CFLAGS ALL_LDFLAGS LDFLAGS \
6972
ALL_SOFLAGS SOFLAGS ALL_LIB LIBS \
7073
$(foreach API,$(KNOWN_APIS),ALL_LUA$(subst .,,$(API))_CPPFLAGS) \
@@ -96,7 +99,7 @@ endif
9699

97100
# set LUA_APIS if empty or "?"
98101
ifeq ($(or $(strip $(LUA_APIS)),?),?)
99-
override LUA_APIS := $(call HAVE_API_FN,5.1) $(call HAVE_API_FN,5.2) $(call HAVE_API_FN,5.3)
102+
override LUA_APIS := $(call HAVE_API_FN,5.1) $(call HAVE_API_FN,5.2) $(call HAVE_API_FN,5.3) $(call HAVE_API_FN,5.4)
100103
endif
101104

102105
define LUAXY_template
@@ -131,6 +134,7 @@ endef # LUAXY_template
131134
$(eval $(call LUAXY_template,5.1))
132135
$(eval $(call LUAXY_template,5.2))
133136
$(eval $(call LUAXY_template,5.3))
137+
$(eval $(call LUAXY_template,5.4))
134138

135139
#
136140
# A U T O D E T E C T C O M P I L A T I O N F L A G S

src/GNUmakefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $$(d)/$(1)/%.o: $$(d)/%.c $$(d)/config.h
4040
$$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$<
4141

4242
ifneq ($(1), 5.3)
43+
ifneq ($(1), 5.4)
4344
$$(d)/$(1)/compat53.o: $$(d)/../vendor/compat53/c-api/compat-5.3.c $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h
4445
$$(MKDIR) -p $$(@D)
4546
$$(CC) $$(CFLAGS_$(d)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$(d)) -c -o $$@ $$<
@@ -48,6 +49,7 @@ $$(d)/$(1)/%.o: $$(d)/../vendor/compat53/c-api/compat-5.3.h
4849

4950
$$(d)/$(1)/openssl.so: $$(d)/$(1)/compat53.o
5051
endif
52+
endif
5153

5254
.SECONDARY: liblua$(1)-openssl openssl$(1) openssl
5355

@@ -58,13 +60,15 @@ endef # BUILD_$(d)
5860
$(eval $(call BUILD_$(d),5.1))
5961
$(eval $(call BUILD_$(d),5.2))
6062
$(eval $(call BUILD_$(d),5.3))
63+
$(eval $(call BUILD_$(d),5.4))
6164

6265
ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
63-
.SECONDARY: all all5.1 all5.2 all5.3
66+
.SECONDARY: all all5.1 all5.2 all5.3 all5.4
6467

6568
all5.1: liblua5.1-openssl
6669
all5.2: liblua5.2-openssl
6770
all5.3: liblua5.3-openssl
71+
all5.4: liblua5.4-openssl
6872
all: $(foreach API,$(strip $(LUA_APIS)),all$(API))
6973

7074
endif
@@ -152,21 +156,24 @@ endef # INSTALL_$(d)
152156
$(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path)))
153157
$(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path)))
154158
$(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path)))
159+
$(eval $(call INSTALL_$(d),5.4,$$(lua54cpath),$$(lua54path)))
155160

156161
ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" ""
157162

158-
.SECONDARY: install5.1 install5.2 install5.3 install
163+
.SECONDARY: install5.1 install5.2 install5.3 install5.4 install
159164

160165
install5.1: liblua5.1-openssl-install
161166
install5.2: liblua5.2-openssl-install
162167
install5.3: liblua5.3-openssl-install
168+
install5.4: liblua5.4-openssl-install
163169
install: $(foreach API,$(strip $(LUA_APIS)),install$(API))
164170

165-
.PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall
171+
.PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall5.4 uninstall
166172

167173
uninstall5.1: liblua5.1-openssl-uninstall
168174
uninstall5.2: liblua5.2-openssl-uninstall
169175
uninstall5.3: liblua5.3-openssl-uninstall
176+
uninstall5.4: liblua5.4-openssl-uninstall
170177
uninstall: $(foreach API,$(strip $(LUA_APIS)),uninstall$(API))
171178

172179
endif
@@ -201,14 +208,17 @@ $(d)/help:
201208
@echo " all5.1 - build 5.1/openssl.so"
202209
@echo " all5.2 - build 5.2/openssl.so"
203210
@echo " all5.3 - build 5.3/openssl.so"
211+
@echo " all5.4 - build 5.4/openssl.so"
204212
@echo " install - install all API targets"
205213
@echo " install5.1 - install openssl Lua 5.1 modules"
206214
@echo " install5.2 - install openssl Lua 5.2 modules"
207215
@echo " install5.3 - install openssl Lua 5.3 modules"
216+
@echo " install5.4 - install openssl Lua 5.4 modules"
208217
@echo " uninstall - uninstall all API targets"
209218
@echo "uninstall5.1 - uninstall openssl Lua 5.1 modules"
210219
@echo "uninstall5.2 - uninstall openssl Lua 5.2 modules"
211220
@echo "uninstall5.3 - uninstall openssl Lua 5.3 modules"
221+
@echo "uninstall5.4 - uninstall openssl Lua 5.4 modules"
212222
@echo " clean - rm binary targets, object files, debugging symbols, etc"
213223
@echo " clean~ - clean + rm *~"
214224
@echo " help - echo this help message"
@@ -223,10 +233,13 @@ $(d)/help:
223233
@echo 'lua52cpath - install path for Lua 5.2 C modules ($(value lua52cpath))'
224234
@echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))'
225235
@echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))'
236+
@echo ' lua54path - install path for Lua 5.4 modules ($(value lua54path))'
237+
@echo 'lua54cpath - install path for Lua 5.4 C modules ($(value lua54cpath))'
226238
@echo ""
227239
@echo 'LUA51_CPPFLAGS - cpp flags for Lua 5.1 headers ($(LUA51_CPPFLAGS))'
228240
@echo 'LUA52_CPPFLAGS - cpp flags for Lua 5.2 headers ($(LUA52_CPPFLAGS))'
229241
@echo 'LUA53_CPPFLAGS - cpp flags for Lua 5.3 headers ($(LUA53_CPPFLAGS))'
242+
@echo 'LUA54_CPPFLAGS - cpp flags for Lua 5.4 headers ($(LUA54_CPPFLAGS))'
230243
@echo ""
231244
@echo "(NOTE: all the common GNU-style paths are supported, including"
232245
@echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)"

vendor/compat53/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require("compat53")
3535
a meaningful return value, so the usual idiom of storing the return of
3636
`require` in a local variable makes no sense.
3737

38-
When run under Lua 5.3, this module does nothing.
38+
When run under Lua 5.3+, this module does nothing.
3939

4040
When run under Lua 5.2 or 5.1, it replaces some of your standard
4141
functions and adds new ones to bring your environment closer to that
@@ -125,6 +125,7 @@ For Lua 5.1 additionally:
125125
* `lua_KContext` (see [here][14])
126126
* `lua_KFunction` (see [here][14])
127127
* `lua_dump` (extra `strip` parameter, ignored, see [here][15])
128+
* `lua_getextraspace` (limited compatibilitiy, see [here][24])
128129
* `lua_getfield` (return value)
129130
* `lua_geti` and `lua_seti`
130131
* `lua_getglobal` (return value)
@@ -186,7 +187,6 @@ For Lua 5.1 additionally:
186187
[`lua-compat-5.2`][2] for a detailed list.
187188
* the following C API functions/macros:
188189
* `lua_isyieldable`
189-
* `lua_getextraspace`
190190
* `lua_arith` (new operators missing)
191191
* `lua_push(v)fstring` (new formats missing)
192192
* `lua_upvalueid` (5.1)
@@ -236,4 +236,5 @@ This package contains code written by:
236236
[21]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_checkversion
237237
[22]: https://github.com/keplerproject/lua-compat-5.3/wiki/luaL_Buffer
238238
[23]: https://github.com/keplerproject/lua-compat-5.3/wiki/coroutine.running
239+
[24]: https://github.com/keplerproject/lua-compat-5.3/wiki/lua_getextraspace
239240

vendor/compat53/c-api/compat-5.3.c

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
#endif /* VC++ _fsopen for share-allowed file read */
2929

3030
#ifndef COMPAT53_HAVE_STRERROR_R
31-
# if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || \
32-
(!defined (__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6))
31+
# if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
32+
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) || \
33+
defined(__APPLE__)
3334
# define COMPAT53_HAVE_STRERROR_R 1
3435
# else /* none of the defines matched: define to 0 */
3536
# define COMPAT53_HAVE_STRERROR_R 0
@@ -448,7 +449,9 @@ static const char *compat53_reader (lua_State *L, void *ud, size_t *size) {
448449

449450
COMPAT53_API int lua_load (lua_State *L, lua_Reader reader, void *data, const char *source, const char *mode) {
450451
int status = LUA_OK;
451-
compat53_reader_data compat53_data = { reader, data, 1, 0, 0 };
452+
compat53_reader_data compat53_data = { 0, NULL, 1, 0, 0 };
453+
compat53_data.reader = reader;
454+
compat53_data.ud = data;
452455
compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size));
453456
if (compat53_data.peeked_data && compat53_data.peeked_data_size &&
454457
compat53_data.peeked_data[0] == LUA_SIGNATURE[0]) /* binary file? */
@@ -720,6 +723,63 @@ COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i) {
720723
}
721724

722725

726+
#ifndef LUA_EXTRASPACE
727+
#define LUA_EXTRASPACE (sizeof(void*))
728+
#endif
729+
730+
COMPAT53_API void *lua_getextraspace (lua_State *L) {
731+
int is_main = 0;
732+
void *ptr = NULL;
733+
luaL_checkstack(L, 4, "not enough stack slots available");
734+
lua_pushliteral(L, "__compat53_extraspace");
735+
lua_pushvalue(L, -1);
736+
lua_rawget(L, LUA_REGISTRYINDEX);
737+
if (!lua_istable(L, -1)) {
738+
lua_pop(L, 1);
739+
lua_createtable(L, 0, 2);
740+
lua_createtable(L, 0, 1);
741+
lua_pushliteral(L, "k");
742+
lua_setfield(L, -2, "__mode");
743+
lua_setmetatable(L, -2);
744+
lua_pushvalue(L, -2);
745+
lua_pushvalue(L, -2);
746+
lua_rawset(L, LUA_REGISTRYINDEX);
747+
}
748+
lua_replace(L, -2);
749+
is_main = lua_pushthread(L);
750+
lua_rawget(L, -2);
751+
ptr = lua_touserdata(L, -1);
752+
if (!ptr) {
753+
lua_pop(L, 1);
754+
ptr = lua_newuserdata(L, LUA_EXTRASPACE);
755+
if (is_main) {
756+
memset(ptr, '\0', LUA_EXTRASPACE);
757+
lua_pushthread(L);
758+
lua_pushvalue(L, -2);
759+
lua_rawset(L, -4);
760+
lua_pushboolean(L, 1);
761+
lua_pushvalue(L, -2);
762+
lua_rawset(L, -4);
763+
} else {
764+
void* mptr = NULL;
765+
lua_pushboolean(L, 1);
766+
lua_rawget(L, -3);
767+
mptr = lua_touserdata(L, -1);
768+
if (mptr)
769+
memcpy(ptr, mptr, LUA_EXTRASPACE);
770+
else
771+
memset(ptr, '\0', LUA_EXTRASPACE);
772+
lua_pop(L, 1);
773+
lua_pushthread(L);
774+
lua_pushvalue(L, -2);
775+
lua_rawset(L, -4);
776+
}
777+
}
778+
lua_pop(L, 2);
779+
return ptr;
780+
}
781+
782+
723783
COMPAT53_API int lua_isinteger (lua_State *L, int index) {
724784
if (lua_type(L, index) == LUA_TNUMBER) {
725785
lua_Number n = lua_tonumber(L, index);

vendor/compat53/c-api/compat-5.3.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
293293
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
294294
COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i);
295295

296+
#define lua_getextraspace COMPAT53_CONCAT(COMPAT53_PREFIX, _getextraspace)
297+
COMPAT53_API void *lua_getextraspace (lua_State *L);
298+
296299
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
297300
COMPAT53_API int lua_isinteger (lua_State *L, int index);
298301

@@ -339,7 +342,6 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,
339342

340343
/* XXX not implemented:
341344
* lua_isyieldable
342-
* lua_getextraspace
343345
* lua_arith (new operators)
344346
* lua_pushfstring (new formats)
345347
*/
@@ -397,11 +399,11 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,
397399

398400

399401
/* other Lua versions */
400-
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 503
402+
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504
401403

402-
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)"
404+
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"
403405

404-
#endif /* other Lua versions except 5.1, 5.2, and 5.3 */
406+
#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */
405407

406408

407409

0 commit comments

Comments
 (0)