@@ -32,20 +32,18 @@ static int __futex4_cp(volatile void *addr, int op, int val, const struct timesp
32
32
if (r != - ENOSYS ) return r ;
33
33
return __syscall_cp (SYS_futex , addr , op & ~FUTEX_PRIVATE , val , to );
34
34
}
35
+ #endif
35
36
36
37
static volatile int dummy = 0 ;
37
38
weak_alias (dummy , __eintr_valid_flag );
38
- #endif
39
39
40
40
int __timedwait_cp (volatile int * addr , int val ,
41
41
clockid_t clk , const struct timespec * at , int priv )
42
42
{
43
43
int r ;
44
44
struct timespec to , * top = 0 ;
45
45
46
- #ifndef __EMSCRIPTEN__
47
46
if (priv ) priv = FUTEX_PRIVATE ;
48
- #endif
49
47
50
48
if (at ) {
51
49
if (at -> tv_nsec >= 1000000000UL ) return EINVAL ;
@@ -58,9 +56,10 @@ int __timedwait_cp(volatile int *addr, int val,
58
56
if (to .tv_sec < 0 ) return ETIMEDOUT ;
59
57
top = & to ;
60
58
}
59
+
61
60
#ifdef __EMSCRIPTEN__
62
61
pthread_t self = __pthread_self ();
63
- double msecsToSleep = top ? (top -> tv_sec * 1000.0 + top -> tv_nsec / 1000000.0 ) : INFINITY ;
62
+ double msecsToSleep = top ? (top -> tv_sec * 1000 + top -> tv_nsec / 1000000.0 ) : INFINITY ;
64
63
const int is_runtime_thread = emscripten_is_main_runtime_thread ();
65
64
66
65
// Main runtime thread may need to run proxied calls, so sleep in very small slices to be responsive.
@@ -94,13 +93,11 @@ int __timedwait_cp(volatile int *addr, int val,
94
93
r = - __futex4_cp (addr , FUTEX_WAIT |priv , val , top );
95
94
#endif
96
95
if (r != EINTR && r != ETIMEDOUT && r != ECANCELED ) r = 0 ;
97
- #ifndef __EMSCRIPTEN__ // XXX Emscripten revert musl commit a63c0104e496f7ba78b64be3cd299b41e8cd427f
98
96
/* Mitigate bug in old kernels wrongly reporting EINTR for non-
99
97
* interrupting (SA_RESTART) signal handlers. This is only practical
100
98
* when NO interrupting signal handlers have been installed, and
101
99
* works by sigaction tracking whether that's the case. */
102
100
if (r == EINTR && !__eintr_valid_flag ) r = 0 ;
103
- #endif
104
101
105
102
return r ;
106
103
}
0 commit comments