Skip to content

Commit ab1971f

Browse files
committed
Implemented 64bit version of the trampoline for thread spawning
1 parent 29555af commit ab1971f

File tree

5 files changed

+440
-436
lines changed

5 files changed

+440
-436
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
293293
thread/sem_timedwait.c \
294294
thread/sem_trywait.c \
295295
thread/sem_wait.c \
296-
thread/wasm32/wasi_thread_start.s \
296+
thread/$(TARGET_ARCH)/wasi_thread_start.s \
297297
)
298298
endif
299299

expected/wasm32-wasi/defined-symbols.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ __do_cleanup_pop
5757
__do_cleanup_push
5858
__do_des
5959
__do_orphaned_stdio_locks
60+
__dummy_reference
6061
__duplocale
6162
__eintr_handler_lock
6263
__eintr_valid_flag
@@ -482,6 +483,7 @@ __wasi_thread_parallelism
482483
__wasi_thread_signal
483484
__wasi_thread_sleep
484485
__wasi_thread_spawn
486+
__wasi_thread_start_C
485487
__wasi_tty_get
486488
__wasi_tty_set
487489
__wasi_ws_connect

expected/wasm64-wasi/defined-symbols.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ __do_cleanup_pop
5757
__do_cleanup_push
5858
__do_des
5959
__do_orphaned_stdio_locks
60+
__dummy_reference
6061
__duplocale
6162
__eintr_handler_lock
6263
__eintr_valid_flag
@@ -482,6 +483,7 @@ __wasi_thread_parallelism
482483
__wasi_thread_signal
483484
__wasi_thread_sleep
484485
__wasi_thread_spawn
486+
__wasi_thread_start_C
485487
__wasi_tty_get
486488
__wasi_tty_set
487489
__wasi_ws_connect

libc-bottom-half/headers/public/wasi/api.h

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ _Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
2525
_Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
2626
_Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
2727
_Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
28-
_Static_assert(_Alignof(intptr_t) == 4, "non-wasi data layout");
29-
_Static_assert(_Alignof(uintptr_t) == 4, "non-wasi data layout");
30-
_Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
31-
typedef int32_t __wasi_int_t;
32-
typedef uint32_t __wasi_uint_t;
33-
_Static_assert(_Alignof(__wasi_int_t) == 4, "non-wasi data layout");
34-
_Static_assert(_Alignof(__wasi_uint_t) == 4, "non-wasi data layout");
28+
_Static_assert(_Alignof(intptr_t) == 8, "non-wasi data layout");
29+
_Static_assert(_Alignof(uintptr_t) == 8, "non-wasi data layout");
30+
_Static_assert(_Alignof(void*) == 8, "non-wasi data layout");
31+
typedef int64_t __wasi_int_t;
32+
typedef uint64_t __wasi_uint_t;
33+
_Static_assert(_Alignof(__wasi_int_t) == 8, "non-wasi data layout");
34+
_Static_assert(_Alignof(__wasi_uint_t) == 8, "non-wasi data layout");
3535
#ifdef __cplusplus
3636
extern "C" {
3737
#endif
@@ -43,8 +43,8 @@ extern "C" {
4343
*/
4444
typedef __wasi_uint_t __wasi_pointersize_t;
4545

46-
_Static_assert(sizeof(__wasi_pointersize_t) == 4, "witx calculated size");
47-
_Static_assert(_Alignof(__wasi_pointersize_t) == 4, "witx calculated align");
46+
_Static_assert(sizeof(__wasi_pointersize_t) == 8, "witx calculated size");
47+
_Static_assert(_Alignof(__wasi_pointersize_t) == 8, "witx calculated align");
4848

4949
/**
5050
* Represents a number of items
@@ -990,10 +990,10 @@ typedef struct __wasi_iovec_t {
990990

991991
} __wasi_iovec_t;
992992

993-
_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
994-
_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
993+
_Static_assert(sizeof(__wasi_iovec_t) == 16, "witx calculated size");
994+
_Static_assert(_Alignof(__wasi_iovec_t) == 8, "witx calculated align");
995995
_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
996-
_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
996+
_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 8, "witx calculated offset");
997997

998998
/**
999999
* A region of memory for scatter/gather writes.
@@ -1011,10 +1011,10 @@ typedef struct __wasi_ciovec_t {
10111011

10121012
} __wasi_ciovec_t;
10131013

1014-
_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
1015-
_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
1014+
_Static_assert(sizeof(__wasi_ciovec_t) == 16, "witx calculated size");
1015+
_Static_assert(_Alignof(__wasi_ciovec_t) == 8, "witx calculated align");
10161016
_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
1017-
_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
1017+
_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 8, "witx calculated offset");
10181018

10191019
/**
10201020
* Relative offset within a file.
@@ -3725,38 +3725,38 @@ typedef struct __wasi_thread_state_t {
37253725

37263726
} __wasi_thread_state_t;
37273727

3728-
_Static_assert(sizeof(__wasi_thread_state_t) == 112, "witx calculated size");
3729-
_Static_assert(_Alignof(__wasi_thread_state_t) == 4, "witx calculated align");
3728+
_Static_assert(sizeof(__wasi_thread_state_t) == 200, "witx calculated size");
3729+
_Static_assert(_Alignof(__wasi_thread_state_t) == 8, "witx calculated align");
37303730
_Static_assert(offsetof(__wasi_thread_state_t, thread_self) == 0, "witx calculated offset");
3731-
_Static_assert(offsetof(__wasi_thread_state_t, dtv) == 4, "witx calculated offset");
3732-
_Static_assert(offsetof(__wasi_thread_state_t, thread_prev) == 8, "witx calculated offset");
3733-
_Static_assert(offsetof(__wasi_thread_state_t, thread_next) == 12, "witx calculated offset");
3734-
_Static_assert(offsetof(__wasi_thread_state_t, sysinfo) == 16, "witx calculated offset");
3735-
_Static_assert(offsetof(__wasi_thread_state_t, canary) == 20, "witx calculated offset");
3736-
_Static_assert(offsetof(__wasi_thread_state_t, tid) == 24, "witx calculated offset");
3737-
_Static_assert(offsetof(__wasi_thread_state_t, errno_val) == 28, "witx calculated offset");
3738-
_Static_assert(offsetof(__wasi_thread_state_t, detach_state) == 32, "witx calculated offset");
3739-
_Static_assert(offsetof(__wasi_thread_state_t, cancel) == 36, "witx calculated offset");
3740-
_Static_assert(offsetof(__wasi_thread_state_t, canceldisable) == 40, "witx calculated offset");
3741-
_Static_assert(offsetof(__wasi_thread_state_t, cancelasync) == 41, "witx calculated offset");
3742-
_Static_assert(offsetof(__wasi_thread_state_t, flags) == 42, "witx calculated offset");
3743-
_Static_assert(offsetof(__wasi_thread_state_t, map_base) == 44, "witx calculated offset");
3744-
_Static_assert(offsetof(__wasi_thread_state_t, map_size) == 48, "witx calculated offset");
3745-
_Static_assert(offsetof(__wasi_thread_state_t, stack) == 52, "witx calculated offset");
3746-
_Static_assert(offsetof(__wasi_thread_state_t, stack_size) == 56, "witx calculated offset");
3747-
_Static_assert(offsetof(__wasi_thread_state_t, guard_size) == 60, "witx calculated offset");
3748-
_Static_assert(offsetof(__wasi_thread_state_t, result) == 64, "witx calculated offset");
3749-
_Static_assert(offsetof(__wasi_thread_state_t, cancelbuf) == 68, "witx calculated offset");
3750-
_Static_assert(offsetof(__wasi_thread_state_t, tsd) == 72, "witx calculated offset");
3751-
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_head) == 76, "witx calculated offset");
3752-
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_off) == 80, "witx calculated offset");
3753-
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_pending) == 84, "witx calculated offset");
3754-
_Static_assert(offsetof(__wasi_thread_state_t, h_errno_val) == 88, "witx calculated offset");
3755-
_Static_assert(offsetof(__wasi_thread_state_t, timer_id) == 92, "witx calculated offset");
3756-
_Static_assert(offsetof(__wasi_thread_state_t, locale) == 96, "witx calculated offset");
3757-
_Static_assert(offsetof(__wasi_thread_state_t, killlock) == 100, "witx calculated offset");
3758-
_Static_assert(offsetof(__wasi_thread_state_t, dlerror_buf) == 104, "witx calculated offset");
3759-
_Static_assert(offsetof(__wasi_thread_state_t, stdio_locks) == 108, "witx calculated offset");
3731+
_Static_assert(offsetof(__wasi_thread_state_t, dtv) == 8, "witx calculated offset");
3732+
_Static_assert(offsetof(__wasi_thread_state_t, thread_prev) == 16, "witx calculated offset");
3733+
_Static_assert(offsetof(__wasi_thread_state_t, thread_next) == 24, "witx calculated offset");
3734+
_Static_assert(offsetof(__wasi_thread_state_t, sysinfo) == 32, "witx calculated offset");
3735+
_Static_assert(offsetof(__wasi_thread_state_t, canary) == 40, "witx calculated offset");
3736+
_Static_assert(offsetof(__wasi_thread_state_t, tid) == 48, "witx calculated offset");
3737+
_Static_assert(offsetof(__wasi_thread_state_t, errno_val) == 52, "witx calculated offset");
3738+
_Static_assert(offsetof(__wasi_thread_state_t, detach_state) == 56, "witx calculated offset");
3739+
_Static_assert(offsetof(__wasi_thread_state_t, cancel) == 60, "witx calculated offset");
3740+
_Static_assert(offsetof(__wasi_thread_state_t, canceldisable) == 64, "witx calculated offset");
3741+
_Static_assert(offsetof(__wasi_thread_state_t, cancelasync) == 65, "witx calculated offset");
3742+
_Static_assert(offsetof(__wasi_thread_state_t, flags) == 66, "witx calculated offset");
3743+
_Static_assert(offsetof(__wasi_thread_state_t, map_base) == 72, "witx calculated offset");
3744+
_Static_assert(offsetof(__wasi_thread_state_t, map_size) == 80, "witx calculated offset");
3745+
_Static_assert(offsetof(__wasi_thread_state_t, stack) == 88, "witx calculated offset");
3746+
_Static_assert(offsetof(__wasi_thread_state_t, stack_size) == 96, "witx calculated offset");
3747+
_Static_assert(offsetof(__wasi_thread_state_t, guard_size) == 104, "witx calculated offset");
3748+
_Static_assert(offsetof(__wasi_thread_state_t, result) == 112, "witx calculated offset");
3749+
_Static_assert(offsetof(__wasi_thread_state_t, cancelbuf) == 120, "witx calculated offset");
3750+
_Static_assert(offsetof(__wasi_thread_state_t, tsd) == 128, "witx calculated offset");
3751+
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_head) == 136, "witx calculated offset");
3752+
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_off) == 144, "witx calculated offset");
3753+
_Static_assert(offsetof(__wasi_thread_state_t, robust_list_pending) == 152, "witx calculated offset");
3754+
_Static_assert(offsetof(__wasi_thread_state_t, h_errno_val) == 160, "witx calculated offset");
3755+
_Static_assert(offsetof(__wasi_thread_state_t, timer_id) == 164, "witx calculated offset");
3756+
_Static_assert(offsetof(__wasi_thread_state_t, locale) == 168, "witx calculated offset");
3757+
_Static_assert(offsetof(__wasi_thread_state_t, killlock) == 176, "witx calculated offset");
3758+
_Static_assert(offsetof(__wasi_thread_state_t, dlerror_buf) == 184, "witx calculated offset");
3759+
_Static_assert(offsetof(__wasi_thread_state_t, stdio_locks) == 192, "witx calculated offset");
37603760

37613761
/**
37623762
* thread start type
@@ -3779,14 +3779,14 @@ typedef struct __wasi_thread_start_t {
37793779

37803780
} __wasi_thread_start_t;
37813781

3782-
_Static_assert(sizeof(__wasi_thread_start_t) == 12, "witx calculated size");
3783-
_Static_assert(_Alignof(__wasi_thread_start_t) == 4, "witx calculated align");
3782+
_Static_assert(sizeof(__wasi_thread_start_t) == 24, "witx calculated size");
3783+
_Static_assert(_Alignof(__wasi_thread_start_t) == 8, "witx calculated align");
37843784
_Static_assert(offsetof(__wasi_thread_start_t, start_funct) == 0, "witx calculated offset");
3785-
_Static_assert(offsetof(__wasi_thread_start_t, start_args) == 4, "witx calculated offset");
3786-
_Static_assert(offsetof(__wasi_thread_start_t, thread) == 8, "witx calculated offset");
3785+
_Static_assert(offsetof(__wasi_thread_start_t, start_args) == 8, "witx calculated offset");
3786+
_Static_assert(offsetof(__wasi_thread_start_t, thread) == 16, "witx calculated offset");
37873787

37883788
/**
3789-
* @defgroup wasix_32v1
3789+
* @defgroup wasix_64v1
37903790
* @{
37913791
*/
37923792

0 commit comments

Comments
 (0)