openbsd-ports/net/luasocket/patches/patch-src_timeout_c
jolan a67566608a if LUA_NUMBER is int then use msecs, otherwise default to allowing
subsecond timeouts via floating point numbers

ok pedro@
2006-01-21 01:32:40 +00:00

30 lines
685 B
Plaintext

$OpenBSD: patch-src_timeout_c,v 1.1 2006/01/21 01:32:40 jolan Exp $
--- src/timeout.c.orig Thu Nov 24 14:29:38 2005
+++ src/timeout.c Fri Jan 20 04:31:32 2006
@@ -15,6 +15,7 @@
#ifdef _WIN32
#include <windows.h>
#else
+#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#endif
@@ -193,6 +194,9 @@ int timeout_lua_sleep(lua_State *L)
#ifdef _WIN32
Sleep((int)(n*1000));
#else
+#if LUA_NUMBER == int
+ usleep((int)n*1000);
+#else
struct timespec t, r;
t.tv_sec = (int) n;
n -= t.tv_sec;
@@ -202,6 +206,7 @@ int timeout_lua_sleep(lua_State *L)
t.tv_sec = r.tv_sec;
t.tv_nsec = r.tv_nsec;
}
+#endif
#endif
return 0;
}