diff options
| author | ruki <[email protected]> | 2020-02-21 22:53:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-21 11:18:31 +0800 |
| commit | 2ce8c14ab4cee3a5673aa24649196cb45dcc0426 (patch) | |
| tree | 295eaa446ccec43eab5e820c4193bfe1cc5d1ee7 /core/src | |
| parent | 868450acbb14b1bf5cd2da7b1b09a195e88a6bd5 (diff) | |
add os.syserror
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/machine.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 1 | ||||
| -rw-r--r-- | core/src/xmake/os/syserror.c | 45 |
3 files changed, 48 insertions, 0 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 9033dc9d1..f8704ff7f 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -82,6 +82,7 @@ tb_int_t xm_os_cpuinfo(lua_State* lua); tb_int_t xm_os_readlink(lua_State* lua); tb_int_t xm_os_filesize(lua_State* lua); tb_int_t xm_os_emptydir(lua_State* lua); +tb_int_t xm_os_syserror(lua_State* lua); tb_int_t xm_os_strerror(lua_State* lua); tb_int_t xm_os_getwinsize(lua_State* lua); #ifndef TB_CONFIG_OS_WINDOWS @@ -230,6 +231,7 @@ static luaL_Reg const g_os_functions[] = , { "readlink", xm_os_readlink } , { "emptydir", xm_os_emptydir } , { "strerror", xm_os_strerror } +, { "syserror", xm_os_syserror } , { "filesize", xm_os_filesize } , { "getwinsize", xm_os_getwinsize} #ifndef TB_CONFIG_OS_WINDOWS diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index aa3a88ff6..caa8f3150 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -39,6 +39,7 @@ xmake_C_FILES += \ os/cpuinfo \ os/readlink \ os/emptydir \ + os/syserror \ os/strerror \ os/filesize \ os/getwinsize \ diff --git a/core/src/xmake/os/syserror.c b/core/src/xmake/os/syserror.c new file mode 100644 index 000000000..9630bd3c8 --- /dev/null +++ b/core/src/xmake/os/syserror.c @@ -0,0 +1,45 @@ +/*!A cross-platform build utility based on Lua + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright (C) 2015-2020, TBOOX Open Source Group. + * + * @author ruki + * @file syserror.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "syserror" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_os_syserror(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // get syserror state + tb_size_t syserror = tb_syserror_state(); + lua_pushinteger(lua, (tb_int_t)syserror); + return 1; +} |
