summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2010-05-23 16:35:59 +0000
committerSteven Barth <steven@midlink.org>2010-05-23 16:35:59 +0000
commitad2ff611913f99526ec82780724e7a178330b4ae (patch)
tree63079568de235f454706cc7a9b4655e3d80486fd /libs/nixio
parent3e923e0a23e80695620bc48a0e8aa81b43ca6e18 (diff)
nixio: Add nixio.gettimeofday() per user request
Diffstat (limited to 'libs/nixio')
-rw-r--r--libs/nixio/src/poll.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/nixio/src/poll.c b/libs/nixio/src/poll.c
index 4af32890a..1211bc72a 100644
--- a/libs/nixio/src/poll.c
+++ b/libs/nixio/src/poll.c
@@ -21,6 +21,16 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/time.h>
+
+
+static int nixio_gettimeofday(lua_State *L) {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ nixio__pushnumber(L, tv.tv_sec);
+ nixio__pushnumber(L, tv.tv_usec);
+ return 2;
+}
/**
@@ -188,6 +198,7 @@ static int nixio_poll(lua_State *L) {
/* module table */
static const luaL_reg R[] = {
+ {"gettimeofday", nixio_gettimeofday},
{"nanosleep", nixio_nanosleep},
{"poll", nixio_poll},
{"poll_flags", nixio_poll_flags},