Skip to content

Commit

Permalink
ruleset: fix clock() replacement
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Nov 9, 2024
1 parent adec24c commit 61eca00
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion libruleset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
_G.printf = printf

-- avoid clock_t wrapping
if neosocksd.clock and neosocksd.clock() then
if neosocksd.clock and neosocksd.clock() ~= -1 then
os.clock = neosocksd.clock
end

Expand Down
13 changes: 0 additions & 13 deletions src/ruleset/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,6 @@ static int api_clock(lua_State *restrict L)
lua_pushnumber(L, t.tv_sec + t.tv_nsec * 1e-9);
return 1;
}

/* neosocksd.time() */
static int api_time(lua_State *restrict L)
{
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t)) {
lua_pushinteger(L, -1);
return 1;
}
lua_pushnumber(L, t.tv_sec + t.tv_nsec * 1e-9);
return 1;
}
#endif /* HAVE_CLOCK_GETTIME */

/* neosocksd.now() */
Expand All @@ -236,7 +224,6 @@ int luaopen_neosocksd(lua_State *restrict L)
{ "now", api_now },
#if HAVE_CLOCK_GETTIME
{ "clock", api_clock },
{ "monotonic", api_time },
#endif
{ "parse_ipv4", api_parse_ipv4 },
{ "parse_ipv6", api_parse_ipv6 },
Expand Down

0 comments on commit 61eca00

Please sign in to comment.