mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Add *NSYNC unit test suite
This change also fixes the clock_nanosleep() api and polyfills futexes on Windows, Mac, and NetBSD using exponential backoff.
This commit is contained in:
parent
3421b9a580
commit
9849b4c7ba
51 changed files with 5505 additions and 1060 deletions
|
@ -46,6 +46,7 @@ struct _umtx_time {
|
|||
};
|
||||
|
||||
int sys_umtx_op(void *, int, unsigned long, void *, void *);
|
||||
int sys_umtx_timedwait_uint(int *, int, bool, const struct timespec *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
/**
|
||||
* Destroys pthread attributes.
|
||||
|
|
|
@ -182,6 +182,7 @@ static int FixupCustomStackOnOpenbsd(pthread_attr_t *attr) {
|
|||
* @raise EINVAL if `attr` was supplied and had unnaceptable data
|
||||
* @raise EPERM if scheduling policy was requested and user account
|
||||
* isn't authorized to use it
|
||||
* @returnserrno
|
||||
* @threadsafe
|
||||
*/
|
||||
errno_t pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
*
|
||||
* @return 0 on success, or errno with error
|
||||
* @raise EINVAL if thread is null or already detached
|
||||
* @returnserrno
|
||||
* @threadsafe
|
||||
*/
|
||||
int pthread_detach(pthread_t thread) {
|
||||
struct PosixThread *pt;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*
|
||||
* @return 0 on success, or errno with error
|
||||
* @raise EDEADLK if thread is detached
|
||||
* @returnserrno
|
||||
* @threadsafe
|
||||
*/
|
||||
int pthread_join(pthread_t thread, void **value_ptr) {
|
||||
struct PosixThread *pt;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
|
@ -66,7 +67,7 @@ static void _wait0_futex(const atomic_int *a, int e) {
|
|||
rc = -GetLastError();
|
||||
}
|
||||
} else if (IsFreebsd()) {
|
||||
rc = sys_umtx_op(a, UMTX_OP_WAIT_UINT, 0, 0, 0);
|
||||
rc = sys_umtx_op(a, UMTX_OP_WAIT_UINT, e, 0, 0);
|
||||
} else {
|
||||
rc = _futex(a, op, e, 0);
|
||||
if (IsOpenbsd() && rc > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue