Created
November 20, 2011 23:48
-
-
Save smellman/1381178 to your computer and use it in GitHub Desktop.
LuakitをMacOSXでビルドするためのパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git config.mk config.mk | |
index 8b453ec..d69b687 100644 | |
--- config.mk | |
+++ config.mk | |
@@ -46,7 +46,7 @@ have lua >= 5.1 installed) | |
endif | |
# Packages required to build luakit | |
-PKGS := gtk+-2.0 gthread-2.0 webkit-1.0 javascriptcoregtk-1.0 sqlite3 $(LUA_PKG_NAME) | |
+PKGS := icu-i18n gtk+-2.0 gthread-2.0 webkit-1.0 javascriptcoregtk-1.0 sqlite3 $(LUA_PKG_NAME) | |
# Build luakit with libunqiue bindings (for writing simple single- | |
# instance applications using dbus). | |
@@ -76,7 +76,7 @@ CFLAGS := -std=gnu99 -ggdb -W -Wall -Wextra $(INCS) $(CFLAGS) | |
# Generate linker options | |
LIBS := $(shell pkg-config --libs $(PKGS)) | |
-LDFLAGS := $(LIBS) $(LDFLAGS) -Wl,--export-dynamic | |
+LDFLAGS := $(LIBS) $(LDFLAGS) | |
# Building on OSX | |
# TODO: These lines have never been tested |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git clib/luakit.c clib/luakit.c | |
index d134653..e3ac256 100644 | |
--- clib/luakit.c | |
+++ clib/luakit.c | |
@@ -30,6 +30,11 @@ | |
#include <time.h> | |
#include <webkit/webkit.h> | |
+#ifdef __MACH__ | |
+#include <mach/clock.h> | |
+#include <mach/mach.h> | |
+#endif | |
+ | |
/* setup luakit module signals */ | |
LUA_CLASS_FUNCS(luakit, luakit_class) | |
@@ -410,7 +415,18 @@ static gint | |
luaH_luakit_time(lua_State *L) | |
{ | |
struct timespec ts; | |
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time | |
+ clock_serv_t cclock; | |
+ mach_timespec_t mts; | |
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); | |
+ clock_get_time(cclock, &mts); | |
+ mach_port_deallocate(mach_task_self(), cclock); | |
+ ts.tv_sec = mts.tv_sec; | |
+ ts.tv_nsec = mts.tv_nsec; | |
+ | |
+#else | |
clock_gettime(CLOCK_REALTIME, &ts); | |
+#endif | |
lua_pushnumber(L, ts.tv_sec + (ts.tv_nsec / 1e9)); | |
return 1; | |
} | |
diff --git clib/sqlite3.c clib/sqlite3.c | |
index 712ec44..8ee41aa 100644 | |
--- clib/sqlite3.c | |
+++ clib/sqlite3.c | |
@@ -26,6 +26,11 @@ | |
#include <sqlite3.h> | |
#include <time.h> | |
+#ifdef __MACH__ | |
+#include <mach/clock.h> | |
+#include <mach/mach.h> | |
+#endif | |
+ | |
/** Internal data structure for all Lua \c sqlite3 object instances. */ | |
typedef struct { | |
/** Common \ref lua_object_t header. \see LUA_OBJECT_HEADER */ | |
@@ -266,7 +271,18 @@ luaH_sqlite3_exec(lua_State *L) | |
lua_newtable(L); | |
/* record time taken to exec query & build return table */ | |
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time | |
+ clock_serv_t cclock1; | |
+ mach_timespec_t mts1; | |
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock1); | |
+ clock_get_time(cclock1, &mts1); | |
+ mach_port_deallocate(mach_task_self(), cclock1); | |
+ ts1.tv_sec = mts1.tv_sec; | |
+ ts1.tv_nsec = mts1.tv_nsec; | |
+ | |
+#else | |
clock_gettime(CLOCK_REALTIME, &ts1); | |
+#endif | |
if (sqlite3_exec(sqlite->db, sql, exec_callback, sqlite, &error)) { | |
lua_pushfstring(L, "sqlite3: failed to execute query: %s", error); | |
@@ -275,7 +291,18 @@ luaH_sqlite3_exec(lua_State *L) | |
} | |
/* get end time reference point */ | |
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time | |
+ clock_serv_t cclock2; | |
+ mach_timespec_t mts2; | |
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock2); | |
+ clock_get_time(cclock2, &mts2); | |
+ mach_port_deallocate(mach_task_self(), cclock2); | |
+ ts2.tv_sec = mts2.tv_sec; | |
+ ts2.tv_nsec = mts2.tv_nsec; | |
+ | |
+#else | |
clock_gettime(CLOCK_REALTIME, &ts2); | |
+#endif | |
gdouble td = (ts2.tv_sec + (ts2.tv_nsec/1e9)) | |
- (ts1.tv_sec + (ts1.tv_nsec/1e9)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment