Skip to content

Commit

Permalink
Move to lua-compat-5.3 instead of compat52.h
Browse files Browse the repository at this point in the history
  • Loading branch information
daurnimator committed Oct 13, 2017
1 parent 621e603 commit ffd47e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 188 deletions.
12 changes: 10 additions & 2 deletions src/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ VENDOR_$(d) = $(or $(CQUEUES_VENDOR),$(shell $(<D)/../mk/changelog author))
VERSION_$(d) = $(or $(CQUEUES_VERSION),$(shell $(<D)/../mk/changelog version))
COMMIT_$(d) = $(shell $(<D)/../mk/changelog commit)

CPPFLAGS_$(d) = $(ALL_CPPFLAGS)
CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DCOMPAT53_PREFIX=cqueues
CFLAGS_$(d) = $(ALL_CFLAGS)
SOFLAGS_$(d) = $(ALL_SOFLAGS)
LDFLAGS_$(d) = $(ALL_LDFLAGS)
Expand Down Expand Up @@ -50,7 +50,7 @@ define BUILD_$(d)
$$(d)/$(1)/cqueues.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d))) $$(d)/lib/libnonlua.a
$$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..))

$$(d)/$(1)/%.o: $$(d)/%.c $$(d)/cqueues.h $$(d)/compat52.h $$(d)/config.h
$$(d)/$(1)/%.o: $$(d)/%.c $$(d)/cqueues.h $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h
$$(MKDIR) -p $$(@D)
$$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$<

Expand All @@ -66,6 +66,14 @@ $$(d)/$(1)/thread.o: $$(d)/lib/llrb.h

$$(d)/$(1)/notify.o: $$(d)/lib/notify.h

ifneq ($(1), 5.3)
$$(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
$$(MKDIR) -p $$(@D)
$$(CC) $$(CFLAGS_$(d)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$(d)) -c -o $$@ $$<

$$(d)/$(1)/cqueues.so: $$(d)/$(1)/compat53.o
endif

.SECONDARY: liblua$(1)-cqueues cqueues$(1) cqueues

liblua$(1)-cqueues cqueues$(1) cqueues: $$(d)/$(1)/cqueues.so
Expand Down
166 changes: 0 additions & 166 deletions src/compat52.h

This file was deleted.

17 changes: 4 additions & 13 deletions src/cqueues.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,7 @@ static int kpoll_wait(struct kpoll *kp, double timeout) {
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#if LUA_VERSION_NUM >= 502

#if LUA_VERSION_NUM >= 503
static int auxlib_tostringk(lua_State *L NOTUSED, int status NOTUSED, lua_KContext ctx NOTUSED) {
#else
static int auxlib_tostringk(lua_State *L NOTUSED) {
#endif
LUA_KFUNCTION(auxlib_tostringk) {
if (luaL_getmetafield(L, 1, "__tostring")) {
lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1));
} else {
Expand All @@ -833,11 +828,7 @@ static int auxlib_tostring(lua_State *L) {
lua_settop(L, 2);
lua_callk(L, 1, 1, 0, &auxlib_tostringk);

#if LUA_VERSION_NUM >= 503
return auxlib_tostringk(L, LUA_OK, 0);
#else
return auxlib_tostringk(L);
#endif
} else {
luaL_tolstring(L, 1, NULL);

Expand Down Expand Up @@ -2199,10 +2190,10 @@ static double cqueue_timeout_(struct cqueue *Q) {
} /* cqueue_timeout_() */


#if LUA_VERSION_NUM <= 502
static int cqueue_step_cont(lua_State *L) {
#if LUA_VERSION_NUM >= 502
LUA_KFUNCTION(cqueue_step_cont) {
#else
static int cqueue_step_cont(lua_State *L, int status NOTUSED, lua_KContext ctx NOTUSED) {
static int cqueue_step_cont(lua_State *L) {
#endif
int nargs = lua_gettop(L);
struct callinfo I = CALLINFO_INITIALIZER;
Expand Down
4 changes: 1 addition & 3 deletions src/cqueues.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
#include <lualib.h>
#include <lauxlib.h>

#if LUA_VERSION_NUM < 502
#include "compat52.h"
#endif
#include "../vendor/compat53/c-api/compat-5.3.h"


/*
Expand Down
4 changes: 0 additions & 4 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,7 @@ static int ct_setfarg(lua_State *L, struct cthread *ct, struct cthread_arg *arg,
T = lua_newthread(L);
luaL_buffinit(T, &B);
lua_pushvalue(L, index);
#if LUA_VERSION_NUM >= 503
lua_dump(L, &dump_add, &B, 0);
#else
lua_dump(L, &dump_add, &B);
#endif
luaL_pushresult(&B);

arg->v.string.iov_base = (char *)luaL_checklstring(T, -1, &arg->v.string.iov_len);
Expand Down

0 comments on commit ffd47e7

Please sign in to comment.