@@ -58,41 +58,8 @@ int __timedwait_cp(volatile int *addr, int val,
5858 }
5959
6060#ifdef __EMSCRIPTEN__
61- double msecsToSleep = top ? (top -> tv_sec * 1000 + top -> tv_nsec / 1000000.0 ) : INFINITY ;
62-
63- // cp suffix in the function name means "cancellation point", so this wait can be cancelled
64- // by the user, unless current thread has cancelation disabled (which may be either done
65- // directly, or indirectly, for example in the __timedwait() function).
66- pthread_t self = pthread_self ();
67-
68- if (self -> canceldisable != PTHREAD_CANCEL_DISABLE ) {
69- double max_ms_slice_to_sleep = 100 ;
70- double sleepUntilTime = emscripten_get_now () + msecsToSleep ;
71- do {
72- if (self -> cancel ) {
73- // The thread was canceled by pthread_cancel().
74- // In the case of cancelasync or PTHREAD_CANCEL_ENABLE we can just call
75- // __pthread_testcancel(), which won't return at all.
76- __pthread_testcancel ();
77- // If __pthread_testcancel does return here it means that canceldisable
78- // must be set to PTHREAD_CANCEL_MASKED. In this case we emulate the
79- // behaviour of the futex syscall and return ECANCELLED here.
80- // See pthread_cond_timedwait.c for the only use of this flag.
81- return ECANCELED ;
82- }
83- msecsToSleep = sleepUntilTime - emscripten_get_now ();
84- if (msecsToSleep <= 0 ) {
85- return ETIMEDOUT ;
86- }
87- // Must wait in slices in case this thread is cancelled in between.
88- if (msecsToSleep > max_ms_slice_to_sleep )
89- msecsToSleep = max_ms_slice_to_sleep ;
90- r = - emscripten_futex_wait ((void * )addr , val , msecsToSleep );
91- } while (r == ETIMEDOUT );
92- } else {
93- // Can wait in one go.
94- r = - emscripten_futex_wait ((void * )addr , val , msecsToSleep );
95- }
61+ double msecs_to_sleep = top ? (top -> tv_sec * 1000 + top -> tv_nsec / 1000000.0 ) : INFINITY ;
62+ r = - emscripten_futex_wait ((void * )addr , val , msecs_to_sleep );
9663#else
9764 r = - __futex4_cp (addr , FUTEX_WAIT |priv , val , top );
9865#endif
0 commit comments