Skip to content

Commit 7cd9ff8

Browse files
committed
Update musl to v1.2.2
1 parent a38a72a commit 7cd9ff8

File tree

889 files changed

+17511
-9812
lines changed

Some content is hidden

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

889 files changed

+17511
-9812
lines changed

src/library_pthread.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ var LibraryPThread = {
364364
} else if (cmd === 'alert') {
365365
alert('Thread ' + d['threadId'] + ': ' + d['text']);
366366
} else if (cmd === 'exit') {
367-
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detached }}}) >> 2);
367+
var detached = worker.pthread && Atomics.load(HEAPU32, (worker.pthread.threadInfoStruct + {{{ C_STRUCTS.pthread.detach_state }}}) >> 2);
368368
if (detached) {
369369
PThread.returnWorkerToPool(worker);
370370
}
@@ -538,9 +538,10 @@ var LibraryPThread = {
538538
var tis = pthread.threadInfoStruct >> 2;
539539
// spawnThread is always called with a zero-initialized thread struct so
540540
// no need to set any valudes to zero here.
541-
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detached }}} >> 2), threadParams.detached);
541+
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.detach_state }}} >> 2), threadParams.detached);
542542
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tsd }}} >> 2), tlsMemory); // Init thread-local-storage memory array.
543543
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.tid }}} >> 2), pthread.threadInfoStruct); // Main thread ID.
544+
544545
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack_size }}} >> 2), threadParams.stackSize);
545546
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.stack }}} >> 2), stackHigh);
546547
Atomics.store(HEAPU32, tis + ({{{ C_STRUCTS.pthread.attr }}} >> 2), threadParams.stackSize);
@@ -863,7 +864,7 @@ var LibraryPThread = {
863864
return ERRNO_CODES.ESRCH;
864865
}
865866

866-
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2);
867+
var detached = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2);
867868
if (detached) {
868869
err('Attempted to join thread ' + thread + ', which was already detached!');
869870
return ERRNO_CODES.EINVAL; // The thread is already detached, can no longer join it!
@@ -880,7 +881,7 @@ var LibraryPThread = {
880881
if (threadStatus == 1) { // Exited?
881882
var threadExitCode = Atomics.load(HEAPU32, (thread + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2);
882883
if (status) {{{ makeSetValue('status', 0, 'threadExitCode', 'i32') }}};
883-
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 1); // Mark the thread as detached.
884+
Atomics.store(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 1); // Mark the thread as detached.
884885

885886
if (!ENVIRONMENT_IS_PTHREAD) cleanupThread(thread);
886887
else postMessage({ 'cmd': 'cleanupThread', 'thread': thread });
@@ -969,7 +970,7 @@ var LibraryPThread = {
969970
// Follow musl convention: detached:0 means not detached, 1 means the thread
970971
// was created as detached, and 2 means that the thread was detached via
971972
// pthread_detach.
972-
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detached }}} ) >> 2, 0, 2);
973+
var wasDetached = Atomics.compareExchange(HEAPU32, (thread + {{{ C_STRUCTS.pthread.detach_state }}} ) >> 2, 0, 2);
973974

974975
return wasDetached ? ERRNO_CODES.EINVAL : 0;
975976
},

src/library_pthread_stub.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var LibraryPThreadStub = {
2323
_pthread_cleanup_push.level = __ATEXIT__.length;
2424
},
2525

26+
pthread_cleanup_pop__deps: ['pthread_cleanup_push'],
2627
pthread_cleanup_pop__sig: 'vi',
2728
pthread_cleanup_pop: function(execute) {
2829
assert(_pthread_cleanup_push.level == __ATEXIT__.length, 'cannot pop if something else added meanwhile!');

src/struct_info.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@
209209
"tv_sec",
210210
"tv_usec"
211211
]
212-
},
213-
"defines": []
212+
}
214213
},
215214
{
216215
"file": "time.h",

src/struct_info_internal.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// libc - internal
44
// ===========================================
55
{
6-
"file": "system/lib/libc/musl/src/internal/pthread_impl.h",
6+
"file": "pthread_impl.h",
77
"structs": {
88
"pthread": [
99
"threadStatus",
1010
"threadExitCode",
1111
"profilerBlock",
1212
"self",
1313
"tsd",
14-
"detached",
14+
"detach_state",
1515
"stack",
1616
"stack_size",
1717
"attr",
@@ -25,7 +25,7 @@
2525
"defines": ["__ATTRP_C11_THREAD"]
2626
},
2727
{
28-
"file": "system/lib/libc/musl/src/internal/libc.h",
28+
"file": "libc.h",
2929
"structs": {
3030
"libc": [
3131
"global_locale"

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

0 commit comments

Comments
 (0)