mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Add *NSYNC to libc/isystem
This commit is contained in:
parent
6f7d0cb1c3
commit
22b63d0b98
32 changed files with 286 additions and 119 deletions
18
Makefile
18
Makefile
|
@ -128,6 +128,7 @@ include libc/mem/mem.mk #─┐
|
|||
include libc/zipos/zipos.mk # ├──DYNAMIC RUNTIME
|
||||
include third_party/gdtoa/gdtoa.mk # │ You can now use stdio
|
||||
include libc/time/time.mk # │ You can finally call malloc()
|
||||
include third_party/nsync/mem/mem.mk # │
|
||||
include libc/thread/thread.mk # │
|
||||
include libc/stdio/stdio.mk # │
|
||||
include third_party/libcxx/libcxx.mk # │
|
||||
|
@ -265,21 +266,23 @@ o/$(MODE)/srcs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS
|
|||
o/$(MODE)/hdrs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(HDRS) $(INCS),$(file >>$@,$(x)))
|
||||
|
||||
TAGS: .UNSANDBOXED = 1
|
||||
TAGS: private .UNSANDBOXED = 1
|
||||
TAGS: o/$(MODE)/srcs-old.txt $(SRCS)
|
||||
@$(RM) $@
|
||||
@$(TAGS) $(TAGSFLAGS) -L $< -o $@
|
||||
|
||||
HTAGS: .UNSANDBOXED = 1
|
||||
HTAGS: private .UNSANDBOXED = 1
|
||||
HTAGS: o/$(MODE)/hdrs-old.txt $(HDRS)
|
||||
@$(RM) $@
|
||||
@build/htags -L $< -o $@
|
||||
|
||||
loc: .UNSANDBOXED = 1
|
||||
loc: private .UNSANDBOXED = 1
|
||||
loc: o/$(MODE)/tool/build/summy.com
|
||||
find -name \*.h -or -name \*.c -or -name \*.S | \
|
||||
$(XARGS) wc -l | grep total | awk '{print $$1}' | $<
|
||||
|
||||
# PLEASE: MAINTAIN TOPOLOGICAL ORDER
|
||||
# FROM HIGHEST LEVEL TO LOWEST LEVEL
|
||||
COSMOPOLITAN_OBJECTS = \
|
||||
NET_HTTP \
|
||||
LIBC_DNS \
|
||||
|
@ -297,6 +300,8 @@ COSMOPOLITAN_OBJECTS = \
|
|||
LIBC_STDIO \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
LIBC_THREAD \
|
||||
THIRD_PARTY_NSYNC_MALLOC \
|
||||
LIBC_MEM \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
LIBC_RUNTIME \
|
||||
|
@ -304,6 +309,7 @@ COSMOPOLITAN_OBJECTS = \
|
|||
LIBC_ELF \
|
||||
LIBC_CALLS \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_VGA \
|
||||
LIBC_NT_PSAPI \
|
||||
LIBC_NT_POWRPROF \
|
||||
LIBC_NT_PDH \
|
||||
|
@ -315,15 +321,13 @@ COSMOPOLITAN_OBJECTS = \
|
|||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_FMT \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
LIBC_THREAD \
|
||||
LIBC_TINYMATH \
|
||||
THIRD_PARTY_XED \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_VGA
|
||||
LIBC_NEXGEN32E
|
||||
|
||||
COSMOPOLITAN_HEADERS = \
|
||||
APE \
|
||||
|
@ -370,7 +374,7 @@ o/cosmopolitan.h: \
|
|||
$(file >$(TMPDIR)/$(subst /,_,$@),libc/integral/normalize.inc $(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS)))
|
||||
@$(COMPILE) -AROLLUP -T$@ o/$(MODE)/tool/build/rollup.com @$(TMPDIR)/$(subst /,_,$@) >$@
|
||||
|
||||
o/cosmopolitan.html: .UNSANDBOXED = 1
|
||||
o/cosmopolitan.html: private .UNSANDBOXED = 1
|
||||
o/cosmopolitan.html: \
|
||||
o/$(MODE)/third_party/chibicc/chibicc.com.dbg \
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))) \
|
||||
|
|
|
@ -163,15 +163,15 @@ o/$(MODE)%/.zip.o: %
|
|||
# and it would be too costly in terms of make latency to have every
|
||||
# header file depend on $(HDRS) and $(INCS).
|
||||
|
||||
o/%.h.ok: .UNSANDBOXED = 1
|
||||
o/%.h.ok: private .UNSANDBOXED = 1
|
||||
o/%.h.ok: %.h
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
|
||||
o/$(MODE)/%.h.ok: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.h.ok: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.h.ok: %.h
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
|
||||
o/$(MODE)/%.hh.ok: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.hh.ok: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.hh.ok: %.hh
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
|
||||
|
||||
|
@ -179,7 +179,7 @@ o/%.okk: .UNSANDBOXED = 1
|
|||
o/%.okk: %
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
|
||||
|
||||
o/$(MODE)/%.okk: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.okk: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%.okk: %
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
|
||||
|
||||
|
@ -207,19 +207,19 @@ MAKE_SYMTAB_ZIP = \
|
|||
################################################################################
|
||||
# EMACS ASSEMBLY GENERATION
|
||||
|
||||
o/$(MODE)/%-gcc.asm: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-gcc.asm: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-gcc.asm: %.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/%-gcc.asm: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-gcc.asm: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-gcc.asm: %.cc
|
||||
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.cxx) -S -g0 $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/%-clang.asm: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-clang.asm: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-clang.asm: %.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/%-clang.asm: CC = $(CLANG)
|
||||
o/$(MODE)/%-clang.asm: .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-clang.asm: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/%-clang.asm: %.cc
|
||||
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.cxx) -S -g0 $(OUTPUT_OPTION) $<
|
||||
|
|
|
@ -81,6 +81,7 @@ EXAMPLES_DIRECTDEPS = \
|
|||
THIRD_PARTY_MBEDTLS \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_NSYNC \
|
||||
THIRD_PARTY_NSYNC_MEM \
|
||||
THIRD_PARTY_QUICKJS \
|
||||
THIRD_PARTY_STB \
|
||||
THIRD_PARTY_XED \
|
||||
|
|
11
libc/isystem/nsync.h
Normal file
11
libc/isystem/nsync.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_H_
|
||||
#include "third_party/nsync/counter.h"
|
||||
#include "third_party/nsync/cv.h"
|
||||
#include "third_party/nsync/debug.h"
|
||||
#include "third_party/nsync/mu.h"
|
||||
#include "third_party/nsync/mu_wait.h"
|
||||
#include "third_party/nsync/note.h"
|
||||
#include "third_party/nsync/once.h"
|
||||
#include "third_party/nsync/waiter.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_H_ */
|
4
libc/isystem/nsync_atomic.h
Normal file
4
libc/isystem/nsync_atomic.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ATOMIC_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ATOMIC_H_
|
||||
#include "third_party/nsync/atomic.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ATOMIC_H_ */
|
4
libc/isystem/nsync_counter.h
Normal file
4
libc/isystem/nsync_counter.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_COUNTER_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_COUNTER_H_
|
||||
#include "third_party/nsync/counter.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_COUNTER_H_ */
|
4
libc/isystem/nsync_cv.h
Normal file
4
libc/isystem/nsync_cv.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_CV_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_CV_H_
|
||||
#include "third_party/nsync/cv.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_CV_H_ */
|
4
libc/isystem/nsync_debug.h
Normal file
4
libc/isystem/nsync_debug.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_DEBUG_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_DEBUG_H_
|
||||
#include "third_party/nsync/debug.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_DEBUG_H_ */
|
4
libc/isystem/nsync_mu.h
Normal file
4
libc/isystem/nsync_mu.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_H_
|
||||
#include "third_party/nsync/mu.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_H_ */
|
4
libc/isystem/nsync_mu_wait.h
Normal file
4
libc/isystem/nsync_mu_wait.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_WAIT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_WAIT_H_
|
||||
#include "third_party/nsync/mu_wait.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_MU_WAIT_H_ */
|
4
libc/isystem/nsync_note.h
Normal file
4
libc/isystem/nsync_note.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_NOTE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_NOTE_H_
|
||||
#include "third_party/nsync/note.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_NOTE_H_ */
|
4
libc/isystem/nsync_once.h
Normal file
4
libc/isystem/nsync_once.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ONCE_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ONCE_H_
|
||||
#include "third_party/nsync/once.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_ONCE_H_ */
|
4
libc/isystem/nsync_time.h
Normal file
4
libc/isystem/nsync_time.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_TIME_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_TIME_H_
|
||||
#include "third_party/nsync/time.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_TIME_H_ */
|
4
libc/isystem/nsync_waiter.h
Normal file
4
libc/isystem/nsync_waiter.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_WAITER_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_WAITER_H_
|
||||
#include "third_party/nsync/waiter.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NSYNC_WAITER_H_ */
|
|
@ -34,7 +34,8 @@ LIBC_THREAD_A_DIRECTDEPS = \
|
|||
LIBC_SYSV \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_NEXGEN32E \
|
||||
THIRD_PARTY_NSYNC
|
||||
THIRD_PARTY_NSYNC \
|
||||
THIRD_PARTY_NSYNC_MEM
|
||||
|
||||
LIBC_THREAD_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(LIBC_THREAD_A_DIRECTDEPS),$($(x))))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
o/$(MODE)/test/libc/release/cosmopolitan.zip: .UNSANDBOXED = 1
|
||||
o/$(MODE)/test/libc/release/cosmopolitan.zip: private .UNSANDBOXED = 1
|
||||
o/$(MODE)/test/libc/release/cosmopolitan.zip: \
|
||||
o/cosmopolitan.h \
|
||||
o/$(MODE)/ape/public/ape.lds \
|
||||
|
|
|
@ -35,7 +35,8 @@ TEST_LIBC_THREAD_DIRECTDEPS = \
|
|||
LIBC_THREAD \
|
||||
LIBC_TIME \
|
||||
LIBC_TESTLIB \
|
||||
THIRD_PARTY_NSYNC
|
||||
THIRD_PARTY_NSYNC \
|
||||
THIRD_PARTY_NSYNC_MEM
|
||||
|
||||
TEST_LIBC_THREAD_DEPS := \
|
||||
$(call uniq,$(foreach x,$(TEST_LIBC_THREAD_DIRECTDEPS),$($(x))))
|
||||
|
|
9
third_party/nsync/README.md
vendored
9
third_party/nsync/README.md
vendored
|
@ -1,7 +1,12 @@
|
|||
# *NSYNC
|
||||
|
||||
The `THIRD_PARTY_NSYNC` and `LIBC_THREAD` packages include source code
|
||||
from *NSYNC. Here's the latest upstream synchronization point:
|
||||
*NSYNC is a library providing scalable synchronization primitives. The
|
||||
following packages are provided:
|
||||
|
||||
- `THIRD_PARTY_NSYNC` has `nsync_mu` which doesn't depend on malloc().
|
||||
- `THIRD_PARTY_NSYNC_MEM` has the rest of *NSYNC, e.g. `nsync_cv`.
|
||||
|
||||
The origin of this code is here:
|
||||
|
||||
git@github.com:google/nsync
|
||||
ac5489682760393fe21bd2a8e038b528442412a7 (1.25.0)
|
||||
|
|
43
third_party/nsync/compat.S
vendored
Normal file
43
third_party/nsync/compat.S
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
nsync_time_now:
|
||||
jmp _timespec_real
|
||||
.endfn nsync_time_now,globl
|
||||
|
||||
nsync_time_add:
|
||||
jmp _timespec_add
|
||||
.endfn nsync_time_add,globl
|
||||
|
||||
nsync_time_sub:
|
||||
jmp _timespec_sub
|
||||
.endfn nsync_time_sub,globl
|
||||
|
||||
nsync_time_cmp:
|
||||
jmp _timespec_cmp
|
||||
.endfn nsync_time_cmp,globl
|
||||
|
||||
nsync_time_ms:
|
||||
jmp _timespec_frommillis
|
||||
.endfn nsync_time_ms,globl
|
||||
|
||||
nsync_time_us:
|
||||
jmp _timespec_frommicros
|
||||
.endfn nsync_time_us,globl
|
44
third_party/nsync/futex.c
vendored
44
third_party/nsync/futex.c
vendored
|
@ -16,11 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/calls/struct/timespec.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/sysv/consts/futex.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "third_party/nsync/common.internal.h"
|
||||
|
@ -34,30 +34,15 @@
|
|||
int _futex (int *, int, int, const struct timespec *, int *, int);
|
||||
|
||||
static int FUTEX_WAIT_;
|
||||
static int FUTEX_WAKE_;
|
||||
static int FUTEX_PRIVATE_FLAG_;
|
||||
static bool FUTEX_IS_SUPPORTED;
|
||||
bool FUTEX_TIMEOUT_IS_ABSOLUTE;
|
||||
|
||||
__attribute__((__constructor__)) static void sync_futex_init_ (void) {
|
||||
__attribute__((__constructor__)) static void nsync_futex_init_ (void) {
|
||||
int x = 0;
|
||||
|
||||
FUTEX_WAKE_ = FUTEX_WAKE;
|
||||
|
||||
if (IsLinux () &&
|
||||
_futex (&x, FUTEX_WAIT_BITSET, 1, 0, 0,
|
||||
FUTEX_BITSET_MATCH_ANY) == -EAGAIN) {
|
||||
FUTEX_WAIT_ = FUTEX_WAIT_BITSET;
|
||||
FUTEX_TIMEOUT_IS_ABSOLUTE = true;
|
||||
} else {
|
||||
FUTEX_WAIT_ = FUTEX_WAIT;
|
||||
}
|
||||
|
||||
if (IsOpenbsd () ||
|
||||
(IsLinux () &&
|
||||
!_futex (&x, FUTEX_WAKE_PRIVATE, 1, 0, 0, 0))) {
|
||||
FUTEX_PRIVATE_FLAG_ = FUTEX_PRIVATE_FLAG;
|
||||
}
|
||||
if (!(FUTEX_IS_SUPPORTED = IsLinux() || IsOpenbsd()))
|
||||
return;
|
||||
|
||||
// In our testing, we found that the monotonic clock on various
|
||||
// popular systems (such as Linux, and some BSD variants) was no
|
||||
|
@ -72,10 +57,23 @@ __attribute__((__constructor__)) static void sync_futex_init_ (void) {
|
|||
if (IsLinux () &&
|
||||
_futex (&x, FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME,
|
||||
1, 0, 0, FUTEX_BITSET_MATCH_ANY) == -EAGAIN) {
|
||||
FUTEX_WAIT_ |= FUTEX_CLOCK_REALTIME;
|
||||
FUTEX_WAIT_ = FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME;
|
||||
FUTEX_PRIVATE_FLAG_ = FUTEX_PRIVATE_FLAG;
|
||||
FUTEX_TIMEOUT_IS_ABSOLUTE = true;
|
||||
} else if (IsLinux () &&
|
||||
_futex (&x, FUTEX_WAIT_BITSET, 1, 0, 0,
|
||||
FUTEX_BITSET_MATCH_ANY) == -EAGAIN) {
|
||||
FUTEX_WAIT_ = FUTEX_WAIT_BITSET;
|
||||
FUTEX_PRIVATE_FLAG_ = FUTEX_PRIVATE_FLAG;
|
||||
FUTEX_TIMEOUT_IS_ABSOLUTE = true;
|
||||
} else if (IsOpenbsd () ||
|
||||
(IsLinux () &&
|
||||
!_futex (&x, FUTEX_WAKE_PRIVATE, 1, 0, 0, 0))) {
|
||||
FUTEX_WAIT_ = FUTEX_WAIT;
|
||||
FUTEX_PRIVATE_FLAG_ = FUTEX_PRIVATE_FLAG;
|
||||
} else {
|
||||
FUTEX_WAIT_ = FUTEX_WAIT;
|
||||
}
|
||||
|
||||
FUTEX_IS_SUPPORTED = IsLinux() || IsOpenbsd();
|
||||
}
|
||||
|
||||
int nsync_futex_wait_ (int *p, int expect, char pshare, struct timespec *timeout) {
|
||||
|
@ -108,7 +106,7 @@ int nsync_futex_wake_ (int *p, int count, char pshare) {
|
|||
int rc, op;
|
||||
int wake (void *, int, int) asm ("_futex");
|
||||
if (FUTEX_IS_SUPPORTED) {
|
||||
op = FUTEX_WAKE_;
|
||||
op = FUTEX_WAKE;
|
||||
if (pshare == PTHREAD_PROCESS_PRIVATE) {
|
||||
op |= FUTEX_PRIVATE_FLAG_;
|
||||
}
|
||||
|
|
55
third_party/nsync/mem/mem.mk
vendored
Normal file
55
third_party/nsync/mem/mem.mk
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
PKGS += THIRD_PARTY_NSYNC_MEM
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_SRCS = $(THIRD_PARTY_NSYNC_MEM_A_SRCS)
|
||||
THIRD_PARTY_NSYNC_MEM_HDRS = $(THIRD_PARTY_NSYNC_MEM_A_HDRS)
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_ARTIFACTS += THIRD_PARTY_NSYNC_MEM_A
|
||||
THIRD_PARTY_NSYNC_MEM = $(THIRD_PARTY_NSYNC_MEM_A_DEPS) $(THIRD_PARTY_NSYNC_MEM_A)
|
||||
THIRD_PARTY_NSYNC_MEM_A = o/$(MODE)/third_party/nsync/mem/nsync.a
|
||||
THIRD_PARTY_NSYNC_MEM_A_FILES := $(wildcard third_party/nsync/mem/*)
|
||||
THIRD_PARTY_NSYNC_MEM_A_HDRS = $(filter %.h,$(THIRD_PARTY_NSYNC_MEM_A_FILES))
|
||||
THIRD_PARTY_NSYNC_MEM_A_SRCS = $(filter %.c,$(THIRD_PARTY_NSYNC_MEM_A_FILES))
|
||||
THIRD_PARTY_NSYNC_MEM_A_OBJS = $(THIRD_PARTY_NSYNC_MEM_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_A_DIRECTDEPS = \
|
||||
LIBC_CALLS \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_MEM \
|
||||
LIBC_STUBS \
|
||||
LIBC_SYSV \
|
||||
THIRD_PARTY_NSYNC
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(THIRD_PARTY_NSYNC_MEM_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_A_CHECKS = \
|
||||
$(THIRD_PARTY_NSYNC_MEM_A).pkg \
|
||||
$(THIRD_PARTY_NSYNC_MEM_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
$(THIRD_PARTY_NSYNC_MEM_A): \
|
||||
third_party/nsync/mem/ \
|
||||
$(THIRD_PARTY_NSYNC_MEM_A).pkg \
|
||||
$(THIRD_PARTY_NSYNC_MEM_A_OBJS)
|
||||
|
||||
$(THIRD_PARTY_NSYNC_MEM_A).pkg: \
|
||||
$(THIRD_PARTY_NSYNC_MEM_A_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_NSYNC_MEM_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
$(THIRD_PARTY_NSYNC_MEM_A_OBJS): private \
|
||||
OVERRIDE_CCFLAGS += \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
THIRD_PARTY_NSYNC_MEM_LIBS = $(foreach x,$(THIRD_PARTY_NSYNC_MEM_ARTIFACTS),$($(x)))
|
||||
THIRD_PARTY_NSYNC_MEM_SRCS = $(foreach x,$(THIRD_PARTY_NSYNC_MEM_ARTIFACTS),$($(x)_SRCS))
|
||||
THIRD_PARTY_NSYNC_MEM_CHECKS = $(foreach x,$(THIRD_PARTY_NSYNC_MEM_ARTIFACTS),$($(x)_CHECKS))
|
||||
THIRD_PARTY_NSYNC_MEM_OBJS = $(foreach x,$(THIRD_PARTY_NSYNC_MEM_ARTIFACTS),$($(x)_OBJS))
|
||||
$(THIRD_PARTY_NSYNC_MEM_OBJS): third_party/nsync/mem/nsync.mk
|
||||
|
||||
.PHONY: o/$(MODE)/third_party/nsync/mem
|
||||
o/$(MODE)/third_party/nsync/mem: $(THIRD_PARTY_NSYNC_MEM_CHECKS)
|
||||
|
0
third_party/nsync/mem/nsync.mk
vendored
Executable file
0
third_party/nsync/mem/nsync.mk
vendored
Executable file
14
third_party/nsync/nsync.mk
vendored
14
third_party/nsync/nsync.mk
vendored
|
@ -11,10 +11,16 @@ THIRD_PARTY_NSYNC = $(THIRD_PARTY_NSYNC_A_DEPS) $(THIRD_PARTY_NSYNC_A)
|
|||
THIRD_PARTY_NSYNC_A = o/$(MODE)/third_party/nsync/nsync.a
|
||||
THIRD_PARTY_NSYNC_A_FILES := $(wildcard third_party/nsync/*)
|
||||
THIRD_PARTY_NSYNC_A_HDRS = $(filter %.h,$(THIRD_PARTY_NSYNC_A_FILES))
|
||||
THIRD_PARTY_NSYNC_A_SRCS = $(filter %.c,$(THIRD_PARTY_NSYNC_A_FILES))
|
||||
THIRD_PARTY_NSYNC_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_NSYNC_A_FILES))
|
||||
THIRD_PARTY_NSYNC_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_NSYNC_A_FILES))
|
||||
|
||||
THIRD_PARTY_NSYNC_A_SRCS = \
|
||||
$(THIRD_PARTY_NSYNC_A_SRCS_S) \
|
||||
$(THIRD_PARTY_NSYNC_A_SRCS_C)
|
||||
|
||||
THIRD_PARTY_NSYNC_A_OBJS = \
|
||||
$(THIRD_PARTY_NSYNC_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||
$(THIRD_PARTY_NSYNC_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(THIRD_PARTY_NSYNC_A_SRCS_S:%.S=o/$(MODE)/%.o)
|
||||
|
||||
THIRD_PARTY_NSYNC_A_DIRECTDEPS = \
|
||||
LIBC_CALLS \
|
||||
|
@ -54,4 +60,6 @@ THIRD_PARTY_NSYNC_OBJS = $(foreach x,$(THIRD_PARTY_NSYNC_ARTIFACTS),$($(x)_OBJS)
|
|||
$(THIRD_PARTY_NSYNC_OBJS): third_party/nsync/nsync.mk
|
||||
|
||||
.PHONY: o/$(MODE)/third_party/nsync
|
||||
o/$(MODE)/third_party/nsync: $(THIRD_PARTY_NSYNC_CHECKS)
|
||||
o/$(MODE)/third_party/nsync: \
|
||||
o/$(MODE)/third_party/nsync/mem \
|
||||
$(THIRD_PARTY_NSYNC_CHECKS)
|
||||
|
|
Loading…
Reference in a new issue