mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-16 15:40:31 +00:00
Introduce clock_nanosleep()
This commit is contained in:
parent
fe3216e961
commit
b75a4654cf
33 changed files with 553 additions and 100 deletions
13
third_party/nsync/common.internal.h
vendored
13
third_party/nsync/common.internal.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef NSYNC_COMMON_H_
|
||||
#define NSYNC_COMMON_H_
|
||||
#include "libc/assert.h"
|
||||
#include "third_party/nsync/atomic.h"
|
||||
#include "third_party/nsync/atomic.internal.h"
|
||||
#include "third_party/nsync/cv.h"
|
||||
|
@ -220,12 +221,12 @@ static const uint32_t NSYNC_WAITER_TAG = 0x726d2ba9;
|
|||
#define WAITER_IN_USE 0x2 /* waiter in use by a thread */
|
||||
|
||||
#define CONTAINER(t_, f_, p_) ((t_ *)(((char *)(p_)) - offsetof(t_, f_)))
|
||||
#define ASSERT(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
*(volatile int *)0 = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef TINY
|
||||
#define ASSERT(x) _unassert(x)
|
||||
#else
|
||||
#define ASSERT(x) _npassert(x)
|
||||
#endif
|
||||
|
||||
/* Return a pointer to the nsync_waiter_s containing nsync_dll_element_ *e. */
|
||||
#define DLL_NSYNC_WAITER(e) \
|
||||
|
|
9
third_party/nsync/mu_semaphore_futex.c
vendored
9
third_party/nsync/mu_semaphore_futex.c
vendored
|
@ -15,6 +15,7 @@
|
|||
│ See the License for the specific language governing permissions and │
|
||||
│ limitations under the License. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
@ -30,13 +31,17 @@ Copyright 2016 Google, Inc.\\n\
|
|||
https://github.com/google/nsync\"");
|
||||
// clang-format off
|
||||
|
||||
#ifdef TINY
|
||||
#define ASSERT(x) _unassert(x)
|
||||
#else
|
||||
#define ASSERT(x) _npassert(x)
|
||||
#endif
|
||||
|
||||
/* Check that atomic operations on nsync_atomic_uint32_ can be applied to int. */
|
||||
static const int assert_int_size = 1 /
|
||||
(sizeof (assert_int_size) == sizeof (uint32_t) &&
|
||||
sizeof (nsync_atomic_uint32_) == sizeof (uint32_t));
|
||||
|
||||
#define ASSERT(x) do { if (!(x)) { *(volatile int *)0 = 0; } } while (0)
|
||||
|
||||
struct futex {
|
||||
int i; /* lo half=count; hi half=waiter count */
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue