summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@mailme.dk>2011-02-26 18:57:50 +0100
committerEmil Renner Berthing <esmil@mailme.dk>2011-02-26 19:01:52 +0100
commitf6ce4e89969e0a863bb784a4c96961171d86f156 (patch)
tree6c7fee162081da603292d3c3a8d41bd36f4afbbe
parentcd37f2f5bcb5042c1df54e370b0f335b81c1f73f (diff)
downloadlem-f6ce4e89969e0a863bb784a4c96961171d86f156.tar.gz
lem-f6ce4e89969e0a863bb784a4c96961171d86f156.tar.xz
lem-f6ce4e89969e0a863bb784a4c96961171d86f156.zip
use kqueue on FreeBSD
-rw-r--r--Makefile10
-rw-r--r--config.FreeBSD44
-rw-r--r--config.Linux (renamed from config.in)0
-rw-r--r--lem.c10
4 files changed, 60 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 1625863..6084179 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,12 @@ BINDIR = $(PREFIX)/bin
LIBDIR = $(PREFIX)/lib/lua/$(LUA_VERSION)
INCDIR = $(PREFIX)/include
+OS = $(shell uname)
+
+ifeq ($(OS), Linux)
+DL = -ldl
+endif
+
headers = lem.h config.h macros.h lua/luaconf.h lua/lua.h lua/lauxlib.h libev/ev.h
programs = lem utils.so
scripts = repl.lua lem-repl
@@ -39,7 +45,7 @@ LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \
all: $(programs)
-config.h: config.in
+config.h: config.$(OS)
$Mecho ' SED $@'
$O$(SED) -e 's|@PREFIX@|$(PREFIX)/|' $< > $@
@@ -61,7 +67,7 @@ event.o: event.c config.h
lem: $(CORE_O:%=lua/%) $(LIB_O:%=lua/%) event.o lem.o
$Mecho ' LD $@'
- $O$(CC) -rdynamic -lm -ldl $(LDFLAGS) $^ -o $@
+ $O$(CC) -rdynamic -lm $(DL) $(LDFLAGS) $^ -o $@
utils.so: utils.pic.o
$Mecho ' LD $@'
diff --git a/config.FreeBSD b/config.FreeBSD
new file mode 100644
index 0000000..6ccaf05
--- /dev/null
+++ b/config.FreeBSD
@@ -0,0 +1,44 @@
+/*
+ * This file is part of LEM, a Lua Event Machine.
+ * Copyright 2011 Emil Renner Berthing
+ *
+ * LEM is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * LEM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LEM. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define LUA_USE_LINUX
+#define LUA_ROOT "@PREFIX@"
+
+#define EV_STANDALONE 1
+#define EV_USE_MONOTONIC 1
+#define EV_USE_CLOCK_SYSCALL 0
+#define EV_USE_NANOSLEEP 1
+#define EV_USE_EVENTFD 0
+
+#define EV_USE_SELECT 0
+#define EV_USE_POLL 0
+#define EV_USE_EPOLL 0
+#define EV_USE_KQUEUE 1
+#define EV_USE_PORT 0
+
+#define EV_MULTIPLICITY 0
+
+#define EV_PERIODIC_ENABLE 0
+#define EV_IDLE_ENABLE 1
+#define EV_EMBED_ENABLE 0
+#define EV_STAT_ENABLE 0
+#define EV_FORK_ENABLE 0
+#define EV_ASYNC_ENABLE 0
+
+#define EV_MINPRI 0
+#define EV_MAXPRI 0
diff --git a/config.in b/config.Linux
index eae65f3..eae65f3 100644
--- a/config.in
+++ b/config.Linux
diff --git a/lem.c b/lem.c
index f0af489..43bc97b 100644
--- a/lem.c
+++ b/lem.c
@@ -32,6 +32,12 @@
#include "libev/ev.h"
#include "macros.h"
+#if EV_USE_KQUEUE
+#define LEM_LOOPFLAGS EVBACKEND_KQUEUE
+#else
+#define LEM_LOOPFLAGS 0
+#endif
+
#ifdef NDEBUG
#define lem_log_error(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
@@ -325,10 +331,10 @@ main(int argc, char *argv[])
}
#if EV_MULTIPLICITY
- lem_loop = ev_default_loop(0);
+ lem_loop = ev_default_loop(LEM_LOOPFLAGS);
if (lem_loop == NULL) {
#else
- if (!ev_default_loop(0)) {
+ if (!ev_default_loop(LEM_LOOPFLAGS)) {
#endif
lem_log_error("Error initializing event loop");
return EXIT_FAILURE;