Skip to content

Commit d24d4e3

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

File tree

887 files changed

+17493
-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

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

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)