Skip to content

Commit 7b7807e

Browse files
committed
Update musl to v1.2.2
1 parent c516c36 commit 7b7807e

File tree

887 files changed

+17487
-9802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

887 files changed

+17487
-9802
lines changed

src/library_pthread.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ var LibraryPThread = {
366366
} else if (cmd === 'alert') {
367367
alert('Thread ' + d['threadId'] + ': ' + d['text']);
368368
} else if (cmd === 'exit') {
369-
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detached }}}) >> 2);
369+
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detach_state }}}) >> 2);
370370
if (detached) {
371371
PThread.returnWorkerToPool(worker);
372372
}
@@ -554,9 +554,10 @@ var LibraryPThread = {
554554
var tis = pthread.threadInfoStruct >> 2;
555555
// spawnThread is always called with a zero-initialized thread struct so
556556
// no need to set any valudes to zero here.
557-
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detached }}} >> 2), threadParams.detached);
557+
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detach_state }}} >> 2), threadParams.detached);
558558
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tsd }}} >> 2), tlsMemory); // Init thread-local-storage memory array.
559559
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tid }}} >> 2), pthread.threadInfoStruct); // Main thread ID.
560+
560561
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack_size }}} >> 2), threadParams.stackSize);
561562
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack }}} >> 2), stackHigh);
562563
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.attr }}} >> 2), threadParams.stackSize);
@@ -879,7 +880,7 @@ var LibraryPThread = {
879880
return ERRNO_CODES.ESRCH;
880881
}
881882

882-
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2);
883+
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2);
883884
if (detached) {
884885
err('Attempted to join thread ' + thread + ', which was already detached!');
885886
return ERRNO_CODES.EINVAL; // The thread is already detached, can no longer join it!
@@ -896,7 +897,7 @@ var LibraryPThread = {
896897
if (threadStatus == 1) { // Exited?
897898
var threadExitCode = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2);
898899
if (status) {{{ makeSetValue('status', 0, 'threadExitCode', 'i32') }}};
899-
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 1); // Mark the thread as detached.
900+
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 1); // Mark the thread as detached.
900901

901902
if (!ENVIRONMENT_IS_PTHREAD) cleanupThread(thread);
902903
else postMessage({ 'cmd': 'cleanupThread', 'thread': thread });
@@ -985,7 +986,7 @@ var LibraryPThread = {
985986
// Follow musl convention: detached:0 means not detached, 1 means the thread
986987
// was created as detached, and 2 means that the thread was detached via
987988
// pthread_detach.
988-
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 0, 2);
989+
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 0, 2);
989990

990991
return wasDetached ? ERRNO_CODES.EINVAL : 0;
991992
},

src/struct_info_internal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"profilerBlock",
1212
"self",
1313
"tsd",
14-
"detached",
14+
"detach_state",
1515
"stack",
1616
"stack_size",
1717
"attr",

system/include/compat/sys/random.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
// syscall which is unnecessary indirection for us.
1010
int getentropy(void *buffer, size_t length);
1111

12+
#include_next <sys/random.h>
13+
1214
#ifdef __cplusplus
1315
}
1416
#endif

system/lib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ extern struct ps_strings *__ps_strings;
102102
#endif
103103

104104
#if SANITIZER_EMSCRIPTEN
105+
#define weak __attribute__(__weak__)
106+
#define hidden __attribute__((__visibility__("hidden")))
105107
#include <syscall.h>
108+
#undef weak
109+
#undef hidden
106110
#include <emscripten/threading.h>
107111
#include <math.h>
108112
#include <wasi/api.h>

