Skip to content

Commit

Permalink
feat(sys): add a new method get_nprocs binding get_nprocs
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Jan 6, 2024
1 parent 22515fe commit 936f591
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ static int eco_sys_spawn(lua_State *L)
return 1;
}

static int eco_sys_get_nprocs(lua_State *L)
{
int nprocs = get_nprocs();

lua_pushinteger(L, nprocs);

return 1;
}

static int eco_sys_strerror(lua_State *L)
{
int no = luaL_checkinteger(L, 1);
Expand All @@ -189,6 +198,7 @@ static const luaL_Reg funcs[] = {
{"kill", eco_sys_kill},
{"exec", eco_sys_exec},
{"spawn", eco_sys_spawn},
{"get_nprocs", eco_sys_get_nprocs},
{"strerror", eco_sys_strerror},
{NULL, NULL}
};
Expand Down

0 comments on commit 936f591

Please sign in to comment.