Skip to content

Commit

Permalink
fix compile error for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Aug 29, 2023
1 parent a83fd77 commit fd261c9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/tbox/platform/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* includes
*/
#include "file.h"
#include "path.h"
#include "../libc/libc.h"

/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/platform/impl/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#elif defined(TB_CONFIG_POSIX_HAVE_PTHREAD_MUTEX_INIT)
# include <pthread.h>
#else
# include "spinlock.h"
# include "../spinlock.h"
#endif

/* //////////////////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion src/tbox/platform/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tb_pipe_file_ref_t tb_pipe_file_init(tb_char_t const* name, tb_size_t mode, tb_s
tb_trace_noimpl();
return tb_null;
}
tb_bool_t tb_pipe_file_init_pair(tb_pipe_file_ref_t pair[2], tb_size_t buffer_size)
tb_bool_t tb_pipe_file_init_pair(tb_pipe_file_ref_t pair[2], tb_size_t mode[2], tb_size_t buffer_size)
{
tb_trace_noimpl();
return tb_false;
Expand All @@ -70,6 +70,11 @@ tb_long_t tb_pipe_file_wait(tb_pipe_file_ref_t file, tb_size_t events, tb_long_t
tb_trace_noimpl();
return -1;
}
tb_long_t tb_pipe_file_connect(tb_pipe_file_ref_t file)
{
tb_trace_noimpl();
return -1;
}
#endif

tb_bool_t tb_pipe_file_bread(tb_pipe_file_ref_t file, tb_byte_t* data, tb_size_t size)
Expand Down
2 changes: 2 additions & 0 deletions src/tbox/platform/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# include "windows/prefix.h"
#elif defined(TB_CONFIG_POSIX_HAVE_SCHED_YIELD)
# include <sched.h>
#else
# include "time.h"
#endif

/* //////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions src/tbox/platform/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ tb_long_t tb_socket_connect(tb_socket_ref_t sock, tb_ipaddr_ref_t addr)
tb_trace_noimpl();
return -1;
}
tb_size_t tb_socket_bind(tb_socket_ref_t sock, tb_ipaddr_ref_t addr)
tb_bool_t tb_socket_bind(tb_socket_ref_t sock, tb_ipaddr_ref_t addr)
{
tb_trace_noimpl();
return 0;
return tb_false;
}
tb_bool_t tb_socket_listen(tb_socket_ref_t sock, tb_size_t backlog)
{
Expand Down Expand Up @@ -118,17 +118,17 @@ tb_long_t tb_socket_send(tb_socket_ref_t sock, tb_byte_t const* data, tb_size_t
tb_trace_noimpl();
return -1;
}
tb_long_t tb_socket_recvv(tb_handle_t socket, tb_iovec_t const* list, tb_size_t size)
tb_long_t tb_socket_recvv(tb_socket_ref_t sock, tb_iovec_t const* list, tb_size_t size)
{
tb_trace_noimpl();
return -1;
}
tb_long_t tb_socket_sendv(tb_handle_t socket, tb_iovec_t const* list, tb_size_t size)
tb_long_t tb_socket_sendv(tb_socket_ref_t sock, tb_iovec_t const* list, tb_size_t size)
{
tb_trace_noimpl();
return -1;
}
tb_hong_t tb_socket_sendf(tb_handle_t socket, tb_file_ref_t file, tb_hize_t offset, tb_hize_t size)
tb_hong_t tb_socket_sendf(tb_socket_ref_t sock, tb_file_ref_t file, tb_hize_t offset, tb_hize_t size)
{
tb_trace_noimpl();
return -1;
Expand Down
5 changes: 5 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if has_config("coroutine") then
add_cxflags("gcc::-Wno-error=dangling-pointer")
end

if is_plat("wasm") then
add_requires("emscripten")
set_toolchains("emcc@emscripten")
end

-- add build modes
add_rules("mode.release", "mode.debug", "mode.profile", "mode.coverage", "mode.valgrind", "mode.asan", "mode.tsan", "mode.ubsan")
if is_mode("debug") then
Expand Down

0 comments on commit fd261c9

Please sign in to comment.