diff options
| author | ruki <[email protected]> | 2025-04-16 22:35:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 11:35:53 +0800 |
| commit | 8bf1576c641f3b68bb43c50929cdcec8ee73ff86 (patch) | |
| tree | cecd4927e8466e076687f6b23d60f00a06023aae /core/src | |
| parent | d985de5de38fb0d041f8e9182c076575603b5b4f (diff) | |
add native thread stub
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/engine.c | 19 | ||||
| -rw-r--r-- | core/src/xmake/thread/prefix.h | 32 | ||||
| -rw-r--r-- | core/src/xmake/thread/thread_exit.c | 43 | ||||
| -rw-r--r-- | core/src/xmake/thread/thread_init.c | 42 | ||||
| -rw-r--r-- | core/src/xmake/thread/thread_resume.c | 43 | ||||
| -rw-r--r-- | core/src/xmake/thread/thread_suspend.c | 43 | ||||
| -rwxr-xr-x | core/src/xmake/xmake.sh | 1 |
7 files changed, 223 insertions, 0 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 69853c1f9..fa3462c7d 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -329,6 +329,12 @@ tb_int_t xm_utils_bin2c(lua_State* lua); tb_int_t xm_lua_curses_register(lua_State* lua, tb_char_t const* module); #endif +// the thread functions +tb_int_t xm_thread_init(lua_State* lua); +tb_int_t xm_thread_exit(lua_State* lua); +tb_int_t xm_thread_suspend(lua_State* lua); +tb_int_t xm_thread_resume(lua_State* lua); + // open cjson __tb_extern_c_enter__ tb_int_t luaopen_cjson(lua_State *l); @@ -615,6 +621,16 @@ static luaL_Reg const g_utils_functions[] = , { tb_null, tb_null } }; +// the thread functions +static luaL_Reg const g_thread_functions[] = +{ + { "thread_init", xm_thread_init } +, { "thread_exit", xm_thread_exit } +, { "thread_resume", xm_thread_resume } +, { "thread_suspend", xm_thread_suspend } +, { tb_null, tb_null } +}; + // the lua global instance for signal handler static lua_State* g_lua = tb_null; @@ -1405,6 +1421,9 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c // bind utils functions xm_lua_register(engine->lua, "utils", g_utils_functions); + // bind thread functions + xm_lua_register(engine->lua, "thread", g_thread_functions); + #ifdef XM_CONFIG_API_HAVE_CURSES // bind curses xm_lua_curses_register(engine->lua, "curses"); diff --git a/core/src/xmake/thread/prefix.h b/core/src/xmake/thread/prefix.h new file mode 100644 index 000000000..0e503c7de --- /dev/null +++ b/core/src/xmake/thread/prefix.h @@ -0,0 +1,32 @@ +/*!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-present, TBOOX Open Source Group. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef XM_THREAD_PREFIX_H +#define XM_THREAD_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + +#endif + + diff --git a/core/src/xmake/thread/thread_exit.c b/core/src/xmake/thread/thread_exit.c new file mode 100644 index 000000000..c43f2d10e --- /dev/null +++ b/core/src/xmake/thread/thread_exit.c @@ -0,0 +1,43 @@ +/*!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-present, TBOOX Open Source Group. + * + * @author ruki + * @file thread_exit.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "thread" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_thread_exit(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + return 0; +} + diff --git a/core/src/xmake/thread/thread_init.c b/core/src/xmake/thread/thread_init.c new file mode 100644 index 000000000..758380b8a --- /dev/null +++ b/core/src/xmake/thread/thread_init.c @@ -0,0 +1,42 @@ +/*!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-present, TBOOX Open Source Group. + * + * @author ruki + * @file thread_init.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "thread" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_thread_init(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + return 0; +} diff --git a/core/src/xmake/thread/thread_resume.c b/core/src/xmake/thread/thread_resume.c new file mode 100644 index 000000000..3ed446cf7 --- /dev/null +++ b/core/src/xmake/thread/thread_resume.c @@ -0,0 +1,43 @@ +/*!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-present, TBOOX Open Source Group. + * + * @author ruki + * @file thread_resume.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "thread" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_thread_resume(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + return 0; +} + diff --git a/core/src/xmake/thread/thread_suspend.c b/core/src/xmake/thread/thread_suspend.c new file mode 100644 index 000000000..0bfcae3f4 --- /dev/null +++ b/core/src/xmake/thread/thread_suspend.c @@ -0,0 +1,43 @@ +/*!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-present, TBOOX Open Source Group. + * + * @author ruki + * @file thread_suspend.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "thread" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_thread_suspend(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + return 0; +} + diff --git a/core/src/xmake/xmake.sh b/core/src/xmake/xmake.sh index 6c45b6fa0..731d1d783 100755 --- a/core/src/xmake/xmake.sh +++ b/core/src/xmake/xmake.sh @@ -72,6 +72,7 @@ target "xmake" add_files "string/*.c" add_files "tty/*.c" add_files "utils/*.c" + add_files "thread/*.c" if is_plat "mingw"; then add_files "winos/*.c" fi |
