mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
3c61a541bd
This is one of the few POSIX APIs that was missing. It lets you choose a monotonic clock for your condition variables. This might improve perf on some platforms. It might also grant more flexibility with NTP configs. I know Qt is one project that believes it needs this. To introduce this, I needed to change some the *NSYNC APIs, to support passing a clock param. There's also new benchmarks, demonstrating Cosmopolitan's supremacy over many libc implementations when it comes to mutex performance. Cygwin has an alarmingly bad pthread_mutex_t implementation. It is so bad that they would have been significantly better off if they'd used naive spinlocks.
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
#ifndef COSMOPOLITAN_LIBC_THREAD_FREEBSD_INTERNAL_H_
|
|
#define COSMOPOLITAN_LIBC_THREAD_FREEBSD_INTERNAL_H_
|
|
#include "libc/calls/struct/timespec.h"
|
|
#include "libc/errno.h"
|
|
#include "libc/intrin/asmflag.h"
|
|
|
|
/**
|
|
* @fileoverview FreeBSD Threading
|
|
*
|
|
* @note even though FreeBSD uses a 64-bit type for thread IDs the
|
|
* maximum legal range is PID_MAX + 2 (100001) through INT_MAX
|
|
*/
|
|
|
|
#define THR_SUSPENDED 1
|
|
#define THR_SYSTEM_SCOPE 2
|
|
|
|
#define UMTX_OP_WAIT 2
|
|
#define UMTX_OP_WAIT_UINT 11
|
|
#define UMTX_OP_WAIT_UINT_PRIVATE 15
|
|
#define UMTX_OP_WAKE 3
|
|
#define UMTX_OP_WAKE_PRIVATE 16
|
|
#define UMTX_ABSTIME 1
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct rtprio {
|
|
uint16_t type; /* scheduling class */
|
|
uint16_t prio;
|
|
};
|
|
|
|
struct thr_param {
|
|
void (*start_func)(void *);
|
|
void *arg;
|
|
char *stack_base;
|
|
uint64_t stack_size;
|
|
char *tls_base;
|
|
uint64_t tls_size;
|
|
int64_t *child_tid;
|
|
int64_t *parent_tid;
|
|
int32_t flags;
|
|
struct rtprio *rtp;
|
|
};
|
|
|
|
struct _umtx_time {
|
|
struct timespec _timeout;
|
|
uint32_t _flags;
|
|
uint32_t _clockid;
|
|
};
|
|
|
|
int sys_umtx_timedwait_uint(_Atomic(int) *, int, bool, int,
|
|
const struct timespec *);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_THREAD_FREEBSD_INTERNAL_H_ */
|