Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/struct_info_generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@
"p_proto": 8
},
"pthread": {
"__size__": 124,
"profilerBlock": 104,
"stack": 48,
"stack_size": 52,
"waiting_async": 120
"__size__": 100,
"profilerBlock": 80,
"stack": 40,
"stack_size": 44,
"waiting_async": 96
},
"pthread_attr_t": {
"__size__": 44,
Expand Down
10 changes: 5 additions & 5 deletions src/struct_info_generated_wasm64.json
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@
"p_proto": 16
},
"pthread": {
"__size__": 216,
"profilerBlock": 184,
"stack": 80,
"stack_size": 88,
"waiting_async": 212
"__size__": 176,
"profilerBlock": 144,
"stack": 64,
"stack_size": 72,
"waiting_async": 172
},
"pthread_attr_t": {
"__size__": 88,
Expand Down
10 changes: 10 additions & 0 deletions system/lib/libc/musl/src/internal/pthread_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ struct pthread {
uintptr_t *dtv;
#endif
struct pthread *prev, *next; /* non-ABI */
#ifndef __EMSCRIPTEN__
uintptr_t sysinfo;
#endif
#ifndef TLS_ABOVE_TP
#ifdef CANARY_PAD
uintptr_t canary_pad;
Expand All @@ -49,10 +51,14 @@ struct pthread {
unsigned char tsd_used:1;
unsigned char dlerror_flag:1;
unsigned char *map_base;
#ifndef __EMSCRIPTEN__
size_t map_size;
#endif
void *stack;
size_t stack_size;
#ifndef __EMSCRIPTEN__
size_t guard_size;
#endif
void *result;
struct __ptcb *cancelbuf;
void **tsd;
Expand All @@ -61,13 +67,17 @@ struct pthread {
long off;
volatile void *volatile pending;
} robust_list;
#ifndef __EMSCRIPTEN__
int h_errno_val;
volatile int timer_id;
#endif
#ifndef __EMSCRIPTEN__
// Emscripten uses C11 _Thread_local instead for locale
locale_t locale;
#endif
#ifndef __EMSCRIPTEN__
volatile int killlock[1];
#endif
char *dlerror_buf;
void *stdio_locks;

Expand Down
8 changes: 8 additions & 0 deletions system/lib/libc/musl/src/network/h_errno.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
#undef h_errno
int h_errno;

#ifdef __EMSCRIPTEN__
static _Thread_local int __h_errno_storage;
#endif

int *__h_errno_location(void)
{
#ifdef __EMSCRIPTEN__
return &__h_errno_storage;
#else
if (!__pthread_self()->stack) return &h_errno;
return &__pthread_self()->h_errno_val;
#endif
}
2 changes: 1 addition & 1 deletion system/lib/libc/musl/src/thread/pthread_getattr_np.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
{
*a = (pthread_attr_t){0};
a->_a_detach = t->detach_state>=DT_DETACHED;
a->_a_guardsize = t->guard_size;
#ifdef __EMSCRIPTEN__
a->_a_stackaddr = (uintptr_t)t->stack;
a->_a_stacksize = t->stack_size;
#else
a->_a_guardsize = t->guard_size;
if (t->stack) {
a->_a_stackaddr = (uintptr_t)t->stack;
a->_a_stacksize = t->stack_size;
Expand Down
1 change: 0 additions & 1 deletion system/lib/pthread/pthread_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ int __pthread_create(pthread_t* restrict res,
offset += sizeof(struct pthread);

new->map_base = block;
new->map_size = size;

// The pthread struct has a field that points to itself - this is used as a
// magic ID to detect whether the pthread_t structure is 'alive'.
Expand Down
1 change: 0 additions & 1 deletion system/lib/pthread/pthread_self_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ static void init_pthread_self(void) {
__main_pthread.tid = getpid();
__main_pthread.stack = &__stack_high;
__main_pthread.stack_size = ((size_t)&__stack_high) - ((size_t)&__stack_low);
__main_pthread.guard_size = __default_guardsize;
}
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors1.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19194,
"a.out.js.gz": 7969,
"a.out.nodebug.wasm": 132638,
"a.out.nodebug.wasm.gz": 49927,
"total": 151832,
"total_gz": 57896,
"a.out.nodebug.wasm": 132618,
"a.out.nodebug.wasm.gz": 49913,
"total": 151812,
"total_gz": 57882,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors2.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19171,
"a.out.js.gz": 7957,
"a.out.nodebug.wasm": 132064,
"a.out.nodebug.wasm.gz": 49586,
"total": 151235,
"total_gz": 57543,
"a.out.nodebug.wasm": 132055,
"a.out.nodebug.wasm.gz": 49582,
"total": 151226,
"total_gz": 57539,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23174,
"a.out.js.gz": 8960,
"a.out.nodebug.wasm": 172516,
"a.out.nodebug.wasm.gz": 57438,
"total": 195690,
"total_gz": 66398,
"a.out.nodebug.wasm": 172498,
"a.out.nodebug.wasm.gz": 57424,
"total": 195672,
"total_gz": 66384,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19026,
"a.out.js.gz": 7904,
"a.out.nodebug.wasm": 147922,
"a.out.nodebug.wasm.gz": 55312,
"total": 166948,
"total_gz": 63216,
"a.out.nodebug.wasm": 147904,
"a.out.nodebug.wasm.gz": 55305,
"total": 166930,
"total_gz": 63209,
"sent": [
"_abort_js",
"_tzset_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm_legacy.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19100,
"a.out.js.gz": 7929,
"a.out.nodebug.wasm": 145729,
"a.out.nodebug.wasm.gz": 54945,
"total": 164829,
"total_gz": 62874,
"a.out.nodebug.wasm": 145711,
"a.out.nodebug.wasm.gz": 54939,
"total": 164811,
"total_gz": 62868,
"sent": [
"_abort_js",
"_tzset_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_lto.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 18563,
"a.out.js.gz": 7666,
"a.out.nodebug.wasm": 101956,
"a.out.nodebug.wasm.gz": 39461,
"total": 120519,
"total_gz": 47127,
"a.out.nodebug.wasm": 101945,
"a.out.nodebug.wasm.gz": 39456,
"total": 120508,
"total_gz": 47122,
"sent": [
"a (emscripten_resize_heap)",
"b (_setitimer_js)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_mangle.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23224,
"a.out.js.gz": 8983,
"a.out.nodebug.wasm": 238957,
"a.out.nodebug.wasm.gz": 79847,
"total": 262181,
"total_gz": 88830,
"a.out.nodebug.wasm": 238939,
"a.out.nodebug.wasm.gz": 79836,
"total": 262163,
"total_gz": 88819,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_noexcept.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19194,
"a.out.js.gz": 7969,
"a.out.nodebug.wasm": 134661,
"a.out.nodebug.wasm.gz": 50777,
"total": 153855,
"total_gz": 58746,
"a.out.nodebug.wasm": 134642,
"a.out.nodebug.wasm.gz": 50759,
"total": 153836,
"total_gz": 58728,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_wasmfs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 7023,
"a.out.js.gz": 3310,
"a.out.nodebug.wasm": 172714,
"a.out.nodebug.wasm.gz": 63316,
"total": 179737,
"total_gz": 66626,
"a.out.nodebug.wasm": 172696,
"a.out.nodebug.wasm.gz": 63298,
"total": 179719,
"total_gz": 66608,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26185,
"a.out.js.gz": 11171,
"a.out.nodebug.wasm": 17668,
"a.out.nodebug.wasm.gz": 8921,
"total": 43853,
"total_gz": 20092,
"a.out.nodebug.wasm": 17652,
"a.out.nodebug.wasm.gz": 8911,
"total": 43837,
"total_gz": 20082,
"sent": [
"__syscall_stat64",
"emscripten_resize_heap",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 244300,
"a.out.nodebug.wasm": 577506,
"total": 821806,
"a.out.nodebug.wasm": 577410,
"total": 821710,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_codesize_minimal_pthreads.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 7363,
"a.out.js.gz": 3604,
"a.out.nodebug.wasm": 19046,
"a.out.nodebug.wasm.gz": 8822,
"total": 26409,
"total_gz": 12426,
"a.out.js": 7362,
"a.out.js.gz": 3603,
"a.out.nodebug.wasm": 19033,
"a.out.nodebug.wasm.gz": 8807,
"total": 26395,
"total_gz": 12410,
"sent": [
"a (memory)",
"b (exit)",
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_codesize_minimal_pthreads_memgrowth.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 7765,
"a.out.js.gz": 3810,
"a.out.nodebug.wasm": 19047,
"a.out.nodebug.wasm.gz": 8823,
"total": 26812,
"total_gz": 12633,
"a.out.js": 7764,
"a.out.js.gz": 3808,
"a.out.nodebug.wasm": 19034,
"a.out.nodebug.wasm.gz": 8808,
"total": 26798,
"total_gz": 12616,
"sent": [
"a (memory)",
"b (exit)",
Expand Down
Loading