system/lib/dlmalloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,10 @@ extern "C" {
856856
#ifndef USE_DL_PREFIX
857857
// XXX Emscripten XXX
858858
#if defined(__EMSCRIPTEN__)
859+
void* __libc_malloc(size_t) __attribute__((weak, alias("dlmalloc")));
860+
void __libc_free(void*) __attribute__((weak, alias("dlfree")));
861+
void* __libc_calloc(size_t) __attribute__((weak, alias("dlcalloc")));
862+
void* __libc_realloc(void*, size_t) __attribute__((weak, alias("dlrealloc")));
859863
void* malloc(size_t) __attribute__((weak, alias("dlmalloc")));
860864
void free(void*) __attribute__((weak, alias("dlfree")));
861865
void* calloc(size_t, size_t) __attribute__((weak, alias("dlcalloc")));

system/lib/emmalloc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ void *emmalloc_memalign(size_t alignment, size_t size)
772772
return ptr;
773773
}
774774
extern __typeof(emmalloc_memalign) emscripten_builtin_memalign __attribute__((alias("emmalloc_memalign")));
775+
extern __typeof(emmalloc_memalign) __libc_memalign __attribute__((alias("emmalloc_memalign")));
775776

776777
void * EMMALLOC_EXPORT memalign(size_t alignment, size_t size)
777778
{
@@ -790,6 +791,7 @@ void *emmalloc_malloc(size_t size)
790791
return emmalloc_memalign(MALLOC_ALIGNMENT, size);
791792
}
792793
extern __typeof(emmalloc_malloc) emscripten_builtin_malloc __attribute__((alias("emmalloc_malloc")));
794+
extern __typeof(emmalloc_malloc) __libc_malloc __attribute__((alias("emmalloc_malloc")));
793795

794796
void * EMMALLOC_EXPORT malloc(size_t size)
795797
{
@@ -891,6 +893,7 @@ void emmalloc_free(void *ptr)
891893
#endif
892894
}
893895
extern __typeof(emmalloc_free) emscripten_builtin_free __attribute__((alias("emmalloc_free")));
896+
extern __typeof(emmalloc_free) __libc_free __attribute__((alias("emmalloc_free")));
894897

895898
void EMMALLOC_EXPORT free(void *ptr)
896899
{
@@ -1086,6 +1089,7 @@ void *emmalloc_realloc(void *ptr, size_t size)
10861089
{
10871090
return emmalloc_aligned_realloc(ptr, MALLOC_ALIGNMENT, size);
10881091
}
1092+
extern __typeof(emmalloc_realloc) __libc_realloc __attribute__((alias("emmalloc_realloc")));
10891093

10901094
void * EMMALLOC_EXPORT realloc(void *ptr, size_t size)
10911095
{
@@ -1121,6 +1125,7 @@ void *emmalloc_calloc(size_t num, size_t size)
11211125
memset(ptr, 0, bytes);
11221126
return ptr;
11231127
}
1128+
extern __typeof(emmalloc_calloc) __libc_calloc __attribute__((alias("emmalloc_calloc")));
11241129

11251130
void * EMMALLOC_EXPORT calloc(size_t num, size_t size)
11261131
{

system/lib/libc/compat/aligned_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Musl has an aligned_alloc routine, but that builds on top of standard malloc(). We are using dlmalloc, so
44
// can route to its implementation instead.
5-
void * __attribute__((weak)) aligned_alloc(size_t alignment, size_t size)
5+
void * weak aligned_alloc(size_t alignment, size_t size)
66
{
77
void *ptr;
88
if ((alignment % sizeof(void *) != 0) || (size % alignment) != 0)

system/lib/libc/crt1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <stdlib.h>
1313
#include <wasi/api.h>
1414

15-
__attribute__((weak)) void __wasm_call_ctors(void);
15+
__attribute__((__weak__)) void __wasm_call_ctors(void);
1616

1717
int __original_main(void);
1818

system/lib/libc/emscripten_asan_strchrnul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ char *__strchrnul(const char *s, int c)
1212
return (char *) s;
1313
}
1414

15-
extern __typeof(__strchrnul) strchrnul __attribute__((weak, alias("__strchrnul")));
15+
extern __typeof(__strchrnul) strchrnul __attribute__((__weak__, alias("__strchrnul")));

system/lib/libc/emscripten_pthread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#if !__EMSCRIPTEN_PTHREADS__
66
static struct pthread __main_pthread;
7-
pthread_t __pthread_self(void) {
8-
return &__main_pthread;
7+
uintptr_t __get_tp(void) {
8+
return (uintptr_t)&__main_pthread;
99
}
1010

1111
__attribute__((constructor))

0 commit comments

Comments
 (0)