From 8b2e05a681cd2a0de20a13f02d64433990360c4c Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Mon, 6 Dec 2010 16:33:32 +0000 Subject: [PATCH] non glibc need a true tms for times --- lsyncd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lsyncd.c b/lsyncd.c index cffddb8..462e87e 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -130,6 +130,16 @@ sig_handler(int sig) } } +/** + * Non glibc builds need a real tms structure for times() call + */ +#ifdef __GLIBC__ + static struct tms *dummy_tms = NULL; +#else + static struct tms _dummy_tms; + static struct tms *dummy_tms = &_dummy_tms; +#endif + /***************************************************************************** * Logging ****************************************************************************/ @@ -769,7 +779,7 @@ l_now(lua_State *L) clock_t *j = lua_newuserdata(L, sizeof(clock_t)); luaL_getmetatable(L, "Lsyncd.jiffies"); lua_setmetatable(L, -2); - *j = times(NULL); + *j = times(dummy_tms); return 1; } @@ -1476,7 +1486,7 @@ masterloop(lua_State *L) while(true) { bool have_alarm; bool force_alarm; - clock_t now = times(NULL); + clock_t now = times(dummy_tms); clock_t alarm_time; /* queries runner about soonest alarm */