#include#include #include #include #include //微秒 static int getmicrosecond(lua_state *l) { struct timeval tv; gettimeofday(&tv,null); long microsecond = tv.tv_sec*1000000 tv.tv_usec; lua_pushnumber(l, microsecond); return 1; } //毫秒 static int getmillisecond(lua_state *l) { struct timeval tv; gettimeofday(&tv,null); long millisecond = (tv.tv_sec*1000000 tv.tv_usec)/1000; lua_pushnumber(l, millisecond); return 1; } int luaopen_usertime(lua_state *l) { lual_checkversion(l); lual_reg l[] = { {"getmillisecond", getmillisecond}, {"getmicrosecond", getmicrosecond}, { null, null }, }; lual_newlib(l, l); return 1; }
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字

上传中....