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

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))

system/lib/libc/musl/COPYRIGHT

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
musl as a whole is licensed under the following standard MIT license:
22

33
----------------------------------------------------------------------
4-
Copyright © 2005-2014 Rich Felker, et al.
4+
Copyright © 2005-2020 Rich Felker, et al.
55

66
Permission is hereby granted, free of charge, to any person obtaining
77
a copy of this software and associated documentation files (the
@@ -25,22 +25,39 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525

2626
Authors/contributors include:
2727

28+
A. Wilcox
29+
Ada Worcester
2830
Alex Dowad
31+
Alex Suykov
2932
Alexander Monakov
33+
Andre McCurdy
34+
Andrew Kelley
3035
Anthony G. Basile
36+
Aric Belsito
3137
Arvid Picciani
38+
Bartosz Brachaczek
39+
Benjamin Peterson
3240
Bobby Bingham
3341
Boris Brezillon
3442
Brent Cook
3543
Chris Spiegel
3644
Clément Vasseur
3745
Daniel Micay
46+
Daniel Sabogal
47+
Daurnimator
48+
David Carlier
49+
David Edelsohn
3850
Denys Vlasenko
51+
Dmitry Ivanov
52+
Dmitry V. Levin
53+
Drew DeVault
3954
Emil Renner Berthing
55+
Fangrui Song
4056
Felix Fietkau
4157
Felix Janda
4258
Gianluca Anzolin
4359
Hauke Mehrtens
60+
He X
4461
Hiltjo Posthuma
4562
Isaac Dunham
4663
Jaydeep Patil
@@ -49,32 +66,47 @@ Jeremy Huntwork
4966
Jo-Philipp Wich
5067
Joakim Sindholt
5168
John Spencer
52-
Josiah Worcester
69+
Julien Ramseier
5370
Justin Cormack
71+
Kaarle Ritvanen
5472
Khem Raj
5573
Kylie McClain
74+
Leah Neukirchen
5675
Luca Barbato
5776
Luka Perkov
5877
M Farkas-Dyck (Strake)
5978
Mahesh Bodapati
79+
Markus Wichmann
80+
Masanori Ogino
81+
Michael Clark
6082
Michael Forney
83+
Mikhail Kremnyov
6184
Natanael Copa
6285
Nicholas J. Kain
6386
orc
6487
Pascal Cuoq
88+
Patrick Oppenlander
6589
Petr Hosek
90+
Petr Skocik
6691
Pierre Carrier
92+
Reini Urban
6793
Rich Felker
6894
Richard Pennington
95+
Ryan Fairfax
96+
Samuel Holland
97+
Segev Finer
6998
Shiz
7099
sin
71100
Solar Designer
72101
Stefan Kristiansson
102+
Stefan O'Rear
73103
Szabolcs Nagy
74104
Timo Teräs
75105
Trutz Behn
76106
Valentin Ochs
107+
Will Dietz
77108
William Haddon
109+
William Pitcock
78110

79111
Portions of this software are derived from third-party works licensed
80112
under terms compatible with the above MIT license:
@@ -90,14 +122,18 @@ Copyright © 1993,2004 Sun Microsystems or
90122
Copyright © 2003-2011 David Schultz or
91123
Copyright © 2003-2009 Steven G. Kargl or
92124
Copyright © 2003-2009 Bruce D. Evans or
93-
Copyright © 2008 Stephen L. Moshier
125+
Copyright © 2008 Stephen L. Moshier or
126+
Copyright © 2017-2018 Arm Limited
94127
and labelled as such in comments in the individual source files. All
95128
have been licensed under extremely permissive terms.
96129

97-
The ARM memcpy code (src/string/arm/memcpy_el.S) is Copyright © 2008
130+
The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
98131
The Android Open Source Project and is licensed under a two-clause BSD
99132
license. It was taken from Bionic libc, used on Android.
100133

134+
The AArch64 memcpy and memset code (src/string/aarch64/*) are
135+
Copyright © 1999-2019, Arm Limited.
136+
101137
The implementation of DES for crypt (src/crypt/crypt_des.c) is
102138
Copyright © 1994 David Burren. It is licensed under a BSD license.
103139

@@ -109,12 +145,6 @@ in jurisdictions that may not recognize the public domain.
109145
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
110146
Valentin Ochs and is licensed under an MIT-style license.
111147

112-
The BSD PRNG implementation (src/prng/random.c) and XSI search API
113-
(src/search/*.c) functions are Copyright © 2011 Szabolcs Nagy and
114-
licensed under following terms: "Permission to use, copy, modify,
115-
and/or distribute this code for any purpose with or without fee is
116-
hereby granted. There is no warranty."
117-
118148
The x86_64 port was written by Nicholas J. Kain and is licensed under
119149
the standard MIT terms.
120150

system/lib/libc/musl/INSTALL

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,38 @@ and ABI combinations:
5555
* Little-endian default; big-endian variants also supported
5656

5757
* MIPS
58-
* ABI is o32
58+
* ABI is o32, fp32/fpxx (except on r6 which is fp64)
5959
* Big-endian default; little-endian variants also supported
6060
* Default ABI variant uses FPU registers; alternate soft-float ABI
6161
that does not use FPU registers or instructions is available
6262
* MIPS2 or later, or kernel emulation of ll/sc (standard in Linux)
6363
is required
64+
* MIPS32r6, an incompatible ISA, is supported as a variant "mipsr6"
6465

6566
* MIPS64
66-
* ABI is n64 (LP64)
67+
* ABI is n64 (LP64) or n32 (ILP32)
6768
* Big-endian default; little-endian variants also supported
6869
* Default ABI variant uses FPU registers; alternate soft-float ABI
6970
that does not use FPU registers or instructions is available
7071

7172
* PowerPC
72-
* Only 32-bit is supported
7373
* Compiler toolchain must provide 64-bit long double, not IBM
7474
double-double or IEEE quad
7575
* For dynamic linking, compiler toolchain must be configured for
7676
"secure PLT" variant
7777

78+
* PowerPC64
79+
* Both little and big endian variants are supported
80+
* Compiler toolchain must provide 64-bit long double, not IBM
81+
double-double or IEEE quad
82+
* Compiler toolchain must use the new (ELFv2) ABI regardless of
83+
whether it is for little or big endian
84+
85+
* S390X (64-bit S390)
86+
7887
* SuperH (SH)
7988
* Standard ELF ABI or FDPIC ABI (shared-text without MMU)
80-
* Little-endian by default; big-engian variant also supported
89+
* Little-endian by default; big-endian variant also supported
8190
* Full FPU ABI or soft-float ABI is supported, but the
8291
single-precision-only FPU ABI is not
8392

@@ -88,6 +97,11 @@ and ABI combinations:
8897

8998
* OpenRISC 1000 (or1k)
9099

100+
* RISC-V 64
101+
* Little endian
102+
* Hard, soft, and hard-single/soft-double floating point ABIs
103+
* Standard ELF; no shared-text NOMMU support
104+
91105

92106

93107
Build and Installation Procedure

0 commit comments

Comments
 (0)