Skip to content

Commit 4ceac4e

Browse files
authored
Remove support for process-shared pthread_barrier_t (#26863)
Emscripten does not support process-shared primitives. This is a followup to #26743 where I removed the other usages of this attr.
1 parent bd05b48 commit 4ceac4e

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

system/lib/libc/musl/src/thread/pthread_barrier_wait.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#ifdef __EMSCRIPTEN__
2-
#include <math.h>
2+
#include <assert.h> // For INFINITY
3+
#include <math.h> // For INFINITY
34
#endif
45

56
#include "pthread_impl.h"
67

8+
#ifndef __EMSCRIPTEN__
79
static int pshared_barrier_wait(pthread_barrier_t *b)
810
{
911
int limit = (b->_b_limit & INT_MAX) + 1;
@@ -52,6 +54,7 @@ static int pshared_barrier_wait(pthread_barrier_t *b)
5254

5355
return ret;
5456
}
57+
#endif
5558

5659
struct instance
5760
{
@@ -69,8 +72,13 @@ int pthread_barrier_wait(pthread_barrier_t *b)
6972
/* Trivial case: count was set at 1 */
7073
if (!limit) return PTHREAD_BARRIER_SERIAL_THREAD;
7174

75+
#ifdef __EMSCRIPTEN__
76+
/* No support for process-shared barriers under emscripten */
77+
assert(limit >= 0);
78+
#else
7279
/* Process-shared barriers require a separate, inefficient wait */
7380
if (limit < 0) return pshared_barrier_wait(b);
81+
#endif
7482

7583
/* Otherwise we need a lock on the barrier object */
7684
while (a_swap(&b->_b_lock, 1))

system/lib/libc/musl/src/thread/pthread_barrierattr_setpshared.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared)
44
{
55
if (pshared > 1U) return EINVAL;
6+
#ifdef __EMSCRIPTEN__
7+
if (pshared) return ENOTSUP;
8+
#endif
69
a->__attr = pshared ? INT_MIN : 0;
710
return 0;
811
}

test/codesize/test_codesize_hello_dylink_all.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"a.out.js": 244557,
3-
"a.out.nodebug.wasm": 578037,
4-
"total": 822594,
3+
"a.out.nodebug.wasm": 578129,
4+
"total": 822686,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",
@@ -2855,7 +2855,10 @@
28552855
"pthread_barrier_destroy",
28562856
"pthread_barrier_init",
28572857
"pthread_barrier_wait",
2858+
"pthread_barrierattr_destroy",
28582859
"pthread_barrierattr_getpshared",
2860+
"pthread_barrierattr_init",
2861+
"pthread_barrierattr_setpshared",
28592862
"pthread_cancel",
28602863
"pthread_cond_broadcast",
28612864
"pthread_cond_destroy",
@@ -4618,9 +4621,10 @@
46184621
"$pthread_attr_setstack",
46194622
"$pthread_attr_setstacksize",
46204623
"$pthread_barrierattr_getpshared",
4624+
"$pthread_barrierattr_init",
4625+
"$pthread_barrierattr_setpshared",
46214626
"$pthread_condattr_getclock",
46224627
"$pthread_condattr_getpshared",
4623-
"$pthread_condattr_init",
46244628
"$pthread_condattr_setclock",
46254629
"$pthread_condattr_setpshared",
46264630
"$pthread_equal",
@@ -4636,7 +4640,6 @@
46364640
"$pthread_mutexattr_setpshared",
46374641
"$pthread_mutexattr_settype",
46384642
"$pthread_rwlockattr_init",
4639-
"$pthread_rwlockattr_setpshared",
46404643
"$pthread_setspecific",
46414644
"$pthread_sigmask",
46424645
"$pthread_spin_init",

test/test_posixtest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def get_tests():
7171

7272
unsupported = {
7373
'test_pthread_cond_init_4_2': 'PTHREAD_PROCESS_SHARED not supported',
74+
'test_pthread_barrierattr_setpshared_1_1': 'PTHREAD_PROCESS_SHARED not supported',
7475
'test_pthread_condattr_getpshared_1_2': 'PTHREAD_PROCESS_SHARED not supported',
7576
'test_pthread_mutexattr_setpshared_1_1': 'PTHREAD_PROCESS_SHARED not supported',
7677
'test_pthread_rwlockattr_setpshared_1_1': 'PTHREAD_PROCESS_SHARED not supported',

tools/system_libs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,9 @@ def get_files(self):
12631263
'pthread_attr_setscope.c',
12641264
'pthread_attr_setstack.c',
12651265
'pthread_attr_setstacksize.c',
1266+
'pthread_barrierattr_destroy.c',
1267+
'pthread_barrierattr_init.c',
1268+
'pthread_barrierattr_setpshared.c',
12661269
'pthread_condattr_destroy.c',
12671270
'pthread_condattr_init.c',
12681271
'pthread_condattr_setpshared.c',

0 commit comments

Comments
 (0)