summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-16 00:52:24 +0800
committerruki <[email protected]>2019-08-15 23:14:26 +0800
commit28654b40d2095cb6f5eac816468c235849c1e1fe (patch)
treebf06f9e6d545a2eca4799514f44a928689e56d27 /core/src
parent9efdf1c2d98afdf4febb4d79bf3a0c39aa2e5eed (diff)
update tbox
Diffstat (limited to 'core/src')
-rw-r--r--core/src/tbox/makefile4
m---------core/src/tbox/tbox0
-rw-r--r--core/src/xmake/process/open.c18
-rw-r--r--core/src/xmake/process/openv.c16
-rw-r--r--core/src/xmake/xmake.c17
5 files changed, 20 insertions, 35 deletions
diff --git a/core/src/tbox/makefile b/core/src/tbox/makefile
index b4b00b592..3d798fc5b 100644
--- a/core/src/tbox/makefile
+++ b/core/src/tbox/makefile
@@ -206,7 +206,7 @@ tbox_C_FILES += \
tbox/src/tbox/libm/isqrti \
tbox/src/tbox/libm/idivi8 \
tbox/src/tbox/platform/addrinfo \
- tbox/src/tbox/platform/atomic64 \
+ tbox/src/tbox/platform/impl/atomic64 \
tbox/src/tbox/platform/backtrace \
tbox/src/tbox/platform/cache_time \
tbox/src/tbox/platform/directory \
@@ -226,7 +226,7 @@ tbox_C_FILES += \
tbox/src/tbox/platform/print \
tbox/src/tbox/platform/stdfile \
tbox/src/tbox/platform/process \
- tbox/src/tbox/platform/processor \
+ tbox/src/tbox/platform/cpu \
tbox/src/tbox/platform/sched \
tbox/src/tbox/platform/semaphore \
tbox/src/tbox/platform/socket \
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox
-Subproject 7de15259a21a7656b16396a1b4a96d9983b694c
+Subproject e9f8d3f57d7a710a30c245e31b5c1a523e0a60b
diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c
index 3ade20733..3318f6017 100644
--- a/core/src/xmake/process/open.c
+++ b/core/src/xmake/process/open.c
@@ -34,7 +34,7 @@
* implementation
*/
-// p = process.open(command, outfile, errfile)
+// p = process.open(command, outpath, errpath)
tb_int_t xm_process_open(lua_State* lua)
{
// check
@@ -43,34 +43,34 @@ tb_int_t xm_process_open(lua_State* lua)
// get the command
size_t command_size = 0;
tb_char_t const* command = luaL_checklstring(lua, 1, &command_size);
- tb_char_t const* outfile = lua_tostring(lua, 2);
- tb_char_t const* errfile = lua_tostring(lua, 3);
+ tb_char_t const* outpath = lua_tostring(lua, 2);
+ tb_char_t const* errpath = lua_tostring(lua, 3);
tb_check_return_val(command, 0);
// init attributes
tb_process_attr_t attr = {0};
// redirect stdout?
- if (outfile)
+ if (outpath)
{
// redirect stdout to file
- attr.outfile = outfile;
+ attr.outpath = outpath;
attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
+ attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
// redirect stderr?
- if (errfile)
+ if (errpath)
{
// redirect stderr to file
- attr.errfile = errfile;
+ attr.errpath = errpath;
attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
+ attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
// init process
tb_process_ref_t process = (tb_process_ref_t)tb_process_init_cmd(command, &attr);
if (process) lua_pushlightuserdata(lua, (tb_pointer_t)process);
else lua_pushnil(lua);
-
- // ok
return 1;
}
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c
index d5539512a..92e552783 100644
--- a/core/src/xmake/process/openv.c
+++ b/core/src/xmake/process/openv.c
@@ -34,7 +34,7 @@
* implementation
*/
-// p = process.openv(shellname, argv, outfile, errfile, envs)
+// p = process.openv(shellname, argv, outpath, errpath, envs)
tb_int_t xm_process_openv(lua_State* lua)
{
// check
@@ -51,8 +51,8 @@ tb_int_t xm_process_openv(lua_State* lua)
// get the output and error file
tb_char_t const* shellname = lua_tostring(lua, 1);
- tb_char_t const* outfile = lua_tostring(lua, 3);
- tb_char_t const* errfile = lua_tostring(lua, 4);
+ tb_char_t const* outpath = lua_tostring(lua, 3);
+ tb_char_t const* errpath = lua_tostring(lua, 4);
tb_check_return_val(shellname, 0);
// get environments
@@ -137,19 +137,21 @@ tb_int_t xm_process_openv(lua_State* lua)
if (envn > 0) attr.envp = envs;
// redirect stdout?
- if (outfile)
+ if (outpath)
{
// redirect stdout to file
- attr.outfile = outfile;
+ attr.outpath = outpath;
attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
+ attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
// redirect stderr?
- if (errfile)
+ if (errpath)
{
// redirect stderr to file
- attr.errfile = errfile;
+ attr.errpath = errpath;
attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT;
+ attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH;
}
// init process
diff --git a/core/src/xmake/xmake.c b/core/src/xmake/xmake.c
index c289518a2..db174c1da 100644
--- a/core/src/xmake/xmake.c
+++ b/core/src/xmake/xmake.c
@@ -25,13 +25,6 @@
#include "xmake.h"
/* //////////////////////////////////////////////////////////////////////////////////////
- * globals
- */
-
-// the initial count
-static tb_atomic_t g_init = 0;
-
-/* //////////////////////////////////////////////////////////////////////////////////////
* private implementation
*/
static __tb_inline__ tb_bool_t xm_check_mode(tb_size_t mode)
@@ -92,9 +85,6 @@ static __tb_inline__ tb_bool_t xm_version_check(tb_hize_t build)
*/
tb_bool_t xm_init_(tb_size_t mode, tb_hize_t build)
{
- // is inited?
- if (tb_atomic_fetch_and_inc(&g_init)) return tb_true;
-
// trace
tb_trace_d("init: ..");
@@ -115,13 +105,6 @@ tb_bool_t xm_init_(tb_size_t mode, tb_hize_t build)
}
tb_void_t xm_exit()
{
- // need exit?
- tb_long_t init = 0;
- if ((init = tb_atomic_dec_and_fetch(&g_init)) > 0) return ;
-
- // check
- tb_assert_and_check_return(!init);
-
// exit tbox
tb_exit();
}