mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Add more missing libc/libc++ functions
- Add sched_rr_get_interval() - Add `unbuffer` command example - Add more locale function stubs - Vendor most of remaining libcxx content
This commit is contained in:
parent
5a2bb07b36
commit
31e746c937
76 changed files with 15519 additions and 157 deletions
|
@ -176,7 +176,8 @@ DEFAULT_CXXFLAGS = \
|
|||
-fuse-cxa-atexit \
|
||||
-fno-threadsafe-statics \
|
||||
-Wno-int-in-bool-context \
|
||||
-Wno-narrowing
|
||||
-Wno-narrowing \
|
||||
-Wno-literal-suffix
|
||||
|
||||
DEFAULT_ASFLAGS = \
|
||||
-W \
|
||||
|
|
|
@ -109,11 +109,11 @@ o/$(MODE)/%: o/$(MODE)/%.com o/$(MODE)/tool/build/cp.com o/$(MODE)/tool/build/as
|
|||
# TODO(jart): find a way to generate dependencies
|
||||
# or alternatively disable sandboxing
|
||||
o/%.h.ok: %.h
|
||||
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
# @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
# @$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
o/$(MODE)/%.h.ok: %.h
|
||||
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
# @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
# @$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
|
||||
o/$(MODE)/%.hh.ok: %.hh
|
||||
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
# @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
|
||||
# @$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
|
||||
|
|
143
examples/unbuffer.c
Normal file
143
examples/unbuffer.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/termios.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
|
||||
#define STR(s) s, strlen(s)
|
||||
|
||||
struct termios tio;
|
||||
struct winsize wsz;
|
||||
sigset_t chldmask, savemask;
|
||||
struct sigaction ignore, saveint, savequit;
|
||||
char databuf[512];
|
||||
char pathbuf[PATH_MAX];
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
ssize_t rc;
|
||||
const char *prog;
|
||||
size_t i, got, wrote;
|
||||
int ws, mfd, sfd, pid;
|
||||
|
||||
if (argc < 2) {
|
||||
write(2, STR("usage: "));
|
||||
if (argc > 0) write(2, argv[0], strlen(argv[0]));
|
||||
write(2, STR(" prog [argv₁...]\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(prog = commandv(argv[1], pathbuf, sizeof(pathbuf)))) {
|
||||
write(2, STR("error: "));
|
||||
write(2, prog, strlen(prog));
|
||||
write(2, STR(" not found\n"));
|
||||
return 2;
|
||||
}
|
||||
|
||||
bzero(&wsz, sizeof(wsz));
|
||||
wsz.ws_col = 80;
|
||||
wsz.ws_row = 45;
|
||||
|
||||
bzero(&tio, sizeof(tio));
|
||||
tio.c_iflag = ICRNL | IXON | IUTF8;
|
||||
tio.c_oflag = OPOST | ONLCR;
|
||||
tio.c_cflag = CREAD | CS8;
|
||||
tio.c_lflag =
|
||||
ISIG | ICANON | ECHO | ECHOE | ECHOK | IEXTEN | ECHOCTL | ECHOKE;
|
||||
tio.c_cc[VMIN] = 1;
|
||||
tio.c_cc[VINTR] = CTRL('C');
|
||||
tio.c_cc[VQUIT] = CTRL('\\');
|
||||
tio.c_cc[VERASE] = CTRL('?');
|
||||
tio.c_cc[VKILL] = CTRL('U');
|
||||
tio.c_cc[VEOF] = CTRL('D');
|
||||
tio.c_cc[VSTART] = CTRL('Q');
|
||||
tio.c_cc[VSTOP] = CTRL('S');
|
||||
tio.c_cc[VSUSP] = CTRL('Z');
|
||||
tio.c_cc[VREPRINT] = CTRL('R');
|
||||
tio.c_cc[VDISCARD] = CTRL('O');
|
||||
tio.c_cc[VWERASE] = CTRL('W');
|
||||
tio.c_cc[VLNEXT] = CTRL('V');
|
||||
|
||||
if (openpty(&mfd, &sfd, 0, &tio, &wsz)) {
|
||||
write(2, STR("error: openpty() failed\n"));
|
||||
return 3;
|
||||
}
|
||||
|
||||
ignore.sa_flags = 0;
|
||||
ignore.sa_handler = SIG_IGN;
|
||||
sigemptyset(&ignore.sa_mask);
|
||||
sigaction(SIGINT, &ignore, &saveint);
|
||||
sigaction(SIGQUIT, &ignore, &savequit);
|
||||
sigemptyset(&chldmask);
|
||||
sigaddset(&chldmask, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &chldmask, &savemask);
|
||||
|
||||
if ((pid = vfork()) == -1) {
|
||||
write(2, STR("error: vfork() failed\n"));
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
close(0);
|
||||
dup(sfd);
|
||||
close(1);
|
||||
dup(sfd);
|
||||
close(2);
|
||||
dup(sfd);
|
||||
close(mfd);
|
||||
sigaction(SIGINT, &saveint, 0);
|
||||
sigaction(SIGQUIT, &savequit, 0);
|
||||
sigprocmask(SIG_SETMASK, &savemask, 0);
|
||||
execv(prog, argv + 1);
|
||||
return 127;
|
||||
}
|
||||
close(sfd);
|
||||
|
||||
for (;;) {
|
||||
if (waitpid(pid, &ws, WNOHANG) == pid) {
|
||||
break;
|
||||
}
|
||||
rc = read(mfd, databuf, sizeof(databuf));
|
||||
if (rc == -1) {
|
||||
perror("read");
|
||||
return 5;
|
||||
}
|
||||
if (!(got = rc)) {
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < got; i += wrote) {
|
||||
rc = write(1, databuf + i, got - i);
|
||||
if (rc != -1) {
|
||||
wrote = rc;
|
||||
} else {
|
||||
write(2, STR("error: read() failed\n"));
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sigaction(SIGINT, &saveint, 0);
|
||||
sigaction(SIGQUIT, &savequit, 0);
|
||||
sigprocmask(SIG_SETMASK, &savemask, 0);
|
||||
|
||||
if (WIFEXITED(ws)) {
|
||||
return WEXITSTATUS(ws);
|
||||
} else {
|
||||
return 128 + WTERMSIG(ws);
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ int openpty(int *mfd, int *sfd, char *name, const struct termios *tio,
|
|||
char buf[20];
|
||||
if ((m = open("/dev/ptmx", O_RDWR | O_NOCTTY)) != -1) {
|
||||
n = 0;
|
||||
if (!ioctl(m, TIOCSPTLCK, &n) || !ioctl(m, TIOCGPTN, &n)) {
|
||||
if (!ioctl(m, TIOCSPTLCK, &n) && !ioctl(m, TIOCGPTN, &n)) {
|
||||
if (!name) name = buf;
|
||||
name[0] = '/', name[1] = 'd', name[2] = 'e', name[3] = 'v';
|
||||
name[4] = '/', name[5] = 'p', name[6] = 't', name[7] = 's';
|
||||
|
|
42
libc/calls/sched_rr_get_interval.c
Normal file
42
libc/calls/sched_rr_get_interval.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/calls/calls.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
||||
int sys_sched_rr_get_interval(int, struct timespec *) hidden;
|
||||
|
||||
/**
|
||||
* Returns round-robin `SCHED_RR` quantum for `pid`.
|
||||
*
|
||||
* @param pid is id of process (where 0 is same as getpid())
|
||||
* @param tp receives output interval
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @error ENOSYS if not Linux or FreeBSD
|
||||
* @error EFAULT if `tp` memory is invalid
|
||||
* @error EINVAL if invalid `pid`
|
||||
* @error ESRCH if could not find `pid`
|
||||
*/
|
||||
int sched_rr_get_interval(int pid, struct timespec *tp) {
|
||||
int rc;
|
||||
rc = sys_sched_rr_get_interval(pid, tp);
|
||||
STRACE("sched_rr_get_interval(%d, [%s]) → %d% m", pid,
|
||||
DescribeTimespec(rc, tp), rc);
|
||||
return rc;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct sched_param {
|
||||
|
@ -10,6 +11,7 @@ int sched_get_priority_max(int);
|
|||
int sched_get_priority_min(int);
|
||||
int sched_getparam(int, struct sched_param *);
|
||||
int sched_getscheduler(int);
|
||||
int sched_rr_get_interval(int, struct timespec *);
|
||||
int sched_setparam(int, const struct sched_param *);
|
||||
int sched_setscheduler(int, int, const struct sched_param *);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ int tcsetpgrp(int, int32_t);
|
|||
int32_t tcgetpgrp(int);
|
||||
|
||||
int openpty(int *, int *, char *, const struct termios *,
|
||||
const struct winsize *) paramsnonnull((1, 2)) dontdiscard;
|
||||
const struct winsize *) paramsnonnull((1, 2));
|
||||
int forkpty(int *, char *, const struct termios *, const struct winsize *)
|
||||
paramsnonnull((1, 2)) dontdiscard;
|
||||
char *ptsname(int);
|
||||
|
|
|
@ -35,7 +35,7 @@ char *ecvt(double, int, int *, int *);
|
|||
│ cosmopolitan § string formatting » optimizations ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
|
||||
#define sprintf(BUF, FMT, ...) (sprintf)(BUF, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vsprintf(BUF, FMT, VA) (vsprintf)(BUF, PFLINK(FMT), VA)
|
||||
#define snprintf(B, Z, F, ...) (snprintf)(B, Z, PFLINK(F), ##__VA_ARGS__)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_PTHREAD_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_PTHREAD_H_
|
||||
#include "libc/bits/atomic.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
|
@ -130,20 +129,20 @@ void *pthread_getspecific(pthread_key_t);
|
|||
})
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define pthread_mutex_lock(mutex) \
|
||||
(((mutex)->attr == PTHREAD_MUTEX_NORMAL && \
|
||||
!atomic_load_explicit(&(mutex)->lock, memory_order_relaxed) && \
|
||||
!atomic_exchange(&(mutex)->lock, 1)) \
|
||||
? 0 \
|
||||
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407
|
||||
#define pthread_mutex_lock(mutex) \
|
||||
(((mutex)->attr == PTHREAD_MUTEX_NORMAL && \
|
||||
!__atomic_load_n(&(mutex)->lock, __ATOMIC_RELAXED) && \
|
||||
!__atomic_exchange_n(&(mutex)->lock, 1, __ATOMIC_SEQ_CST)) \
|
||||
? 0 \
|
||||
: pthread_mutex_lock(mutex))
|
||||
#define pthread_mutex_unlock(mutex) \
|
||||
((mutex)->attr == PTHREAD_MUTEX_NORMAL \
|
||||
? (atomic_store_explicit(&(mutex)->lock, 0, memory_order_relaxed), \
|
||||
((IsLinux() || IsOpenbsd()) && \
|
||||
atomic_load_explicit(&(mutex)->waits, memory_order_relaxed) && \
|
||||
_pthread_mutex_wake(mutex)), \
|
||||
0) \
|
||||
#define pthread_mutex_unlock(mutex) \
|
||||
((mutex)->attr == PTHREAD_MUTEX_NORMAL \
|
||||
? (__atomic_store_n(&(mutex)->lock, 0, __ATOMIC_RELAXED), \
|
||||
((IsLinux() || IsOpenbsd()) && \
|
||||
__atomic_load_n(&(mutex)->waits, __ATOMIC_RELAXED) && \
|
||||
_pthread_mutex_wake(mutex)), \
|
||||
0) \
|
||||
: pthread_mutex_unlock(mutex))
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LIBC_ISYSTEM_SCHED_H_
|
||||
#define LIBC_ISYSTEM_SCHED_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* transforms strings into the current C locale.
|
||||
* Transforms strings into current C locale.
|
||||
* calling strcmp() on two strxfrm()-ed strings
|
||||
* is same as calling strcoll() on the originals.
|
||||
*
|
||||
|
|
31
libc/str/wcsxfrm.c
Normal file
31
libc/str/wcsxfrm.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
|
||||
size_t wcsxfrm(wchar_t *d, const wchar_t *s, size_t n) {
|
||||
size_t m;
|
||||
m = wcslen(s);
|
||||
if (m < n) {
|
||||
wmemcpy(d, s, m + 1);
|
||||
} else if (m) {
|
||||
wmemcpy(d, s, m - 1);
|
||||
d[m - 1] = 0;
|
||||
}
|
||||
return m;
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sched_rr_get_interval,0xffffff14effff094,globl
|
2
libc/sysv/calls/sys_sched_rr_get_interval.s
Normal file
2
libc/sysv/calls/sys_sched_rr_get_interval.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall sys_sched_rr_get_interval,0xffffff14effff094,globl,hidden
|
|
@ -206,7 +206,7 @@ scall sys_sched_get_priority_max 0xffffff14cffff092 globl hidden
|
|||
scall sys_sched_get_priority_min 0xffffff14dffff093 globl hidden
|
||||
scall cpuset_getaffinity 0xffffff1e7fffffff globl
|
||||
scall cpuset_setaffinity 0xffffff1e8fffffff globl
|
||||
scall sched_rr_get_interval 0xffffff14effff094 globl
|
||||
scall sys_sched_rr_get_interval 0xffffff14effff094 globl hidden
|
||||
scall vhangup 0xfffffffffffff099 globl
|
||||
scall modify_ldt 0xfffffffffffff09a globl
|
||||
scall pivot_root 0xfffffffffffff09b globl
|
||||
|
|
23
libc/unicode/freelocale.c
Normal file
23
libc/unicode/freelocale.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/unicode/locale.h"
|
||||
|
||||
void freelocale(locale_t l) {
|
||||
// TODO: implement me
|
||||
}
|
24
libc/unicode/islower_l.c
Normal file
24
libc/unicode/islower_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int islower_l(int c, locale_t l) {
|
||||
return islower(c);
|
||||
}
|
24
libc/unicode/isupper_l.c
Normal file
24
libc/unicode/isupper_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int isupper_l(int c, locale_t l) {
|
||||
return isupper(c);
|
||||
}
|
24
libc/unicode/iswalpha_l.c
Normal file
24
libc/unicode/iswalpha_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswalpha_l(wint_t c, locale_t l) {
|
||||
return iswalpha(c);
|
||||
}
|
24
libc/unicode/iswblank_l.c
Normal file
24
libc/unicode/iswblank_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswblank_l(wint_t c, locale_t l) {
|
||||
return iswblank(c);
|
||||
}
|
24
libc/unicode/iswcntrl_l.c
Normal file
24
libc/unicode/iswcntrl_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswcntrl_l(wint_t c, locale_t l) {
|
||||
return iswcntrl(c);
|
||||
}
|
24
libc/unicode/iswdigit_l.c
Normal file
24
libc/unicode/iswdigit_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswdigit_l(wint_t c, locale_t l) {
|
||||
return iswdigit(c);
|
||||
}
|
24
libc/unicode/iswlower_l.c
Normal file
24
libc/unicode/iswlower_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswlower_l(wint_t c, locale_t l) {
|
||||
return iswlower(c);
|
||||
}
|
24
libc/unicode/iswprint_l.c
Normal file
24
libc/unicode/iswprint_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswprint_l(wint_t c, locale_t l) {
|
||||
return iswprint(c);
|
||||
}
|
24
libc/unicode/iswpunct_l.c
Normal file
24
libc/unicode/iswpunct_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswpunct_l(wint_t c, locale_t l) {
|
||||
return iswpunct(c);
|
||||
}
|
24
libc/unicode/iswspace_l.c
Normal file
24
libc/unicode/iswspace_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswspace_l(wint_t c, locale_t l) {
|
||||
return iswspace(c);
|
||||
}
|
24
libc/unicode/iswupper_l.c
Normal file
24
libc/unicode/iswupper_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswupper_l(wint_t c, locale_t l) {
|
||||
return iswupper(c);
|
||||
}
|
24
libc/unicode/iswxdigit_l.c
Normal file
24
libc/unicode/iswxdigit_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int iswxdigit_l(wint_t c, locale_t l) {
|
||||
return iswxdigit(c);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_UNICODE_LOCALE_H_
|
||||
#define COSMOPOLITAN_LIBC_UNICODE_LOCALE_H_
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
|
||||
#define LC_CTYPE 0
|
||||
#define LC_NUMERIC 1
|
||||
|
@ -24,20 +25,43 @@ struct __locale_struct;
|
|||
typedef struct __locale_struct *locale_t;
|
||||
|
||||
char *setlocale(int, const char *);
|
||||
locale_t uselocale(locale_t);
|
||||
locale_t newlocale(int, const char *, locale_t);
|
||||
long long strtoll_l(const char *, char **, int, locale_t);
|
||||
unsigned long long strtoull_l(const char *, char **, int, locale_t);
|
||||
long long wcstoll_l(const wchar_t *, wchar_t **, int, locale_t);
|
||||
unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t);
|
||||
double strtod_l(const char *, char **, locale_t);
|
||||
double wcstod_l(const wchar_t *, wchar_t **, locale_t);
|
||||
float strtof_l(const char *, char **, locale_t);
|
||||
float wcstof_l(const wchar_t *, wchar_t **, locale_t);
|
||||
double wcstod_l(const wchar_t *, wchar_t **, locale_t);
|
||||
long double wcstold_l(const wchar_t *, wchar_t **, locale_t);
|
||||
double strtod_l(const char *, char **, locale_t);
|
||||
long double strtold_l(const char *, char **, locale_t);
|
||||
int isxdigit_l(int, locale_t);
|
||||
int isdigit_l(int, locale_t);
|
||||
int islower_l(int, locale_t);
|
||||
int isupper_l(int, locale_t);
|
||||
int iswalpha_l(wint_t, locale_t);
|
||||
int iswblank_l(wint_t, locale_t);
|
||||
int iswcntrl_l(wint_t, locale_t);
|
||||
int iswdigit_l(wint_t, locale_t);
|
||||
int iswlower_l(wint_t, locale_t);
|
||||
int iswprint_l(wint_t, locale_t);
|
||||
int iswpunct_l(wint_t, locale_t);
|
||||
int iswspace_l(wint_t, locale_t);
|
||||
int iswupper_l(wint_t, locale_t);
|
||||
int iswxdigit_l(wint_t, locale_t);
|
||||
int isxdigit_l(int, locale_t);
|
||||
int strcoll_l(const char *, const char *, locale_t);
|
||||
int tolower_l(int, locale_t);
|
||||
int toupper_l(int, locale_t);
|
||||
int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
|
||||
locale_t duplocale(locale_t);
|
||||
locale_t newlocale(int, const char *, locale_t);
|
||||
locale_t uselocale(locale_t);
|
||||
long double strtold_l(const char *, char **, locale_t);
|
||||
long double wcstold_l(const wchar_t *, wchar_t **, locale_t);
|
||||
long long strtoll_l(const char *, char **, int, locale_t);
|
||||
long long wcstoll_l(const wchar_t *, wchar_t **, int, locale_t);
|
||||
size_t strftime_l(char *, size_t, char const *, struct tm const *, locale_t);
|
||||
size_t strxfrm_l(char *, const char *, size_t, locale_t);
|
||||
size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
|
||||
unsigned long long strtoull_l(const char *, char **, int, locale_t);
|
||||
unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t);
|
||||
void freelocale(locale_t);
|
||||
wint_t towlower_l(wint_t, locale_t);
|
||||
wint_t towupper_l(wint_t, locale_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
25
libc/unicode/newlocale.c
Normal file
25
libc/unicode/newlocale.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/sysv/errfuns.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
locale_t newlocale(int catmask, const char *locale, locale_t base) {
|
||||
// TODO: implement me
|
||||
return 0;
|
||||
}
|
24
libc/unicode/strcoll_l.c
Normal file
24
libc/unicode/strcoll_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int strcoll_l(const char *p, const char *q, locale_t l) {
|
||||
return strcmp(p, q);
|
||||
}
|
24
libc/unicode/strxfrm_l.c
Normal file
24
libc/unicode/strxfrm_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
size_t strxfrm_l(char *dest, const char *src, size_t count, locale_t l) {
|
||||
return strxfrm(dest, src, count);
|
||||
}
|
24
libc/unicode/tolower_l.c
Normal file
24
libc/unicode/tolower_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int tolower_l(int c, locale_t l) {
|
||||
return tolower(c);
|
||||
}
|
24
libc/unicode/toupper_l.c
Normal file
24
libc/unicode/toupper_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int toupper_l(int c, locale_t l) {
|
||||
return toupper(c);
|
||||
}
|
24
libc/unicode/towlower_l.c
Normal file
24
libc/unicode/towlower_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
wint_t towlower_l(wint_t c, locale_t l) {
|
||||
return towlower(c);
|
||||
}
|
24
libc/unicode/towupper_l.c
Normal file
24
libc/unicode/towupper_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
wint_t towupper_l(wint_t c, locale_t l) {
|
||||
return towupper(c);
|
||||
}
|
25
libc/unicode/uselocale.c
Normal file
25
libc/unicode/uselocale.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/sysv/errfuns.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
locale_t uselocale(locale_t l) {
|
||||
// TODO: implement me!
|
||||
return 0;
|
||||
}
|
24
libc/unicode/wcscoll_l.c
Normal file
24
libc/unicode/wcscoll_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
int wcscoll_l(const wchar_t *p, const wchar_t *q, locale_t l) {
|
||||
return wcscmp(p, q);
|
||||
}
|
24
libc/unicode/wcsxfrm_l.c
Normal file
24
libc/unicode/wcsxfrm_l.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 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/str/str.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t count, locale_t l) {
|
||||
return wcsxfrm(dest, src, count);
|
||||
}
|
40
third_party/gdtoa/strtold_l.c
vendored
Normal file
40
third_party/gdtoa/strtold_l.c
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set et ft=c ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
│ │
|
||||
│ The author of this software is David M. Gay. │
|
||||
│ Please send bug reports to David M. Gay <dmg@acm.org> │
|
||||
│ or Justine Tunney <jtunney@gmail.com> │
|
||||
│ │
|
||||
│ Copyright (C) 1998, 1999 by Lucent Technologies │
|
||||
│ All Rights Reserved │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and distribute this software and │
|
||||
│ its documentation for any purpose and without fee is hereby │
|
||||
│ granted, provided that the above copyright notice appear in all │
|
||||
│ copies and that both that the copyright notice and this │
|
||||
│ permission notice and warranty disclaimer appear in supporting │
|
||||
│ documentation, and that the name of Lucent or any of its entities │
|
||||
│ not be used in advertising or publicity pertaining to │
|
||||
│ distribution of the software without specific, written prior │
|
||||
│ permission. │
|
||||
│ │
|
||||
│ LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, │
|
||||
│ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. │
|
||||
│ IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY │
|
||||
│ SPECIAL, 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/unicode/locale.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
/**
|
||||
* Converts string to long double.
|
||||
*/
|
||||
long double strtold_l(const char *s, char **endptr, locale_t l) {
|
||||
return strtold(s, endptr);
|
||||
}
|
77
third_party/libcxx/__sso_allocator
vendored
Normal file
77
third_party/libcxx/__sso_allocator
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___SSO_ALLOCATOR
|
||||
#define _LIBCPP___SSO_ALLOCATOR
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/new"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator;
|
||||
|
||||
template <size_t _Np>
|
||||
class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
|
||||
{
|
||||
public:
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
};
|
||||
|
||||
template <class _Tp, size_t _Np>
|
||||
class _LIBCPP_HIDDEN __sso_allocator
|
||||
{
|
||||
typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
|
||||
bool __allocated_;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp value_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
|
||||
: __allocated_(false) {}
|
||||
private:
|
||||
__sso_allocator& operator=(const __sso_allocator&);
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)
|
||||
{
|
||||
if (!__allocated_ && __n <= _Np)
|
||||
{
|
||||
__allocated_ = true;
|
||||
return (pointer)&buf_;
|
||||
}
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)
|
||||
{
|
||||
if (__p == (pointer)&buf_)
|
||||
__allocated_ = false;
|
||||
else
|
||||
_VSTD::__libcpp_deallocate(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___SSO_ALLOCATOR
|
362
third_party/libcxx/__std_stream
vendored
Normal file
362
third_party/libcxx/__std_stream
vendored
Normal file
|
@ -0,0 +1,362 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___STD_STREAM
|
||||
#define _LIBCPP___STD_STREAM
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/ostream"
|
||||
#include "third_party/libcxx/istream"
|
||||
#include "third_party/libcxx/__locale"
|
||||
#include "third_party/libcxx/cstdio"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
static const int __limit = 8;
|
||||
|
||||
// __stdinbuf
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_HIDDEN __stdinbuf
|
||||
: public basic_streambuf<_CharT, char_traits<_CharT> >
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
typedef typename traits_type::state_type state_type;
|
||||
|
||||
__stdinbuf(FILE* __fp, state_type* __st);
|
||||
|
||||
protected:
|
||||
virtual int_type underflow();
|
||||
virtual int_type uflow();
|
||||
virtual int_type pbackfail(int_type __c = traits_type::eof());
|
||||
virtual void imbue(const locale& __loc);
|
||||
|
||||
private:
|
||||
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type* __st_;
|
||||
int __encoding_;
|
||||
int_type __last_consumed_;
|
||||
bool __last_consumed_is_next_;
|
||||
bool __always_noconv_;
|
||||
|
||||
__stdinbuf(const __stdinbuf&);
|
||||
__stdinbuf& operator=(const __stdinbuf&);
|
||||
|
||||
int_type __getchar(bool __consume);
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
|
||||
: __file_(__fp),
|
||||
__st_(__st),
|
||||
__last_consumed_(traits_type::eof()),
|
||||
__last_consumed_is_next_(false)
|
||||
{
|
||||
imbue(this->getloc());
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
void
|
||||
__stdinbuf<_CharT>::imbue(const locale& __loc)
|
||||
{
|
||||
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
|
||||
__encoding_ = __cv_->encoding();
|
||||
__always_noconv_ = __cv_->always_noconv();
|
||||
if (__encoding_ > __limit)
|
||||
__throw_runtime_error("unsupported locale for standard input");
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::underflow()
|
||||
{
|
||||
return __getchar(false);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::uflow()
|
||||
{
|
||||
return __getchar(true);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::__getchar(bool __consume)
|
||||
{
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
int_type __result = __last_consumed_;
|
||||
if (__consume)
|
||||
{
|
||||
__last_consumed_ = traits_type::eof();
|
||||
__last_consumed_is_next_ = false;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
char __extbuf[__limit];
|
||||
int __nread = _VSTD::max(1, __encoding_);
|
||||
for (int __i = 0; __i < __nread; ++__i)
|
||||
{
|
||||
int __c = getc(__file_);
|
||||
if (__c == EOF)
|
||||
return traits_type::eof();
|
||||
__extbuf[__i] = static_cast<char>(__c);
|
||||
}
|
||||
char_type __1buf;
|
||||
if (__always_noconv_)
|
||||
__1buf = static_cast<char_type>(__extbuf[0]);
|
||||
else
|
||||
{
|
||||
const char* __enxt;
|
||||
char_type* __inxt;
|
||||
codecvt_base::result __r;
|
||||
do
|
||||
{
|
||||
state_type __sv_st = *__st_;
|
||||
__r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
|
||||
&__1buf, &__1buf + 1, __inxt);
|
||||
switch (__r)
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
*__st_ = __sv_st;
|
||||
if (__nread == sizeof(__extbuf))
|
||||
return traits_type::eof();
|
||||
{
|
||||
int __c = getc(__file_);
|
||||
if (__c == EOF)
|
||||
return traits_type::eof();
|
||||
__extbuf[__nread] = static_cast<char>(__c);
|
||||
}
|
||||
++__nread;
|
||||
break;
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__1buf = static_cast<char_type>(__extbuf[0]);
|
||||
break;
|
||||
}
|
||||
} while (__r == _VSTD::codecvt_base::partial);
|
||||
}
|
||||
if (!__consume)
|
||||
{
|
||||
for (int __i = __nread; __i > 0;)
|
||||
{
|
||||
if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
else
|
||||
__last_consumed_ = traits_type::to_int_type(__1buf);
|
||||
return traits_type::to_int_type(__1buf);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::pbackfail(int_type __c)
|
||||
{
|
||||
if (traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
if (!__last_consumed_is_next_)
|
||||
{
|
||||
__c = __last_consumed_;
|
||||
__last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
|
||||
traits_type::eof());
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
char* __enxt;
|
||||
const char_type __ci = traits_type::to_char_type(__last_consumed_);
|
||||
const char_type* __inxt;
|
||||
switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
|
||||
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__extbuf[0] = static_cast<char>(__last_consumed_);
|
||||
__enxt = __extbuf + 1;
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
}
|
||||
while (__enxt > __extbuf)
|
||||
if (ungetc(*--__enxt, __file_) == EOF)
|
||||
return traits_type::eof();
|
||||
}
|
||||
__last_consumed_ = __c;
|
||||
__last_consumed_is_next_ = true;
|
||||
return __c;
|
||||
}
|
||||
|
||||
// __stdoutbuf
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_HIDDEN __stdoutbuf
|
||||
: public basic_streambuf<_CharT, char_traits<_CharT> >
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
typedef typename traits_type::state_type state_type;
|
||||
|
||||
__stdoutbuf(FILE* __fp, state_type* __st);
|
||||
|
||||
protected:
|
||||
virtual int_type overflow (int_type __c = traits_type::eof());
|
||||
virtual streamsize xsputn(const char_type* __s, streamsize __n);
|
||||
virtual int sync();
|
||||
virtual void imbue(const locale& __loc);
|
||||
|
||||
private:
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type* __st_;
|
||||
bool __always_noconv_;
|
||||
|
||||
__stdoutbuf(const __stdoutbuf&);
|
||||
__stdoutbuf& operator=(const __stdoutbuf&);
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
|
||||
: __file_(__fp),
|
||||
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
|
||||
__st_(__st),
|
||||
__always_noconv_(__cv_->always_noconv())
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdoutbuf<_CharT>::int_type
|
||||
__stdoutbuf<_CharT>::overflow(int_type __c)
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
char_type __1buf;
|
||||
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
__1buf = traits_type::to_char_type(__c);
|
||||
if (__always_noconv_)
|
||||
{
|
||||
if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else
|
||||
{
|
||||
char* __extbe = __extbuf;
|
||||
codecvt_base::result __r;
|
||||
char_type* pbase = &__1buf;
|
||||
char_type* pptr = pbase + 1;
|
||||
do
|
||||
{
|
||||
const char_type* __e;
|
||||
__r = __cv_->out(*__st_, pbase, pptr, __e,
|
||||
__extbuf,
|
||||
__extbuf + sizeof(__extbuf),
|
||||
__extbe);
|
||||
if (__e == pbase)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::noconv)
|
||||
{
|
||||
if (fwrite(pbase, 1, 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
|
||||
{
|
||||
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
||||
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
pbase = const_cast<char_type*>(__e);
|
||||
}
|
||||
}
|
||||
else
|
||||
return traits_type::eof();
|
||||
} while (__r == codecvt_base::partial);
|
||||
}
|
||||
}
|
||||
return traits_type::not_eof(__c);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
streamsize
|
||||
__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
|
||||
{
|
||||
if (__always_noconv_)
|
||||
return fwrite(__s, sizeof(char_type), __n, __file_);
|
||||
streamsize __i = 0;
|
||||
for (; __i < __n; ++__i, ++__s)
|
||||
if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
|
||||
break;
|
||||
return __i;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
int
|
||||
__stdoutbuf<_CharT>::sync()
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
codecvt_base::result __r;
|
||||
do
|
||||
{
|
||||
char* __extbe;
|
||||
__r = __cv_->unshift(*__st_, __extbuf,
|
||||
__extbuf + sizeof(__extbuf),
|
||||
__extbe);
|
||||
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
||||
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
|
||||
return -1;
|
||||
} while (__r == codecvt_base::partial);
|
||||
if (__r == codecvt_base::error)
|
||||
return -1;
|
||||
if (fflush(__file_))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
void
|
||||
__stdoutbuf<_CharT>::imbue(const locale& __loc)
|
||||
{
|
||||
sync();
|
||||
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
|
||||
__always_noconv_ = __cv_->always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___STD_STREAM
|
6
third_party/libcxx/__threading_support
vendored
6
third_party/libcxx/__threading_support
vendored
|
@ -24,8 +24,10 @@
|
|||
#elif !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# include "third_party/libcxx/pthread.h"
|
||||
# include "third_party/libcxx/sched.h"
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
|
|
484
third_party/libcxx/array
vendored
Normal file
484
third_party/libcxx/array
vendored
Normal file
|
@ -0,0 +1,484 @@
|
|||
// -*- C++ -*-
|
||||
//===---------------------------- array -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_ARRAY
|
||||
#define _LIBCPP_ARRAY
|
||||
|
||||
/*
|
||||
array synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class T, size_t N >
|
||||
struct array
|
||||
{
|
||||
// types:
|
||||
typedef T & reference;
|
||||
typedef const T & const_reference;
|
||||
typedef implementation defined iterator;
|
||||
typedef implementation defined const_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
void fill(const T& u);
|
||||
void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
|
||||
|
||||
// iterators:
|
||||
iterator begin() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
|
||||
reverse_iterator rbegin() noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
reverse_iterator rend() noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// capacity:
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// element access:
|
||||
reference operator[](size_type n);
|
||||
const_reference operator[](size_type n) const; // constexpr in C++14
|
||||
const_reference at(size_type n) const; // constexpr in C++14
|
||||
reference at(size_type n);
|
||||
|
||||
reference front();
|
||||
const_reference front() const; // constexpr in C++14
|
||||
reference back();
|
||||
const_reference back() const; // constexpr in C++14
|
||||
|
||||
T* data() noexcept;
|
||||
const T* data() const noexcept;
|
||||
};
|
||||
|
||||
template <class T, class... U>
|
||||
array(T, U...) -> array<T, 1 + sizeof...(U)>;
|
||||
|
||||
template <class T, size_t N>
|
||||
bool operator==(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator!=(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator<(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator>(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator<=(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator>=(const array<T,N>& x, const array<T,N>& y);
|
||||
|
||||
template <class T, size_t N >
|
||||
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
|
||||
|
||||
template <class T> struct tuple_size;
|
||||
template <size_t I, class T> struct tuple_element;
|
||||
template <class T, size_t N> struct tuple_size<array<T, N>>;
|
||||
template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
|
||||
template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/__tuple"
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/utility"
|
||||
#include "third_party/libcxx/iterator"
|
||||
#include "third_party/libcxx/algorithm"
|
||||
#include "third_party/libcxx/stdexcept"
|
||||
#include "third_party/libcxx/cstdlib" // for _LIBCPP_UNREACHABLE
|
||||
#include "third_party/libcxx/version"
|
||||
#include "third_party/libcxx/__debug"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS array
|
||||
{
|
||||
// types:
|
||||
typedef array __self;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
_Tp __elems_[_Size];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
|
||||
_VSTD::fill_n(__elems_, _Size, __u);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
|
||||
std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator end() _NOEXCEPT {return iterator(data() + _Size);}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reference operator[](size_type __n) _NOEXCEPT {return __elems_[__n];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type __n) const _NOEXCEPT {return __elems_[__n];}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n);
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return __elems_[_Size - 1];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return __elems_[_Size - 1];}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
value_type* data() _NOEXCEPT {return __elems_;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const value_type* data() const _NOEXCEPT {return __elems_;}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename array<_Tp, _Size>::reference
|
||||
array<_Tp, _Size>::at(size_type __n)
|
||||
{
|
||||
if (__n >= _Size)
|
||||
__throw_out_of_range("array::at");
|
||||
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename array<_Tp, _Size>::const_reference
|
||||
array<_Tp, _Size>::at(size_type __n) const
|
||||
{
|
||||
if (__n >= _Size)
|
||||
__throw_out_of_range("array::at");
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
|
||||
{
|
||||
// types:
|
||||
typedef array __self;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
typedef typename conditional<is_const<_Tp>::value, const char,
|
||||
char>::type _CharType;
|
||||
|
||||
struct _ArrayInStructT { _Tp __data_[1]; };
|
||||
_ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot fill zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array&) _NOEXCEPT {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot swap zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator[](size_type) _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type) const _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference at(size_type) {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type) const {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference front() _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference back() _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
|
||||
};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Tp, class... _Args,
|
||||
class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
|
||||
>
|
||||
array(_Tp, _Args...)
|
||||
-> array<_Tp, 1 + sizeof...(_Args)>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
_Size == 0 ||
|
||||
__is_swappable<_Tp>::value,
|
||||
void
|
||||
>::type
|
||||
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
|
||||
_NOEXCEPT_(noexcept(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
|
||||
: public integral_constant<size_t, _Size> {};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&
|
||||
get(array<_Tp, _Size>& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
|
||||
return __a.__elems_[_Ip];
|
||||
}
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
get(const array<_Tp, _Size>& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
|
||||
return __a.__elems_[_Ip];
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&&
|
||||
get(array<_Tp, _Size>&& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
|
||||
return _VSTD::move(__a.__elems_[_Ip]);
|
||||
}
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&&
|
||||
get(const array<_Tp, _Size>&& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
|
||||
return _VSTD::move(__a.__elems_[_Ip]);
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ARRAY
|
2443
third_party/libcxx/atomic
vendored
Normal file
2443
third_party/libcxx/atomic
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
third_party/libcxx/bit
vendored
7
third_party/libcxx/bit
vendored
|
@ -59,13 +59,6 @@ namespace std {
|
|||
#include "third_party/libcxx/version"
|
||||
#include "third_party/libcxx/__debug"
|
||||
|
||||
#if defined(__IBMCPP__)
|
||||
#include "support/ibm/support.h"
|
||||
#endif
|
||||
#if defined(_LIBCPP_COMPILER_MSVC)
|
||||
#include "third_party/libcxx/intrin.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
|
68
third_party/libcxx/chrono.cc
vendored
Normal file
68
third_party/libcxx/chrono.cc
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
// clang-format off
|
||||
//===------------------------- chrono.cpp ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/chrono"
|
||||
#include "third_party/libcxx/cerrno" // errn"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "third_party/libcxx/system_error" // __throw_system_erro"
|
||||
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace chrono
|
||||
{
|
||||
|
||||
// system_clock
|
||||
|
||||
const bool system_clock::is_steady;
|
||||
|
||||
system_clock::time_point
|
||||
system_clock::now() _NOEXCEPT
|
||||
{
|
||||
struct timespec tp;
|
||||
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
|
||||
__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
|
||||
return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
|
||||
}
|
||||
|
||||
time_t
|
||||
system_clock::to_time_t(const time_point& t) _NOEXCEPT
|
||||
{
|
||||
return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
|
||||
}
|
||||
|
||||
system_clock::time_point
|
||||
system_clock::from_time_t(time_t t) _NOEXCEPT
|
||||
{
|
||||
return system_clock::time_point(seconds(t));
|
||||
}
|
||||
|
||||
// steady_clock
|
||||
//
|
||||
// Warning: If this is not truly steady, then it is non-conforming. It is
|
||||
// better for it to not exist and have the rest of libc++ use system_clock
|
||||
// instead.
|
||||
|
||||
const bool steady_clock::is_steady;
|
||||
|
||||
steady_clock::time_point
|
||||
steady_clock::now() _NOEXCEPT
|
||||
{
|
||||
struct timespec tp;
|
||||
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
|
||||
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
|
||||
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
|
||||
}
|
||||
|
||||
} // namespace chrono
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
55
third_party/libcxx/clocale
vendored
Normal file
55
third_party/libcxx/clocale
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- clocale ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CLOCALE
|
||||
#define _LIBCPP_CLOCALE
|
||||
|
||||
/*
|
||||
clocale synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
LC_ALL
|
||||
LC_COLLATE
|
||||
LC_CTYPE
|
||||
LC_MONETARY
|
||||
LC_NUMERIC
|
||||
LC_TIME
|
||||
NULL
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
struct lconv;
|
||||
char* setlocale(int category, const char* locale);
|
||||
lconv* localeconv();
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::lconv;
|
||||
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
using ::setlocale;
|
||||
#endif
|
||||
using ::localeconv;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CLOCALE
|
550
third_party/libcxx/codecvt
vendored
Normal file
550
third_party/libcxx/codecvt
vendored
Normal file
|
@ -0,0 +1,550 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===-------------------------- codecvt -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CODECVT
|
||||
#define _LIBCPP_CODECVT
|
||||
|
||||
/*
|
||||
codecvt synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum codecvt_mode
|
||||
{
|
||||
consume_header = 4,
|
||||
generate_header = 2,
|
||||
little_endian = 1
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf8
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf8(size_t refs = 0);
|
||||
~codecvt_utf8();
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf16
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf16(size_t refs = 0);
|
||||
~codecvt_utf16();
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf8_utf16
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf8_utf16(size_t refs = 0);
|
||||
~codecvt_utf8_utf16();
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/__locale"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
enum codecvt_mode
|
||||
{
|
||||
consume_header = 4,
|
||||
generate_header = 2,
|
||||
little_endian = 1
|
||||
};
|
||||
|
||||
// codecvt_utf8
|
||||
|
||||
template <class _Elem> class __codecvt_utf8;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf8
|
||||
: public __codecvt_utf8<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8(size_t __refs = 0)
|
||||
: __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8() {}
|
||||
};
|
||||
|
||||
// codecvt_utf16
|
||||
|
||||
template <class _Elem, bool _LittleEndian> class __codecvt_utf16;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf16
|
||||
: public __codecvt_utf16<_Elem, _Mode & little_endian>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf16() {}
|
||||
};
|
||||
|
||||
// codecvt_utf8_utf16
|
||||
|
||||
template <class _Elem> class __codecvt_utf8_utf16;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
|
||||
: public __codecvt_utf8_utf16<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8_utf16() {}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CODECVT
|
269
third_party/libcxx/condition_variable
vendored
Normal file
269
third_party/libcxx/condition_variable
vendored
Normal file
|
@ -0,0 +1,269 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===---------------------- condition_variable ----------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CONDITION_VARIABLE
|
||||
#define _LIBCPP_CONDITION_VARIABLE
|
||||
|
||||
/*
|
||||
condition_variable synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum class cv_status { no_timeout, timeout };
|
||||
|
||||
class condition_variable
|
||||
{
|
||||
public:
|
||||
condition_variable();
|
||||
~condition_variable();
|
||||
|
||||
condition_variable(const condition_variable&) = delete;
|
||||
condition_variable& operator=(const condition_variable&) = delete;
|
||||
|
||||
void notify_one() noexcept;
|
||||
void notify_all() noexcept;
|
||||
|
||||
void wait(unique_lock<mutex>& lock);
|
||||
template <class Predicate>
|
||||
void wait(unique_lock<mutex>& lock, Predicate pred);
|
||||
|
||||
template <class Clock, class Duration>
|
||||
cv_status
|
||||
wait_until(unique_lock<mutex>& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time);
|
||||
|
||||
template <class Clock, class Duration, class Predicate>
|
||||
bool
|
||||
wait_until(unique_lock<mutex>& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time,
|
||||
Predicate pred);
|
||||
|
||||
template <class Rep, class Period>
|
||||
cv_status
|
||||
wait_for(unique_lock<mutex>& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
template <class Rep, class Period, class Predicate>
|
||||
bool
|
||||
wait_for(unique_lock<mutex>& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time,
|
||||
Predicate pred);
|
||||
|
||||
typedef pthread_cond_t* native_handle_type;
|
||||
native_handle_type native_handle();
|
||||
};
|
||||
|
||||
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
||||
|
||||
class condition_variable_any
|
||||
{
|
||||
public:
|
||||
condition_variable_any();
|
||||
~condition_variable_any();
|
||||
|
||||
condition_variable_any(const condition_variable_any&) = delete;
|
||||
condition_variable_any& operator=(const condition_variable_any&) = delete;
|
||||
|
||||
void notify_one() noexcept;
|
||||
void notify_all() noexcept;
|
||||
|
||||
template <class Lock>
|
||||
void wait(Lock& lock);
|
||||
template <class Lock, class Predicate>
|
||||
void wait(Lock& lock, Predicate pred);
|
||||
|
||||
template <class Lock, class Clock, class Duration>
|
||||
cv_status
|
||||
wait_until(Lock& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time);
|
||||
|
||||
template <class Lock, class Clock, class Duration, class Predicate>
|
||||
bool
|
||||
wait_until(Lock& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time,
|
||||
Predicate pred);
|
||||
|
||||
template <class Lock, class Rep, class Period>
|
||||
cv_status
|
||||
wait_for(Lock& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
template <class Lock, class Rep, class Period, class Predicate>
|
||||
bool
|
||||
wait_for(Lock& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time,
|
||||
Predicate pred);
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/__mutex_base"
|
||||
#include "third_party/libcxx/memory"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable_any
|
||||
{
|
||||
condition_variable __cv_;
|
||||
shared_ptr<mutex> __mut_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
condition_variable_any();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void notify_one() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void notify_all() _NOEXCEPT;
|
||||
|
||||
template <class _Lock>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
void wait(_Lock& __lock);
|
||||
template <class _Lock, class _Predicate>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void wait(_Lock& __lock, _Predicate __pred);
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
cv_status
|
||||
wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t);
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
||||
bool
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred);
|
||||
|
||||
template <class _Lock, class _Rep, class _Period>
|
||||
cv_status
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d);
|
||||
|
||||
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
||||
bool
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred);
|
||||
};
|
||||
|
||||
inline
|
||||
condition_variable_any::condition_variable_any()
|
||||
: __mut_(make_shared<mutex>()) {}
|
||||
|
||||
inline
|
||||
void
|
||||
condition_variable_any::notify_one() _NOEXCEPT
|
||||
{
|
||||
{lock_guard<mutex> __lx(*__mut_);}
|
||||
__cv_.notify_one();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
condition_variable_any::notify_all() _NOEXCEPT
|
||||
{
|
||||
{lock_guard<mutex> __lx(*__mut_);}
|
||||
__cv_.notify_all();
|
||||
}
|
||||
|
||||
struct __lock_external
|
||||
{
|
||||
template <class _Lock>
|
||||
void operator()(_Lock* __m) {__m->lock();}
|
||||
};
|
||||
|
||||
template <class _Lock>
|
||||
void
|
||||
condition_variable_any::wait(_Lock& __lock)
|
||||
{
|
||||
shared_ptr<mutex> __mut = __mut_;
|
||||
unique_lock<mutex> __lk(*__mut);
|
||||
__lock.unlock();
|
||||
unique_ptr<_Lock, __lock_external> __lxx(&__lock);
|
||||
lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
|
||||
__cv_.wait(__lk);
|
||||
} // __mut_.unlock(), __lock.lock()
|
||||
|
||||
template <class _Lock, class _Predicate>
|
||||
inline
|
||||
void
|
||||
condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
wait(__lock);
|
||||
}
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration>
|
||||
cv_status
|
||||
condition_variable_any::wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
shared_ptr<mutex> __mut = __mut_;
|
||||
unique_lock<mutex> __lk(*__mut);
|
||||
__lock.unlock();
|
||||
unique_ptr<_Lock, __lock_external> __lxx(&__lock);
|
||||
lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
|
||||
return __cv_.wait_until(__lk, __t);
|
||||
} // __mut_.unlock(), __lock.lock()
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
||||
inline
|
||||
bool
|
||||
condition_variable_any::wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
if (wait_until(__lock, __t) == cv_status::timeout)
|
||||
return __pred();
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Lock, class _Rep, class _Period>
|
||||
inline
|
||||
cv_status
|
||||
condition_variable_any::wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return wait_until(__lock, chrono::steady_clock::now() + __d);
|
||||
}
|
||||
|
||||
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
||||
inline
|
||||
bool
|
||||
condition_variable_any::wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred)
|
||||
{
|
||||
return wait_until(__lock, chrono::steady_clock::now() + __d,
|
||||
_VSTD::move(__pred));
|
||||
}
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_CONDITION_VARIABLE
|
90
third_party/libcxx/condition_variable.cc
vendored
Normal file
90
third_party/libcxx/condition_variable.cc
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
// clang-format off
|
||||
//===-------------------- condition_variable.cpp --------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#include "third_party/libcxx/condition_variable"
|
||||
#include "third_party/libcxx/thread"
|
||||
#include "third_party/libcxx/system_error"
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// ~condition_variable is defined elsewhere.
|
||||
|
||||
void
|
||||
condition_variable::notify_one() _NOEXCEPT
|
||||
{
|
||||
__libcpp_condvar_signal(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::notify_all() _NOEXCEPT
|
||||
{
|
||||
__libcpp_condvar_broadcast(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::wait(unique_lock<mutex>& lk) _NOEXCEPT
|
||||
{
|
||||
if (!lk.owns_lock())
|
||||
__throw_system_error(EPERM,
|
||||
"condition_variable::wait: mutex not locked");
|
||||
int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
|
||||
if (ec)
|
||||
__throw_system_error(ec, "condition_variable wait failed");
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) _NOEXCEPT
|
||||
{
|
||||
using namespace chrono;
|
||||
if (!lk.owns_lock())
|
||||
__throw_system_error(EPERM,
|
||||
"condition_variable::timed wait: mutex not locked");
|
||||
nanoseconds d = tp.time_since_epoch();
|
||||
if (d > nanoseconds(0x59682F000000E941))
|
||||
d = nanoseconds(0x59682F000000E941);
|
||||
__libcpp_timespec_t ts;
|
||||
seconds s = duration_cast<seconds>(d);
|
||||
typedef decltype(ts.tv_sec) ts_sec;
|
||||
_LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
|
||||
if (s.count() < ts_sec_max)
|
||||
{
|
||||
ts.tv_sec = static_cast<ts_sec>(s.count());
|
||||
ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
|
||||
}
|
||||
else
|
||||
{
|
||||
ts.tv_sec = ts_sec_max;
|
||||
ts.tv_nsec = giga::num - 1;
|
||||
}
|
||||
int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
|
||||
if (ec != 0 && ec != ETIMEDOUT)
|
||||
__throw_system_error(ec, "condition_variable timed_wait failed");
|
||||
}
|
||||
|
||||
void
|
||||
notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
|
||||
{
|
||||
auto& tl_ptr = __thread_local_data();
|
||||
// If this thread was not created using std::thread then it will not have
|
||||
// previously allocated.
|
||||
if (tl_ptr.get() == nullptr) {
|
||||
tl_ptr.set_pointer(new __thread_struct);
|
||||
}
|
||||
__thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
47
third_party/libcxx/condition_variable_destructor.cc
vendored
Normal file
47
third_party/libcxx/condition_variable_destructor.cc
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// clang-format off
|
||||
//===---------------- condition_variable_destructor.cpp ------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Define ~condition_variable.
|
||||
//
|
||||
// On some platforms ~condition_variable has been made trivial and the
|
||||
// definition is only provided for ABI compatibility.
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/__threading_support"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
# if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
|
||||
# define NEEDS_CONDVAR_DESTRUCTOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifdef NEEDS_CONDVAR_DESTRUCTOR
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable
|
||||
{
|
||||
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr condition_variable() noexcept = default;
|
||||
|
||||
~condition_variable();
|
||||
|
||||
condition_variable(const condition_variable&) = delete;
|
||||
condition_variable& operator=(const condition_variable&) = delete;
|
||||
};
|
||||
|
||||
condition_variable::~condition_variable()
|
||||
{
|
||||
__libcpp_condvar_destroy(&__cv_);
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
1
third_party/libcxx/ctime
vendored
1
third_party/libcxx/ctime
vendored
|
@ -46,6 +46,7 @@ int timespec_get( struct timespec *ts, int base); // C++17
|
|||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/isystem/time.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
|
|
4
third_party/libcxx/exception
vendored
4
third_party/libcxx/exception
vendored
|
@ -82,10 +82,6 @@ template <class E> void rethrow_if_nested(const E& e);
|
|||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/version"
|
||||
|
||||
#if defined(_LIBCPP_ABI_VCRUNTIME)
|
||||
#include "third_party/libcxx/vcruntime_exception.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
|
80
third_party/libcxx/experimental/__config
vendored
Normal file
80
third_party/libcxx/experimental/__config
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- __config ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_CONFIG
|
||||
#define _LIBCPP_EXPERIMENTAL_CONFIG
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
|
||||
#define _VSTD_EXPERIMENTAL std::experimental
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS } } }
|
||||
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } }
|
||||
#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
|
||||
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \
|
||||
namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
|
||||
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
|
||||
|
||||
#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM)
|
||||
# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */
|
||||
#else
|
||||
# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro.")))
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \
|
||||
inline namespace v1 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
|
||||
} } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace coroutines_v1 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
|
||||
|
||||
// TODO: support more targets
|
||||
#if defined(__AVX__)
|
||||
#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
|
||||
#else
|
||||
#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
|
||||
#endif
|
||||
|
||||
#endif
|
177
third_party/libcxx/include/atomic_support.hh
vendored
Normal file
177
third_party/libcxx/include/atomic_support.hh
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
// clang-format off
|
||||
//===----------------------------------------------------------------------===////
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===////
|
||||
|
||||
#ifndef ATOMIC_SUPPORT_H
|
||||
#define ATOMIC_SUPPORT_H
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/memory" // for __libcpp_relaxed_loa"
|
||||
|
||||
#if defined(__clang__) && __has_builtin(__atomic_load_n) \
|
||||
&& __has_builtin(__atomic_store_n) \
|
||||
&& __has_builtin(__atomic_add_fetch) \
|
||||
&& __has_builtin(__atomic_exchange_n) \
|
||||
&& __has_builtin(__atomic_compare_exchange_n) \
|
||||
&& defined(__ATOMIC_RELAXED) \
|
||||
&& defined(__ATOMIC_CONSUME) \
|
||||
&& defined(__ATOMIC_ACQUIRE) \
|
||||
&& defined(__ATOMIC_RELEASE) \
|
||||
&& defined(__ATOMIC_ACQ_REL) \
|
||||
&& defined(__ATOMIC_SEQ_CST)
|
||||
# define _LIBCPP_HAS_ATOMIC_BUILTINS
|
||||
#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
|
||||
# define _LIBCPP_HAS_ATOMIC_BUILTINS
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
# if defined(_LIBCPP_WARNING)
|
||||
_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
|
||||
# else
|
||||
# warning Building libc++ without __atomic builtins is unsupported
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
enum __libcpp_atomic_order {
|
||||
_AO_Relaxed = __ATOMIC_RELAXED,
|
||||
_AO_Consume = __ATOMIC_CONSUME,
|
||||
_AO_Acquire = __ATOMIC_ACQUIRE,
|
||||
_AO_Release = __ATOMIC_RELEASE,
|
||||
_AO_Acq_Rel = __ATOMIC_ACQ_REL,
|
||||
_AO_Seq = __ATOMIC_SEQ_CST
|
||||
};
|
||||
|
||||
template <class _ValueType, class _FromType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
|
||||
int __order = _AO_Seq)
|
||||
{
|
||||
__atomic_store_n(__dest, __val, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType, class _FromType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
|
||||
{
|
||||
__atomic_store_n(__dest, __val, _AO_Relaxed);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_load(_ValueType const* __val,
|
||||
int __order = _AO_Seq)
|
||||
{
|
||||
return __atomic_load_n(__val, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType, class _AddType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
|
||||
int __order = _AO_Seq)
|
||||
{
|
||||
return __atomic_add_fetch(__val, __a, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_exchange(_ValueType* __target,
|
||||
_ValueType __value, int __order = _AO_Seq)
|
||||
{
|
||||
return __atomic_exchange_n(__target, __value, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
|
||||
_ValueType* __expected, _ValueType __after,
|
||||
int __success_order = _AO_Seq,
|
||||
int __fail_order = _AO_Seq)
|
||||
{
|
||||
return __atomic_compare_exchange_n(__val, __expected, __after, true,
|
||||
__success_order, __fail_order);
|
||||
}
|
||||
|
||||
#else // _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
enum __libcpp_atomic_order {
|
||||
_AO_Relaxed,
|
||||
_AO_Consume,
|
||||
_AO_Acquire,
|
||||
_AO_Release,
|
||||
_AO_Acq_Rel,
|
||||
_AO_Seq
|
||||
};
|
||||
|
||||
template <class _ValueType, class _FromType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
|
||||
int = 0)
|
||||
{
|
||||
*__dest = __val;
|
||||
}
|
||||
|
||||
template <class _ValueType, class _FromType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
|
||||
{
|
||||
*__dest = __val;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_load(_ValueType const* __val,
|
||||
int = 0)
|
||||
{
|
||||
return *__val;
|
||||
}
|
||||
|
||||
template <class _ValueType, class _AddType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
|
||||
int = 0)
|
||||
{
|
||||
return *__val += __a;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_exchange(_ValueType* __target,
|
||||
_ValueType __value, int __order = _AO_Seq)
|
||||
{
|
||||
_ValueType old = *__target;
|
||||
*__target = __value;
|
||||
return old;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
|
||||
_ValueType* __expected, _ValueType __after,
|
||||
int = 0, int = 0)
|
||||
{
|
||||
if (*__val == *__expected) {
|
||||
*__val = __after;
|
||||
return true;
|
||||
}
|
||||
*__expected = *__val;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
} // end namespace
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // ATOMIC_SUPPORT_H
|
36
third_party/libcxx/include/config_elast.hh
vendored
Normal file
36
third_party/libcxx/include/config_elast.hh
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// clang-format off
|
||||
//===----------------------- config_elast.h -------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CONFIG_ELAST
|
||||
#define _LIBCPP_CONFIG_ELAST
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if defined(ELAST)
|
||||
#define _LIBCPP_ELAST ELAST
|
||||
#elif defined(_NEWLIB_VERSION)
|
||||
#define _LIBCPP_ELAST __ELASTERROR
|
||||
#elif defined(__Fuchsia__)
|
||||
// No _LIBCPP_ELAST needed on Fuchsia
|
||||
#elif defined(__wasi__)
|
||||
// No _LIBCPP_ELAST needed on WASI
|
||||
#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
|
||||
#define _LIBCPP_ELAST 4095
|
||||
#elif defined(__APPLE__)
|
||||
// No _LIBCPP_ELAST needed on Apple
|
||||
#elif defined(__sun__)
|
||||
#define _LIBCPP_ELAST ESTALE
|
||||
#elif defined(_LIBCPP_MSVCRT_LIKE)
|
||||
#define _LIBCPP_ELAST (_sys_nerr - 1)
|
||||
#else
|
||||
// Warn here so that the person doing the libcxx port has an easier time:
|
||||
#warning ELAST for this platform not yet implemented
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CONFIG_ELAST
|
456
third_party/libcxx/ios.cc
vendored
Normal file
456
third_party/libcxx/ios.cc
vendored
Normal file
|
@ -0,0 +1,456 @@
|
|||
// clang-format off
|
||||
//===-------------------------- ios.cpp -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#include "third_party/libcxx/ios"
|
||||
|
||||
#include "third_party/libcxx/__locale"
|
||||
#include "third_party/libcxx/algorithm"
|
||||
#include "third_party/libcxx/include/config_elast.hh"
|
||||
#include "third_party/libcxx/istream"
|
||||
#include "third_party/libcxx/limits"
|
||||
#include "third_party/libcxx/memory"
|
||||
#include "third_party/libcxx/new"
|
||||
#include "third_party/libcxx/streambuf"
|
||||
#include "third_party/libcxx/string"
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;
|
||||
|
||||
class _LIBCPP_HIDDEN __iostream_category
|
||||
: public __do_message
|
||||
{
|
||||
public:
|
||||
virtual const char* name() const _NOEXCEPT;
|
||||
virtual string message(int ev) const;
|
||||
};
|
||||
|
||||
const char*
|
||||
__iostream_category::name() const _NOEXCEPT
|
||||
{
|
||||
return "iostream";
|
||||
}
|
||||
|
||||
string
|
||||
__iostream_category::message(int ev) const
|
||||
{
|
||||
if (ev != static_cast<int>(io_errc::stream)
|
||||
#ifdef _LIBCPP_ELAST
|
||||
&& ev <= _LIBCPP_ELAST
|
||||
#endif // _LIBCPP_ELAST
|
||||
)
|
||||
return __do_message::message(ev);
|
||||
return string("unspecified iostream_category error");
|
||||
}
|
||||
|
||||
const error_category&
|
||||
iostream_category() _NOEXCEPT
|
||||
{
|
||||
static __iostream_category s;
|
||||
return s;
|
||||
}
|
||||
|
||||
// ios_base::failure
|
||||
|
||||
ios_base::failure::failure(const string& msg, const error_code& ec)
|
||||
: system_error(ec, msg)
|
||||
{
|
||||
}
|
||||
|
||||
ios_base::failure::failure(const char* msg, const error_code& ec)
|
||||
: system_error(ec, msg)
|
||||
{
|
||||
}
|
||||
|
||||
ios_base::failure::~failure() throw()
|
||||
{
|
||||
}
|
||||
|
||||
// ios_base locale
|
||||
|
||||
const ios_base::fmtflags ios_base::boolalpha;
|
||||
const ios_base::fmtflags ios_base::dec;
|
||||
const ios_base::fmtflags ios_base::fixed;
|
||||
const ios_base::fmtflags ios_base::hex;
|
||||
const ios_base::fmtflags ios_base::internal;
|
||||
const ios_base::fmtflags ios_base::left;
|
||||
const ios_base::fmtflags ios_base::oct;
|
||||
const ios_base::fmtflags ios_base::right;
|
||||
const ios_base::fmtflags ios_base::scientific;
|
||||
const ios_base::fmtflags ios_base::showbase;
|
||||
const ios_base::fmtflags ios_base::showpoint;
|
||||
const ios_base::fmtflags ios_base::showpos;
|
||||
const ios_base::fmtflags ios_base::skipws;
|
||||
const ios_base::fmtflags ios_base::unitbuf;
|
||||
const ios_base::fmtflags ios_base::uppercase;
|
||||
const ios_base::fmtflags ios_base::adjustfield;
|
||||
const ios_base::fmtflags ios_base::basefield;
|
||||
const ios_base::fmtflags ios_base::floatfield;
|
||||
|
||||
const ios_base::iostate ios_base::badbit;
|
||||
const ios_base::iostate ios_base::eofbit;
|
||||
const ios_base::iostate ios_base::failbit;
|
||||
const ios_base::iostate ios_base::goodbit;
|
||||
|
||||
const ios_base::openmode ios_base::app;
|
||||
const ios_base::openmode ios_base::ate;
|
||||
const ios_base::openmode ios_base::binary;
|
||||
const ios_base::openmode ios_base::in;
|
||||
const ios_base::openmode ios_base::out;
|
||||
const ios_base::openmode ios_base::trunc;
|
||||
|
||||
void
|
||||
ios_base::__call_callbacks(event ev)
|
||||
{
|
||||
for (size_t i = __event_size_; i;)
|
||||
{
|
||||
--i;
|
||||
__fn_[i](ev, *this, __index_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// locale
|
||||
|
||||
locale
|
||||
ios_base::imbue(const locale& newloc)
|
||||
{
|
||||
static_assert(sizeof(locale) == sizeof(__loc_), "");
|
||||
locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
|
||||
locale oldloc = loc_storage;
|
||||
loc_storage = newloc;
|
||||
__call_callbacks(imbue_event);
|
||||
return oldloc;
|
||||
}
|
||||
|
||||
locale
|
||||
ios_base::getloc() const
|
||||
{
|
||||
const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
|
||||
return loc_storage;
|
||||
}
|
||||
|
||||
// xalloc
|
||||
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
|
||||
#else
|
||||
int ios_base::__xindex_ = 0;
|
||||
#endif
|
||||
|
||||
template <typename _Tp>
|
||||
static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
|
||||
{ // Precondition: __req_size > __current_cap
|
||||
const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
|
||||
if (__req_size < mx/2)
|
||||
return _VSTD::max(2 * __current_cap, __req_size);
|
||||
else
|
||||
return mx;
|
||||
}
|
||||
|
||||
int
|
||||
ios_base::xalloc()
|
||||
{
|
||||
return __xindex_++;
|
||||
}
|
||||
|
||||
long&
|
||||
ios_base::iword(int index)
|
||||
{
|
||||
size_t req_size = static_cast<size_t>(index)+1;
|
||||
if (req_size > __iarray_cap_)
|
||||
{
|
||||
size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
|
||||
long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
|
||||
if (iarray == 0)
|
||||
{
|
||||
setstate(badbit);
|
||||
static long error;
|
||||
error = 0;
|
||||
return error;
|
||||
}
|
||||
__iarray_ = iarray;
|
||||
for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
|
||||
*p = 0;
|
||||
__iarray_cap_ = newcap;
|
||||
}
|
||||
__iarray_size_ = max<size_t>(__iarray_size_, req_size);
|
||||
return __iarray_[index];
|
||||
}
|
||||
|
||||
void*&
|
||||
ios_base::pword(int index)
|
||||
{
|
||||
size_t req_size = static_cast<size_t>(index)+1;
|
||||
if (req_size > __parray_cap_)
|
||||
{
|
||||
size_t newcap = __ios_new_cap<void *>(req_size, __iarray_cap_);
|
||||
void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void *)));
|
||||
if (parray == 0)
|
||||
{
|
||||
setstate(badbit);
|
||||
static void* error;
|
||||
error = 0;
|
||||
return error;
|
||||
}
|
||||
__parray_ = parray;
|
||||
for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
|
||||
*p = 0;
|
||||
__parray_cap_ = newcap;
|
||||
}
|
||||
__parray_size_ = max<size_t>(__parray_size_, req_size);
|
||||
return __parray_[index];
|
||||
}
|
||||
|
||||
// register_callback
|
||||
|
||||
void
|
||||
ios_base::register_callback(event_callback fn, int index)
|
||||
{
|
||||
size_t req_size = __event_size_ + 1;
|
||||
if (req_size > __event_cap_)
|
||||
{
|
||||
size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
|
||||
event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
|
||||
if (fns == 0)
|
||||
setstate(badbit);
|
||||
__fn_ = fns;
|
||||
int* indxs = static_cast<int *>(realloc(__index_, newcap * sizeof(int)));
|
||||
if (indxs == 0)
|
||||
setstate(badbit);
|
||||
__index_ = indxs;
|
||||
__event_cap_ = newcap;
|
||||
}
|
||||
__fn_[__event_size_] = fn;
|
||||
__index_[__event_size_] = index;
|
||||
++__event_size_;
|
||||
}
|
||||
|
||||
ios_base::~ios_base()
|
||||
{
|
||||
__call_callbacks(erase_event);
|
||||
locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
|
||||
loc_storage.~locale();
|
||||
free(__fn_);
|
||||
free(__index_);
|
||||
free(__iarray_);
|
||||
free(__parray_);
|
||||
}
|
||||
|
||||
// iostate
|
||||
|
||||
void
|
||||
ios_base::clear(iostate state)
|
||||
{
|
||||
if (__rdbuf_)
|
||||
__rdstate_ = state;
|
||||
else
|
||||
__rdstate_ = state | badbit;
|
||||
|
||||
if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
|
||||
__throw_failure("ios_base::clear");
|
||||
}
|
||||
|
||||
// init
|
||||
|
||||
void
|
||||
ios_base::init(void* sb)
|
||||
{
|
||||
__rdbuf_ = sb;
|
||||
__rdstate_ = __rdbuf_ ? goodbit : badbit;
|
||||
__exceptions_ = goodbit;
|
||||
__fmtflags_ = skipws | dec;
|
||||
__width_ = 0;
|
||||
__precision_ = 6;
|
||||
__fn_ = 0;
|
||||
__index_ = 0;
|
||||
__event_size_ = 0;
|
||||
__event_cap_ = 0;
|
||||
__iarray_ = 0;
|
||||
__iarray_size_ = 0;
|
||||
__iarray_cap_ = 0;
|
||||
__parray_ = 0;
|
||||
__parray_size_ = 0;
|
||||
__parray_cap_ = 0;
|
||||
::new(&__loc_) locale;
|
||||
}
|
||||
|
||||
void
|
||||
ios_base::copyfmt(const ios_base& rhs)
|
||||
{
|
||||
// If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
|
||||
// Don't alter *this until all needed resources are acquired
|
||||
unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
|
||||
unique_ptr<int, void (*)(void*)> new_ints(0, free);
|
||||
unique_ptr<long, void (*)(void*)> new_longs(0, free);
|
||||
unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
|
||||
if (__event_cap_ < rhs.__event_size_)
|
||||
{
|
||||
size_t newesize = sizeof(event_callback) * rhs.__event_size_;
|
||||
new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
|
||||
if (!new_callbacks)
|
||||
__throw_bad_alloc();
|
||||
|
||||
size_t newisize = sizeof(int) * rhs.__event_size_;
|
||||
new_ints.reset(static_cast<int *>(malloc(newisize)));
|
||||
if (!new_ints)
|
||||
__throw_bad_alloc();
|
||||
}
|
||||
if (__iarray_cap_ < rhs.__iarray_size_)
|
||||
{
|
||||
size_t newsize = sizeof(long) * rhs.__iarray_size_;
|
||||
new_longs.reset(static_cast<long*>(malloc(newsize)));
|
||||
if (!new_longs)
|
||||
__throw_bad_alloc();
|
||||
}
|
||||
if (__parray_cap_ < rhs.__parray_size_)
|
||||
{
|
||||
size_t newsize = sizeof(void*) * rhs.__parray_size_;
|
||||
new_pointers.reset(static_cast<void**>(malloc(newsize)));
|
||||
if (!new_pointers)
|
||||
__throw_bad_alloc();
|
||||
}
|
||||
// Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
|
||||
__fmtflags_ = rhs.__fmtflags_;
|
||||
__precision_ = rhs.__precision_;
|
||||
__width_ = rhs.__width_;
|
||||
locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
|
||||
const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
|
||||
lhs_loc = rhs_loc;
|
||||
if (__event_cap_ < rhs.__event_size_)
|
||||
{
|
||||
free(__fn_);
|
||||
__fn_ = new_callbacks.release();
|
||||
free(__index_);
|
||||
__index_ = new_ints.release();
|
||||
__event_cap_ = rhs.__event_size_;
|
||||
}
|
||||
for (__event_size_ = 0; __event_size_ < rhs.__event_size_; ++__event_size_)
|
||||
{
|
||||
__fn_[__event_size_] = rhs.__fn_[__event_size_];
|
||||
__index_[__event_size_] = rhs.__index_[__event_size_];
|
||||
}
|
||||
if (__iarray_cap_ < rhs.__iarray_size_)
|
||||
{
|
||||
free(__iarray_);
|
||||
__iarray_ = new_longs.release();
|
||||
__iarray_cap_ = rhs.__iarray_size_;
|
||||
}
|
||||
for (__iarray_size_ = 0; __iarray_size_ < rhs.__iarray_size_; ++__iarray_size_)
|
||||
__iarray_[__iarray_size_] = rhs.__iarray_[__iarray_size_];
|
||||
if (__parray_cap_ < rhs.__parray_size_)
|
||||
{
|
||||
free(__parray_);
|
||||
__parray_ = new_pointers.release();
|
||||
__parray_cap_ = rhs.__parray_size_;
|
||||
}
|
||||
for (__parray_size_ = 0; __parray_size_ < rhs.__parray_size_; ++__parray_size_)
|
||||
__parray_[__parray_size_] = rhs.__parray_[__parray_size_];
|
||||
}
|
||||
|
||||
void
|
||||
ios_base::move(ios_base& rhs)
|
||||
{
|
||||
// *this is uninitialized
|
||||
__fmtflags_ = rhs.__fmtflags_;
|
||||
__precision_ = rhs.__precision_;
|
||||
__width_ = rhs.__width_;
|
||||
__rdstate_ = rhs.__rdstate_;
|
||||
__exceptions_ = rhs.__exceptions_;
|
||||
__rdbuf_ = 0;
|
||||
locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
|
||||
::new(&__loc_) locale(rhs_loc);
|
||||
__fn_ = rhs.__fn_;
|
||||
rhs.__fn_ = 0;
|
||||
__index_ = rhs.__index_;
|
||||
rhs.__index_ = 0;
|
||||
__event_size_ = rhs.__event_size_;
|
||||
rhs.__event_size_ = 0;
|
||||
__event_cap_ = rhs.__event_cap_;
|
||||
rhs.__event_cap_ = 0;
|
||||
__iarray_ = rhs.__iarray_;
|
||||
rhs.__iarray_ = 0;
|
||||
__iarray_size_ = rhs.__iarray_size_;
|
||||
rhs.__iarray_size_ = 0;
|
||||
__iarray_cap_ = rhs.__iarray_cap_;
|
||||
rhs.__iarray_cap_ = 0;
|
||||
__parray_ = rhs.__parray_;
|
||||
rhs.__parray_ = 0;
|
||||
__parray_size_ = rhs.__parray_size_;
|
||||
rhs.__parray_size_ = 0;
|
||||
__parray_cap_ = rhs.__parray_cap_;
|
||||
rhs.__parray_cap_ = 0;
|
||||
}
|
||||
|
||||
void
|
||||
ios_base::swap(ios_base& rhs) _NOEXCEPT
|
||||
{
|
||||
_VSTD::swap(__fmtflags_, rhs.__fmtflags_);
|
||||
_VSTD::swap(__precision_, rhs.__precision_);
|
||||
_VSTD::swap(__width_, rhs.__width_);
|
||||
_VSTD::swap(__rdstate_, rhs.__rdstate_);
|
||||
_VSTD::swap(__exceptions_, rhs.__exceptions_);
|
||||
locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
|
||||
locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
|
||||
_VSTD::swap(lhs_loc, rhs_loc);
|
||||
_VSTD::swap(__fn_, rhs.__fn_);
|
||||
_VSTD::swap(__index_, rhs.__index_);
|
||||
_VSTD::swap(__event_size_, rhs.__event_size_);
|
||||
_VSTD::swap(__event_cap_, rhs.__event_cap_);
|
||||
_VSTD::swap(__iarray_, rhs.__iarray_);
|
||||
_VSTD::swap(__iarray_size_, rhs.__iarray_size_);
|
||||
_VSTD::swap(__iarray_cap_, rhs.__iarray_cap_);
|
||||
_VSTD::swap(__parray_, rhs.__parray_);
|
||||
_VSTD::swap(__parray_size_, rhs.__parray_size_);
|
||||
_VSTD::swap(__parray_cap_, rhs.__parray_cap_);
|
||||
}
|
||||
|
||||
void
|
||||
ios_base::__set_badbit_and_consider_rethrow()
|
||||
{
|
||||
__rdstate_ |= badbit;
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (__exceptions_ & badbit)
|
||||
throw;
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
|
||||
void
|
||||
ios_base::__set_failbit_and_consider_rethrow()
|
||||
{
|
||||
__rdstate_ |= failbit;
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (__exceptions_ & failbit)
|
||||
throw;
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
|
||||
bool
|
||||
ios_base::sync_with_stdio(bool sync)
|
||||
{
|
||||
static bool previous_state = true;
|
||||
bool r = previous_state;
|
||||
previous_state = sync;
|
||||
return r;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
64
third_party/libcxx/iostream
vendored
Normal file
64
third_party/libcxx/iostream
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- iostream ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_IOSTREAM
|
||||
#define _LIBCPP_IOSTREAM
|
||||
|
||||
/*
|
||||
iostream synopsis
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
namespace std {
|
||||
|
||||
extern istream cin;
|
||||
extern ostream cout;
|
||||
extern ostream cerr;
|
||||
extern ostream clog;
|
||||
extern wistream wcin;
|
||||
extern wostream wcout;
|
||||
extern wostream wcerr;
|
||||
extern wostream wclog;
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/ios"
|
||||
#include "third_party/libcxx/streambuf"
|
||||
#include "third_party/libcxx/istream"
|
||||
#include "third_party/libcxx/ostream"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
extern _LIBCPP_FUNC_VIS istream cin;
|
||||
extern _LIBCPP_FUNC_VIS wistream wcin;
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
extern _LIBCPP_FUNC_VIS ostream cout;
|
||||
extern _LIBCPP_FUNC_VIS wostream wcout;
|
||||
#endif
|
||||
extern _LIBCPP_FUNC_VIS ostream cerr;
|
||||
extern _LIBCPP_FUNC_VIS wostream wcerr;
|
||||
extern _LIBCPP_FUNC_VIS ostream clog;
|
||||
extern _LIBCPP_FUNC_VIS wostream wclog;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_IOSTREAM
|
160
third_party/libcxx/iostream.cc
vendored
Normal file
160
third_party/libcxx/iostream.cc
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
// clang-format off
|
||||
//===------------------------ iostream.cpp --------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/__std_stream"
|
||||
#include "third_party/libcxx/__locale"
|
||||
#include "third_party/libcxx/string"
|
||||
#include "third_party/libcxx/new"
|
||||
|
||||
#define _str(s) #s
|
||||
#define str(s) _str(s)
|
||||
#define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE)
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin[sizeof(__stdinbuf <char>)];
|
||||
static mbstate_t mb_cin;
|
||||
_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin[sizeof(__stdinbuf <wchar_t>)];
|
||||
static mbstate_t mb_wcin;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
|
||||
static mbstate_t mb_cout;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
|
||||
static mbstate_t mb_wcout;
|
||||
#endif
|
||||
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
|
||||
static mbstate_t mb_cerr;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
|
||||
static mbstate_t mb_wcerr;
|
||||
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
|
||||
_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
|
||||
|
||||
// On Windows the TLS storage for locales needs to be initialized before we create
|
||||
// the standard streams, otherwise it may not be alive during program termination
|
||||
// when we flush the streams.
|
||||
static void force_locale_initialization() {
|
||||
#if defined(_LIBCPP_MSVCRT_LIKE)
|
||||
static bool once = []() {
|
||||
auto loc = newlocale(LC_ALL_MASK, "C", 0);
|
||||
{
|
||||
__libcpp_locale_guard g(loc); // forces initialization of locale TLS
|
||||
((void)g);
|
||||
}
|
||||
freelocale(loc);
|
||||
return true;
|
||||
}();
|
||||
((void)once);
|
||||
#endif
|
||||
}
|
||||
|
||||
class DoIOSInit {
|
||||
public:
|
||||
DoIOSInit();
|
||||
~DoIOSInit();
|
||||
};
|
||||
|
||||
DoIOSInit::DoIOSInit()
|
||||
{
|
||||
force_locale_initialization();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin));
|
||||
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin));
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
|
||||
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
|
||||
#endif
|
||||
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
|
||||
::new(clog) ostream(cerr_ptr->rdbuf());
|
||||
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
|
||||
::new(wclog) wostream(wcerr_ptr->rdbuf());
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT)
|
||||
cin_ptr->tie(cout_ptr);
|
||||
wcin_ptr->tie(wcout_ptr);
|
||||
#endif
|
||||
_VSTD::unitbuf(*cerr_ptr);
|
||||
_VSTD::unitbuf(*wcerr_ptr);
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
cerr_ptr->tie(cout_ptr);
|
||||
wcerr_ptr->tie(wcout_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
DoIOSInit::~DoIOSInit()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
|
||||
wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
|
||||
cout_ptr->flush();
|
||||
wcout_ptr->flush();
|
||||
#endif
|
||||
|
||||
ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
|
||||
wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
|
||||
clog_ptr->flush();
|
||||
wclog_ptr->flush();
|
||||
}
|
||||
|
||||
ios_base::Init::Init()
|
||||
{
|
||||
static DoIOSInit init_the_streams; // gets initialized once
|
||||
}
|
||||
|
||||
ios_base::Init::~Init()
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
4
third_party/libcxx/istream
vendored
4
third_party/libcxx/istream
vendored
|
@ -359,7 +359,7 @@ basic_istream<_CharT, _Traits>::~basic_istream()
|
|||
}
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
|
||||
ios_base::iostate __state = ios_base::goodbit;
|
||||
|
@ -468,7 +468,7 @@ basic_istream<_CharT, _Traits>::operator>>(void*& __n)
|
|||
}
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
|
||||
ios_base::iostate __state = ios_base::goodbit;
|
||||
|
|
83
third_party/libcxx/libcxx.mk
vendored
83
third_party/libcxx/libcxx.mk
vendored
|
@ -13,59 +13,99 @@ THIRD_PARTY_LIBCXX_A_HDRS = \
|
|||
third_party/libcxx/__debug \
|
||||
third_party/libcxx/__functional_base \
|
||||
third_party/libcxx/__hash_table \
|
||||
third_party/libcxx/__mutex_base \
|
||||
third_party/libcxx/__node_handle \
|
||||
third_party/libcxx/__nullptr \
|
||||
third_party/libcxx/__split_buffer \
|
||||
third_party/libcxx/__sso_allocator \
|
||||
third_party/libcxx/__std_stream \
|
||||
third_party/libcxx/__threading_support \
|
||||
third_party/libcxx/__tuple \
|
||||
third_party/libcxx/__undef_macros \
|
||||
third_party/libcxx/algorithm \
|
||||
third_party/libcxx/array \
|
||||
third_party/libcxx/atomic_support.hh \
|
||||
third_party/libcxx/bit \
|
||||
third_party/libcxx/bitset \
|
||||
third_party/libcxx/cassert \
|
||||
third_party/libcxx/cerrno \
|
||||
third_party/libcxx/chrono \
|
||||
third_party/libcxx/climits \
|
||||
third_party/libcxx/cmath \
|
||||
third_party/libcxx/codecvt \
|
||||
third_party/libcxx/condition_variable \
|
||||
third_party/libcxx/config_elast.h \
|
||||
third_party/libcxx/cstddef \
|
||||
third_party/libcxx/cstdint \
|
||||
third_party/libcxx/cstdio \
|
||||
third_party/libcxx/cstdlib \
|
||||
third_party/libcxx/cstring \
|
||||
third_party/libcxx/deque \
|
||||
third_party/libcxx/exception \
|
||||
third_party/libcxx/exception_fallback.hh \
|
||||
third_party/libcxx/exception_pointer_unimplemented.hh \
|
||||
third_party/libcxx/include/atomic_support.hh \
|
||||
third_party/libcxx/include/config_elast.hh \
|
||||
third_party/libcxx/initializer_list \
|
||||
third_party/libcxx/ios \
|
||||
third_party/libcxx/iosfwd \
|
||||
third_party/libcxx/iostream \
|
||||
third_party/libcxx/istream \
|
||||
third_party/libcxx/limits \
|
||||
third_party/libcxx/list \
|
||||
third_party/libcxx/map \
|
||||
third_party/libcxx/memory \
|
||||
third_party/libcxx/mutex \
|
||||
third_party/libcxx/new \
|
||||
third_party/libcxx/new_handler_fallback.hh \
|
||||
third_party/libcxx/numeric \
|
||||
third_party/libcxx/optional \
|
||||
third_party/libcxx/ostream \
|
||||
third_party/libcxx/queue \
|
||||
third_party/libcxx/queue \
|
||||
third_party/libcxx/random \
|
||||
third_party/libcxx/ratio \
|
||||
third_party/libcxx/refstring.hh \
|
||||
third_party/libcxx/set \
|
||||
third_party/libcxx/sstream \
|
||||
third_party/libcxx/stdexcept \
|
||||
third_party/libcxx/stdexcept_default.hh \
|
||||
third_party/libcxx/streambuf \
|
||||
third_party/libcxx/string \
|
||||
third_party/libcxx/string_view \
|
||||
third_party/libcxx/system_error \
|
||||
third_party/libcxx/tuple \
|
||||
third_party/libcxx/type_traits \
|
||||
third_party/libcxx/typeinfo \
|
||||
third_party/libcxx/unordered_map \
|
||||
third_party/libcxx/unordered_set \
|
||||
third_party/libcxx/utility \
|
||||
third_party/libcxx/variant \
|
||||
third_party/libcxx/vector \
|
||||
third_party/libcxx/version \
|
||||
third_party/libcxx/wchar.h \
|
||||
third_party/libcxx/config_elast.h \
|
||||
third_party/libcxx/atomic_support.hh \
|
||||
third_party/libcxx/exception_fallback.hh \
|
||||
third_party/libcxx/exception_pointer_unimplemented.hh \
|
||||
third_party/libcxx/new_handler_fallback.hh \
|
||||
third_party/libcxx/refstring.hh \
|
||||
third_party/libcxx/stdexcept_default.hh
|
||||
third_party/libcxx/wchar.h
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_SRCS_CC = \
|
||||
third_party/libcxx/algorithm.cc \
|
||||
third_party/libcxx/charconv.cc \
|
||||
third_party/libcxx/chrono.cc \
|
||||
third_party/libcxx/condition_variable.cc \
|
||||
third_party/libcxx/condition_variable_destructor.cc \
|
||||
third_party/libcxx/exception.cc \
|
||||
third_party/libcxx/functional.cc \
|
||||
third_party/libcxx/system_error.cc \
|
||||
third_party/libcxx/random.cc \
|
||||
third_party/libcxx/hash.cc \
|
||||
third_party/libcxx/string.cc \
|
||||
third_party/libcxx/vector.cc \
|
||||
third_party/libcxx/ios.cc \
|
||||
third_party/libcxx/iostream.cc \
|
||||
third_party/libcxx/locale.cc \
|
||||
third_party/libcxx/memory.cc \
|
||||
third_party/libcxx/mutex.cc \
|
||||
third_party/libcxx/new.cc \
|
||||
third_party/libcxx/optional.cc \
|
||||
third_party/libcxx/random.cc \
|
||||
third_party/libcxx/stdexcept.cc \
|
||||
third_party/libcxx/exception.cc
|
||||
third_party/libcxx/string.cc \
|
||||
third_party/libcxx/system_error.cc \
|
||||
third_party/libcxx/vector.cc
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_SRCS = \
|
||||
$(THIRD_PARTY_LIBCXX_A_SRCS_S) \
|
||||
|
@ -81,17 +121,20 @@ THIRD_PARTY_LIBCXX_A_CHECKS = \
|
|||
$(THIRD_PARTY_LIBCXX_A_HDRS:%=o/$(MODE)/%.okk)
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_DIRECTDEPS = \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_MEM \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_RAND \
|
||||
LIBC_STDIO \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
LIBC_SYSV \
|
||||
LIBC_INTRIN \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RAND \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_STUBS \
|
||||
LIBC_SYSV \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
THIRD_PARTY_GDTOA
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_DEPS := \
|
||||
|
|
1
third_party/libcxx/locale
vendored
1
third_party/libcxx/locale
vendored
|
@ -194,6 +194,7 @@ template <class charT> class messages_byname;
|
|||
#include "third_party/libcxx/ctime"
|
||||
#include "third_party/libcxx/cstdio"
|
||||
#ifdef _LIBCPP_HAS_CATOPEN
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "third_party/libcxx/nl_types.h"
|
||||
#endif
|
||||
|
||||
|
|
6146
third_party/libcxx/locale.cc
vendored
Normal file
6146
third_party/libcxx/locale.cc
vendored
Normal file
File diff suppressed because it is too large
Load diff
239
third_party/libcxx/memory.cc
vendored
Normal file
239
third_party/libcxx/memory.cc
vendored
Normal file
|
@ -0,0 +1,239 @@
|
|||
// clang-format off
|
||||
//===------------------------ memory.cpp ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/memory"
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
#include "third_party/libcxx/mutex"
|
||||
#include "third_party/libcxx/thread"
|
||||
#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
|
||||
#pragma comment(lib, "pthread")
|
||||
#endif
|
||||
#endif
|
||||
#include "third_party/libcxx/include/atomic_support.hh"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// TODO(jart): why does this need to be commented?
|
||||
// const allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
|
||||
bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
|
||||
|
||||
const char*
|
||||
bad_weak_ptr::what() const _NOEXCEPT
|
||||
{
|
||||
return "bad_weak_ptr";
|
||||
}
|
||||
|
||||
__shared_count::~__shared_count()
|
||||
{
|
||||
}
|
||||
|
||||
__shared_weak_count::~__shared_weak_count()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
|
||||
void
|
||||
__shared_count::__add_shared() _NOEXCEPT
|
||||
{
|
||||
__libcpp_atomic_refcount_increment(__shared_owners_);
|
||||
}
|
||||
|
||||
bool
|
||||
__shared_count::__release_shared() _NOEXCEPT
|
||||
{
|
||||
if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
|
||||
{
|
||||
__on_zero_shared();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
__shared_weak_count::__add_shared() _NOEXCEPT
|
||||
{
|
||||
__shared_count::__add_shared();
|
||||
}
|
||||
|
||||
void
|
||||
__shared_weak_count::__add_weak() _NOEXCEPT
|
||||
{
|
||||
__libcpp_atomic_refcount_increment(__shared_weak_owners_);
|
||||
}
|
||||
|
||||
void
|
||||
__shared_weak_count::__release_shared() _NOEXCEPT
|
||||
{
|
||||
if (__shared_count::__release_shared())
|
||||
__release_weak();
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
|
||||
|
||||
void
|
||||
__shared_weak_count::__release_weak() _NOEXCEPT
|
||||
{
|
||||
// NOTE: The acquire load here is an optimization of the very
|
||||
// common case where a shared pointer is being destructed while
|
||||
// having no other contended references.
|
||||
//
|
||||
// BENEFIT: We avoid expensive atomic stores like XADD and STREX
|
||||
// in a common case. Those instructions are slow and do nasty
|
||||
// things to caches.
|
||||
//
|
||||
// IS THIS SAFE? Yes. During weak destruction, if we see that we
|
||||
// are the last reference, we know that no-one else is accessing
|
||||
// us. If someone were accessing us, then they would be doing so
|
||||
// while the last shared / weak_ptr was being destructed, and
|
||||
// that's undefined anyway.
|
||||
//
|
||||
// If we see anything other than a 0, then we have possible
|
||||
// contention, and need to use an atomicrmw primitive.
|
||||
// The same arguments don't apply for increment, where it is legal
|
||||
// (though inadvisable) to share shared_ptr references between
|
||||
// threads, and have them all get copied at once. The argument
|
||||
// also doesn't apply for __release_shared, because an outstanding
|
||||
// weak_ptr::lock() could read / modify the shared count.
|
||||
if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0)
|
||||
{
|
||||
// no need to do this store, because we are about
|
||||
// to destroy everything.
|
||||
//__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
|
||||
__on_zero_shared_weak();
|
||||
}
|
||||
else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
|
||||
__on_zero_shared_weak();
|
||||
}
|
||||
|
||||
__shared_weak_count*
|
||||
__shared_weak_count::lock() _NOEXCEPT
|
||||
{
|
||||
long object_owners = __libcpp_atomic_load(&__shared_owners_);
|
||||
while (object_owners != -1)
|
||||
{
|
||||
if (__libcpp_atomic_compare_exchange(&__shared_owners_,
|
||||
&object_owners,
|
||||
object_owners+1))
|
||||
return this;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
|
||||
|
||||
const void*
|
||||
__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
|
||||
_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =
|
||||
{
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER
|
||||
};
|
||||
|
||||
_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) _NOEXCEPT
|
||||
: __lx(p)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
__sp_mut::lock() _NOEXCEPT
|
||||
{
|
||||
auto m = static_cast<__libcpp_mutex_t*>(__lx);
|
||||
unsigned count = 0;
|
||||
while (!__libcpp_mutex_trylock(m))
|
||||
{
|
||||
if (++count > 16)
|
||||
{
|
||||
__libcpp_mutex_lock(m);
|
||||
break;
|
||||
}
|
||||
this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__sp_mut::unlock() _NOEXCEPT
|
||||
{
|
||||
__libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx));
|
||||
}
|
||||
|
||||
__sp_mut&
|
||||
__get_sp_mut(const void* p)
|
||||
{
|
||||
static __sp_mut muts[__sp_mut_count]
|
||||
{
|
||||
&mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
|
||||
&mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
|
||||
&mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
|
||||
&mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15]
|
||||
};
|
||||
return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
|
||||
}
|
||||
|
||||
#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
void
|
||||
declare_reachable(void*)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
declare_no_pointers(char*, size_t)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
undeclare_no_pointers(char*, size_t)
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE)
|
||||
pointer_safety get_pointer_safety() _NOEXCEPT
|
||||
{
|
||||
return pointer_safety::relaxed;
|
||||
}
|
||||
#endif
|
||||
|
||||
void*
|
||||
__undeclare_reachable(void* p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
void*
|
||||
align(size_t alignment, size_t size, void*& ptr, size_t& space)
|
||||
{
|
||||
void* r = nullptr;
|
||||
if (size <= space)
|
||||
{
|
||||
char* p1 = static_cast<char*>(ptr);
|
||||
char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
|
||||
size_t d = static_cast<size_t>(p2 - p1);
|
||||
if (d <= space - size)
|
||||
{
|
||||
r = p2;
|
||||
ptr = r;
|
||||
space -= d;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
1
third_party/libcxx/mutex
vendored
1
third_party/libcxx/mutex
vendored
|
@ -1,4 +1,5 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- mutex ------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
|
|
262
third_party/libcxx/mutex.cc
vendored
Normal file
262
third_party/libcxx/mutex.cc
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
// clang-format off
|
||||
//===------------------------- mutex.cpp ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/mutex"
|
||||
#include "third_party/libcxx/limits"
|
||||
#include "third_party/libcxx/system_error"
|
||||
#include "third_party/libcxx/include/atomic_support.hh"
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
|
||||
#pragma comment(lib, "pthread")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
// TODO(jart): why do we need to comment these out?
|
||||
// const defer_lock_t defer_lock{};
|
||||
// const try_to_lock_t try_to_lock{};
|
||||
// const adopt_lock_t adopt_lock{};
|
||||
|
||||
// ~mutex is defined elsewhere
|
||||
|
||||
void
|
||||
mutex::lock()
|
||||
{
|
||||
int ec = __libcpp_mutex_lock(&__m_);
|
||||
if (ec)
|
||||
__throw_system_error(ec, "mutex lock failed");
|
||||
}
|
||||
|
||||
bool
|
||||
mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
return __libcpp_mutex_trylock(&__m_);
|
||||
}
|
||||
|
||||
void
|
||||
mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
int ec = __libcpp_mutex_unlock(&__m_);
|
||||
(void)ec;
|
||||
_LIBCPP_ASSERT(ec == 0, "call to mutex::unlock failed");
|
||||
}
|
||||
|
||||
// recursive_mutex
|
||||
|
||||
recursive_mutex::recursive_mutex()
|
||||
{
|
||||
int ec = __libcpp_recursive_mutex_init(&__m_);
|
||||
if (ec)
|
||||
__throw_system_error(ec, "recursive_mutex constructor failed");
|
||||
}
|
||||
|
||||
recursive_mutex::~recursive_mutex()
|
||||
{
|
||||
int e = __libcpp_recursive_mutex_destroy(&__m_);
|
||||
(void)e;
|
||||
_LIBCPP_ASSERT(e == 0, "call to ~recursive_mutex() failed");
|
||||
}
|
||||
|
||||
void
|
||||
recursive_mutex::lock()
|
||||
{
|
||||
int ec = __libcpp_recursive_mutex_lock(&__m_);
|
||||
if (ec)
|
||||
__throw_system_error(ec, "recursive_mutex lock failed");
|
||||
}
|
||||
|
||||
void
|
||||
recursive_mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
int e = __libcpp_recursive_mutex_unlock(&__m_);
|
||||
(void)e;
|
||||
_LIBCPP_ASSERT(e == 0, "call to recursive_mutex::unlock() failed");
|
||||
}
|
||||
|
||||
bool
|
||||
recursive_mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
return __libcpp_recursive_mutex_trylock(&__m_);
|
||||
}
|
||||
|
||||
// timed_mutex
|
||||
|
||||
timed_mutex::timed_mutex()
|
||||
: __locked_(false)
|
||||
{
|
||||
}
|
||||
|
||||
timed_mutex::~timed_mutex()
|
||||
{
|
||||
lock_guard<mutex> _(__m_);
|
||||
}
|
||||
|
||||
void
|
||||
timed_mutex::lock()
|
||||
{
|
||||
unique_lock<mutex> lk(__m_);
|
||||
while (__locked_)
|
||||
__cv_.wait(lk);
|
||||
__locked_ = true;
|
||||
}
|
||||
|
||||
bool
|
||||
timed_mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
unique_lock<mutex> lk(__m_, try_to_lock);
|
||||
if (lk.owns_lock() && !__locked_)
|
||||
{
|
||||
__locked_ = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
timed_mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
lock_guard<mutex> _(__m_);
|
||||
__locked_ = false;
|
||||
__cv_.notify_one();
|
||||
}
|
||||
|
||||
// recursive_timed_mutex
|
||||
|
||||
recursive_timed_mutex::recursive_timed_mutex()
|
||||
: __count_(0),
|
||||
__id_{}
|
||||
{
|
||||
}
|
||||
|
||||
recursive_timed_mutex::~recursive_timed_mutex()
|
||||
{
|
||||
lock_guard<mutex> _(__m_);
|
||||
}
|
||||
|
||||
void
|
||||
recursive_timed_mutex::lock()
|
||||
{
|
||||
__thread_id id = this_thread::get_id();
|
||||
unique_lock<mutex> lk(__m_);
|
||||
if (id ==__id_)
|
||||
{
|
||||
if (__count_ == numeric_limits<size_t>::max())
|
||||
__throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
|
||||
++__count_;
|
||||
return;
|
||||
}
|
||||
while (__count_ != 0)
|
||||
__cv_.wait(lk);
|
||||
__count_ = 1;
|
||||
__id_ = id;
|
||||
}
|
||||
|
||||
bool
|
||||
recursive_timed_mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
__thread_id id = this_thread::get_id();
|
||||
unique_lock<mutex> lk(__m_, try_to_lock);
|
||||
if (lk.owns_lock() && (__count_ == 0 || id == __id_))
|
||||
{
|
||||
if (__count_ == numeric_limits<size_t>::max())
|
||||
return false;
|
||||
++__count_;
|
||||
__id_ = id;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
recursive_timed_mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
unique_lock<mutex> lk(__m_);
|
||||
if (--__count_ == 0)
|
||||
{
|
||||
__id_.__reset();
|
||||
lk.unlock();
|
||||
__cv_.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
// If dispatch_once_f ever handles C++ exceptions, and if one can get to it
|
||||
// without illegal macros (unexpected macros not beginning with _UpperCase or
|
||||
// __lowercase), and if it stops spinning waiting threads, then call_once should
|
||||
// call into dispatch_once_f instead of here. Relevant radar this code needs to
|
||||
// keep in sync with: 7741191.
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
|
||||
_LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
|
||||
#endif
|
||||
|
||||
void __call_once(volatile once_flag::_State_type& flag, void* arg,
|
||||
void (*func)(void*))
|
||||
{
|
||||
#if defined(_LIBCPP_HAS_NO_THREADS)
|
||||
if (flag == 0)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
flag = 1;
|
||||
func(arg);
|
||||
flag = ~once_flag::_State_type(0);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
flag = 0;
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
__libcpp_mutex_lock(&mut);
|
||||
while (flag == 1)
|
||||
__libcpp_condvar_wait(&cv, &mut);
|
||||
if (flag == 0)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__libcpp_relaxed_store(&flag, once_flag::_State_type(1));
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
func(arg);
|
||||
__libcpp_mutex_lock(&mut);
|
||||
__libcpp_atomic_store(&flag, ~once_flag::_State_type(0),
|
||||
_AO_Release);
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
__libcpp_condvar_broadcast(&cv);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__libcpp_mutex_lock(&mut);
|
||||
__libcpp_relaxed_store(&flag, once_flag::_State_type(0));
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
__libcpp_condvar_broadcast(&cv);
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
else
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
4
third_party/libcxx/new
vendored
4
third_party/libcxx/new
vendored
|
@ -95,10 +95,6 @@ void operator delete[](void* ptr, void*) noexcept;
|
|||
#include "third_party/libcxx/cstdlib"
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_VCRUNTIME)
|
||||
#include "third_party/libcxx/new.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
|
42
third_party/libcxx/optional.cc
vendored
Normal file
42
third_party/libcxx/optional.cc
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
// clang-format off
|
||||
//===------------------------ optional.cpp --------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/optional"
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
|
||||
|
||||
const char* bad_optional_access::what() const _NOEXCEPT {
|
||||
return "bad_optional_access";
|
||||
}
|
||||
|
||||
} // std
|
||||
|
||||
|
||||
#include "third_party/libcxx/experimental/__config"
|
||||
|
||||
// Preserve std::experimental::bad_optional_access for ABI compatibility
|
||||
// Even though it no longer exists in a header file
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
|
||||
: public std::logic_error
|
||||
{
|
||||
public:
|
||||
bad_optional_access() : std::logic_error("Bad optional Access") {}
|
||||
|
||||
// Get the key function ~bad_optional_access() into the dylib
|
||||
virtual ~bad_optional_access() _NOEXCEPT;
|
||||
};
|
||||
|
||||
bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
11
third_party/libcxx/random.cc
vendored
11
third_party/libcxx/random.cc
vendored
|
@ -8,19 +8,8 @@
|
|||
|
||||
#include "libc/rand/rand.h"
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if defined(_LIBCPP_USING_WIN32_RANDOM)
|
||||
// Must be defined before including stdlib.h to enable rand_s().
|
||||
#define _CRT_RAND_S
|
||||
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
|
||||
|
||||
#include "third_party/libcxx/random"
|
||||
#include "third_party/libcxx/system_error"
|
||||
|
||||
#if defined(__sun__)
|
||||
#define rename solaris_headers_are_broken
|
||||
#endif // defined(__sun__)
|
||||
|
||||
#include "third_party/libcxx/errno.h"
|
||||
#include "third_party/libcxx/stdio.h"
|
||||
#include "third_party/libcxx/stdlib.h"
|
||||
|
|
322
third_party/libcxx/stack
vendored
Normal file
322
third_party/libcxx/stack
vendored
Normal file
|
@ -0,0 +1,322 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===---------------------------- stack -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_STACK
|
||||
#define _LIBCPP_STACK
|
||||
|
||||
/*
|
||||
stack synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class T, class Container = deque<T>>
|
||||
class stack
|
||||
{
|
||||
public:
|
||||
typedef Container container_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename container_type::reference reference;
|
||||
typedef typename container_type::const_reference const_reference;
|
||||
typedef typename container_type::size_type size_type;
|
||||
|
||||
protected:
|
||||
container_type c;
|
||||
|
||||
public:
|
||||
stack() = default;
|
||||
~stack() = default;
|
||||
|
||||
stack(const stack& q) = default;
|
||||
stack(stack&& q) = default;
|
||||
|
||||
stack& operator=(const stack& q) = default;
|
||||
stack& operator=(stack&& q) = default;
|
||||
|
||||
explicit stack(const container_type& c);
|
||||
explicit stack(container_type&& c);
|
||||
template <class Alloc> explicit stack(const Alloc& a);
|
||||
template <class Alloc> stack(const container_type& c, const Alloc& a);
|
||||
template <class Alloc> stack(container_type&& c, const Alloc& a);
|
||||
template <class Alloc> stack(const stack& c, const Alloc& a);
|
||||
template <class Alloc> stack(stack&& c, const Alloc& a);
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
reference top();
|
||||
const_reference top() const;
|
||||
|
||||
void push(const value_type& x);
|
||||
void push(value_type&& x);
|
||||
template <class... Args> reference emplace(Args&&... args); // reference in C++17
|
||||
void pop();
|
||||
|
||||
void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
|
||||
};
|
||||
|
||||
template<class Container>
|
||||
stack(Container) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template<class Container, class Allocator>
|
||||
stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template <class T, class Container>
|
||||
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
|
||||
template <class T, class Container>
|
||||
void swap(stack<T, Container>& x, stack<T, Container>& y)
|
||||
noexcept(noexcept(x.swap(y)));
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/deque"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
|
||||
|
||||
template <class _Tp, class _Container /*= deque<_Tp>*/>
|
||||
class _LIBCPP_TEMPLATE_VIS stack
|
||||
{
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename container_type::reference reference;
|
||||
typedef typename container_type::const_reference const_reference;
|
||||
typedef typename container_type::size_type size_type;
|
||||
static_assert((is_same<_Tp, value_type>::value), "" );
|
||||
|
||||
protected:
|
||||
container_type c;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
|
||||
: c() {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(const stack& __q) : c(__q.c) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack& operator=(const stack& __q) {c = __q.c; return *this;}
|
||||
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(stack&& __q)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
|
||||
: c(_VSTD::move(__q.c)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack& operator=(stack&& __q)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
|
||||
{c = _VSTD::move(__q.c); return *this;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(const container_type& __c) : c(__c) {}
|
||||
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
: c(__a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(const container_type& __c, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
: c(__c, __a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(const stack& __s, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
: c(__s.c, __a) {}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(container_type&& __c, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
: c(_VSTD::move(__c), __a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(stack&& __s, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
: c(_VSTD::move(__s.c), __a) {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return c.empty();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return c.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference top() {return c.back();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference top() const {return c.back();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void push(const value_type& __v) {c.push_back(__v);}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#endif
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void pop() {c.pop_back();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(stack& __s)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(c, __s.c);
|
||||
}
|
||||
|
||||
template <class T1, class _C1>
|
||||
friend
|
||||
bool
|
||||
operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
||||
|
||||
template <class T1, class _C1>
|
||||
friend
|
||||
bool
|
||||
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Container,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
>
|
||||
stack(_Container)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
|
||||
template<class _Container,
|
||||
class _Alloc,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
|
||||
class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
|
||||
>
|
||||
stack(_Container, _Alloc)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return __x.c == __y.c;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return __x.c < __y.c;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<
|
||||
__is_swappable<_Container>::value,
|
||||
void
|
||||
>::type
|
||||
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container, class _Alloc>
|
||||
struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
|
||||
: public uses_allocator<_Container, _Alloc>
|
||||
{
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STACK
|
421
third_party/libcxx/thread
vendored
Normal file
421
third_party/libcxx/thread
vendored
Normal file
|
@ -0,0 +1,421 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- thread -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_THREAD
|
||||
#define _LIBCPP_THREAD
|
||||
|
||||
/*
|
||||
|
||||
thread synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
class thread
|
||||
{
|
||||
public:
|
||||
class id;
|
||||
typedef pthread_t native_handle_type;
|
||||
|
||||
thread() noexcept;
|
||||
template <class F, class ...Args> explicit thread(F&& f, Args&&... args);
|
||||
~thread();
|
||||
|
||||
thread(const thread&) = delete;
|
||||
thread(thread&& t) noexcept;
|
||||
|
||||
thread& operator=(const thread&) = delete;
|
||||
thread& operator=(thread&& t) noexcept;
|
||||
|
||||
void swap(thread& t) noexcept;
|
||||
|
||||
bool joinable() const noexcept;
|
||||
void join();
|
||||
void detach();
|
||||
id get_id() const noexcept;
|
||||
native_handle_type native_handle();
|
||||
|
||||
static unsigned hardware_concurrency() noexcept;
|
||||
};
|
||||
|
||||
void swap(thread& x, thread& y) noexcept;
|
||||
|
||||
class thread::id
|
||||
{
|
||||
public:
|
||||
id() noexcept;
|
||||
};
|
||||
|
||||
bool operator==(thread::id x, thread::id y) noexcept;
|
||||
bool operator!=(thread::id x, thread::id y) noexcept;
|
||||
bool operator< (thread::id x, thread::id y) noexcept;
|
||||
bool operator<=(thread::id x, thread::id y) noexcept;
|
||||
bool operator> (thread::id x, thread::id y) noexcept;
|
||||
bool operator>=(thread::id x, thread::id y) noexcept;
|
||||
|
||||
template<class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& out, thread::id id);
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
|
||||
thread::id get_id() noexcept;
|
||||
|
||||
void yield() noexcept;
|
||||
|
||||
template <class Clock, class Duration>
|
||||
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
|
||||
|
||||
template <class Rep, class Period>
|
||||
void sleep_for(const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
} // this_thread
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/iosfwd"
|
||||
#include "third_party/libcxx/__functional_base"
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/cstddef"
|
||||
#include "third_party/libcxx/functional"
|
||||
#include "third_party/libcxx/memory"
|
||||
#include "third_party/libcxx/system_error"
|
||||
#include "third_party/libcxx/chrono"
|
||||
#include "third_party/libcxx/__mutex_base"
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
#include "third_party/libcxx/tuple"
|
||||
#endif
|
||||
#include "third_party/libcxx/__threading_support"
|
||||
#include "third_party/libcxx/__debug"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
||||
#error <thread> is not supported on this single threaded system
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp> class __thread_specific_ptr;
|
||||
class _LIBCPP_TYPE_VIS __thread_struct;
|
||||
class _LIBCPP_HIDDEN __thread_struct_imp;
|
||||
class __assoc_sub_state;
|
||||
|
||||
_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
|
||||
|
||||
class _LIBCPP_TYPE_VIS __thread_struct
|
||||
{
|
||||
__thread_struct_imp* __p_;
|
||||
|
||||
__thread_struct(const __thread_struct&);
|
||||
__thread_struct& operator=(const __thread_struct&);
|
||||
public:
|
||||
__thread_struct();
|
||||
~__thread_struct();
|
||||
|
||||
void notify_all_at_thread_exit(condition_variable*, mutex*);
|
||||
void __make_ready_at_thread_exit(__assoc_sub_state*);
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class __thread_specific_ptr
|
||||
{
|
||||
__libcpp_tls_key __key_;
|
||||
|
||||
// Only __thread_local_data() may construct a __thread_specific_ptr
|
||||
// and only with _Tp == __thread_struct.
|
||||
static_assert((is_same<_Tp, __thread_struct>::value), "");
|
||||
__thread_specific_ptr();
|
||||
friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data();
|
||||
|
||||
__thread_specific_ptr(const __thread_specific_ptr&);
|
||||
__thread_specific_ptr& operator=(const __thread_specific_ptr&);
|
||||
|
||||
_LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
|
||||
|
||||
public:
|
||||
typedef _Tp* pointer;
|
||||
|
||||
~__thread_specific_ptr();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer get() const {return static_cast<_Tp*>(__libcpp_tls_get(__key_));}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator*() const {return *get();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return get();}
|
||||
void set_pointer(pointer __p);
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
void _LIBCPP_TLS_DESTRUCTOR_CC
|
||||
__thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
|
||||
{
|
||||
delete static_cast<pointer>(__p);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
__thread_specific_ptr<_Tp>::__thread_specific_ptr()
|
||||
{
|
||||
int __ec =
|
||||
__libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
|
||||
if (__ec)
|
||||
__throw_system_error(__ec, "__thread_specific_ptr construction failed");
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
__thread_specific_ptr<_Tp>::~__thread_specific_ptr()
|
||||
{
|
||||
// __thread_specific_ptr is only created with a static storage duration
|
||||
// so this destructor is only invoked during program termination. Invoking
|
||||
// pthread_key_delete(__key_) may prevent other threads from deleting their
|
||||
// thread local data. For this reason we leak the key.
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
void
|
||||
__thread_specific_ptr<_Tp>::set_pointer(pointer __p)
|
||||
{
|
||||
_LIBCPP_ASSERT(get() == nullptr,
|
||||
"Attempting to overwrite thread local data");
|
||||
__libcpp_tls_set(__key_, __p);
|
||||
}
|
||||
|
||||
template<>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
|
||||
: public unary_function<__thread_id, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(__thread_id __v) const _NOEXCEPT
|
||||
{
|
||||
return hash<__libcpp_thread_id>()(__v.__id_);
|
||||
}
|
||||
};
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id)
|
||||
{return __os << __id.__id_;}
|
||||
|
||||
class _LIBCPP_TYPE_VIS thread
|
||||
{
|
||||
__libcpp_thread_t __t_;
|
||||
|
||||
thread(const thread&);
|
||||
thread& operator=(const thread&);
|
||||
public:
|
||||
typedef __thread_id id;
|
||||
typedef __libcpp_thread_t native_handle_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Fp, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<typename __uncvref<_Fp>::type, thread>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
explicit thread(_Fp&& __f, _Args&&... __args);
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
template <class _Fp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
explicit thread(_Fp __f);
|
||||
#endif
|
||||
~thread();
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = _LIBCPP_NULL_THREAD;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
thread& operator=(thread&& __t) _NOEXCEPT;
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool joinable() const _NOEXCEPT {return !__libcpp_thread_isnull(&__t_);}
|
||||
void join();
|
||||
void detach();
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
id get_id() const _NOEXCEPT {return __libcpp_thread_get_id(&__t_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
native_handle_type native_handle() _NOEXCEPT {return __t_;}
|
||||
|
||||
static unsigned hardware_concurrency() _NOEXCEPT;
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _TSp, class _Fp, class ..._Args, size_t ..._Indices>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
|
||||
{
|
||||
__invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
|
||||
}
|
||||
|
||||
template <class _Fp>
|
||||
void* __thread_proxy(void* __vp)
|
||||
{
|
||||
// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
|
||||
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
|
||||
__thread_local_data().set_pointer(_VSTD::get<0>(*__p).release());
|
||||
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
|
||||
__thread_execute(*__p, _Index());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class _Fp, class ..._Args,
|
||||
class
|
||||
>
|
||||
thread::thread(_Fp&& __f, _Args&&... __args)
|
||||
{
|
||||
typedef unique_ptr<__thread_struct> _TSPtr;
|
||||
_TSPtr __tsp(new __thread_struct);
|
||||
typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
|
||||
_VSTD::unique_ptr<_Gp> __p(
|
||||
new _Gp(std::move(__tsp),
|
||||
__decay_copy(_VSTD::forward<_Fp>(__f)),
|
||||
__decay_copy(_VSTD::forward<_Args>(__args))...));
|
||||
int __ec = __libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
|
||||
if (__ec == 0)
|
||||
__p.release();
|
||||
else
|
||||
__throw_system_error(__ec, "thread constructor failed");
|
||||
}
|
||||
|
||||
inline
|
||||
thread&
|
||||
thread::operator=(thread&& __t) _NOEXCEPT
|
||||
{
|
||||
if (!__libcpp_thread_isnull(&__t_))
|
||||
terminate();
|
||||
__t_ = __t.__t_;
|
||||
__t.__t_ = _LIBCPP_NULL_THREAD;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Fp>
|
||||
struct __thread_invoke_pair {
|
||||
// This type is used to pass memory for thread local storage and a functor
|
||||
// to a newly created thread because std::pair doesn't work with
|
||||
// std::unique_ptr in C++03.
|
||||
__thread_invoke_pair(_Fp& __f) : __tsp_(new __thread_struct), __fn_(__f) {}
|
||||
unique_ptr<__thread_struct> __tsp_;
|
||||
_Fp __fn_;
|
||||
};
|
||||
|
||||
template <class _Fp>
|
||||
void* __thread_proxy_cxx03(void* __vp)
|
||||
{
|
||||
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
|
||||
__thread_local_data().set_pointer(__p->__tsp_.release());
|
||||
(__p->__fn_)();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class _Fp>
|
||||
thread::thread(_Fp __f)
|
||||
{
|
||||
|
||||
typedef __thread_invoke_pair<_Fp> _InvokePair;
|
||||
typedef std::unique_ptr<_InvokePair> _PairPtr;
|
||||
_PairPtr __pp(new _InvokePair(__f));
|
||||
int __ec = __libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
|
||||
if (__ec == 0)
|
||||
__pp.release();
|
||||
else
|
||||
__throw_system_error(__ec, "thread constructor failed");
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);}
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
|
||||
_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);
|
||||
|
||||
template <class _Rep, class _Period>
|
||||
void
|
||||
sleep_for(const chrono::duration<_Rep, _Period>& __d)
|
||||
{
|
||||
using namespace chrono;
|
||||
if (__d > duration<_Rep, _Period>::zero())
|
||||
{
|
||||
#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
|
||||
// GCC's long double const folding is incomplete for IBM128 long doubles.
|
||||
_LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max();
|
||||
#else
|
||||
_LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ;
|
||||
#endif
|
||||
nanoseconds __ns;
|
||||
if (__d < _Max)
|
||||
{
|
||||
__ns = duration_cast<nanoseconds>(__d);
|
||||
if (__ns < __d)
|
||||
++__ns;
|
||||
}
|
||||
else
|
||||
__ns = nanoseconds::max();
|
||||
sleep_for(__ns);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Clock, class _Duration>
|
||||
void
|
||||
sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
using namespace chrono;
|
||||
mutex __mut;
|
||||
condition_variable __cv;
|
||||
unique_lock<mutex> __lk(__mut);
|
||||
while (_Clock::now() < __t)
|
||||
__cv.wait_until(__lk, __t);
|
||||
}
|
||||
|
||||
template <class _Duration>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
|
||||
{
|
||||
using namespace chrono;
|
||||
sleep_for(__t - steady_clock::now());
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void yield() _NOEXCEPT {__libcpp_thread_yield();}
|
||||
|
||||
} // this_thread
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_THREAD
|
2
third_party/libcxx/typeinfo
vendored
2
third_party/libcxx/typeinfo
vendored
|
@ -69,7 +69,7 @@ public:
|
|||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_VCRUNTIME)
|
||||
#include "third_party/libcxx/vcruntime_typeinfo.h"
|
||||
//#include "third_party/libcxx/vcruntime_typeinfo.h"
|
||||
#else
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
|
|
1669
third_party/libcxx/variant
vendored
Normal file
1669
third_party/libcxx/variant
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
third_party/python/Modules/posixmodule.c
vendored
1
third_party/python/Modules/posixmodule.c
vendored
|
@ -12,6 +12,7 @@
|
|||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/makedev.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/calls/struct/stat.macros.h"
|
||||
#include "libc/calls/struct/tms.h"
|
||||
#include "libc/calls/struct/utsname.h"
|
||||
|
|
118
third_party/python/pyconfig.h
vendored
118
third_party/python/pyconfig.h
vendored
|
@ -50,7 +50,7 @@
|
|||
/* #undef HAVE_CONFSTR */
|
||||
|
||||
/* Define to 1 if you have the `ctermid' function. */
|
||||
/* #undef HAVE_CTERMID */
|
||||
#define HAVE_CTERMID 1
|
||||
|
||||
/* Define if you have the 'ctermid_r' function. */
|
||||
/* #undef HAVE_CTERMID_R */
|
||||
|
@ -217,9 +217,6 @@
|
|||
/* Define to 1 if you have the `ieee' library (-lieee). */
|
||||
/* #undef HAVE_LIBIEEE */
|
||||
|
||||
/* Define if you have the readline library (-lreadline). */
|
||||
/* #undef HAVE_LIBREADLINE */
|
||||
|
||||
/* Define to 1 if you have the `resolv' library (-lresolv). */
|
||||
/* #undef HAVE_LIBRESOLV */
|
||||
|
||||
|
@ -240,68 +237,17 @@
|
|||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMRCHR 1
|
||||
|
||||
/* /\* #undef HAVE_RL_APPEND_HISTORY *\/ */
|
||||
/* /\* #undef HAVE_RL_CALLBACK *\/ */
|
||||
/* #define HAVE_RL_CATCH_SIGNAL 1 */
|
||||
/* #define HAVE_RL_COMPLETION_APPEND_CHARACTER 1 */
|
||||
/* #define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1 */
|
||||
/* /\* #undef HAVE_RL_COMPLETION_MATCHES *\/ */
|
||||
/* #define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 */
|
||||
/* #define HAVE_RL_PRE_INPUT_HOOK 1 */
|
||||
/* /\* #undef HAVE_RL_RESIZE_TERMINAL *\/ */
|
||||
|
||||
/* Define to 1 if you have the `sched_get_priority_max' function. */
|
||||
/* #undef HAVE_SCHED_GET_PRIORITY_MAX */
|
||||
|
||||
/* Define to 1 if you have the `sched_rr_get_interval' function. */
|
||||
/* #undef HAVE_SCHED_RR_GET_INTERVAL */
|
||||
|
||||
/* #undef HAVE_SEM_GETVALUE */
|
||||
/* #undef HAVE_SEM_OPEN */
|
||||
/* #undef HAVE_SEM_TIMEDWAIT */
|
||||
/* #undef HAVE_SEM_UNLINK */
|
||||
|
||||
#define HAVE_SELECT 1
|
||||
#define HAVE_SENDFILE 1
|
||||
#define HAVE_SETEGID 1
|
||||
#define HAVE_SETEUID 1
|
||||
#define HAVE_SETGID 1
|
||||
#define HAVE_SETHOSTNAME 1
|
||||
#define HAVE_SETITIMER 1
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_SETPGID 1
|
||||
#define HAVE_SETPRIORITY 1
|
||||
#define HAVE_UTIMENSAT 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_WAIT 1
|
||||
#define HAVE_WAIT3 1
|
||||
#define HAVE_WAIT4 1
|
||||
#define HAVE_WAITPID 1
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_SYMLINKAT 1
|
||||
#define HAVE_SYNC 1
|
||||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_TCGETPGRP 1
|
||||
#define HAVE_TCSETPGRP 1
|
||||
#define HAVE_TEMPNAM 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_TIMES 1
|
||||
#define HAVE_TMPFILE 1
|
||||
#define HAVE_UNAME 1
|
||||
#define HAVE_UNLINKAT 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_TRUNCATE 1
|
||||
#define HAVE_SETREGID 1
|
||||
#define HAVE_SETRESGID 1
|
||||
#define HAVE_SETRESUID 1
|
||||
#define HAVE_SETREUID 1
|
||||
#define HAVE_SETSID 1
|
||||
#define HAVE_SETUID 1
|
||||
#define HAVE_SETVBUF 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SIGINTERRUPT 1
|
||||
#define HAVE_SOCKADDR_STORAGE 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_GETPPID 1
|
||||
#define HAVE_LINK 1
|
||||
#define HAVE_LINKAT 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_LUTIMES 1
|
||||
#define HAVE_MKFIFO 1
|
||||
#define HAVE_MKFIFOAT 1
|
||||
#define HAVE_MKNOD 1
|
||||
|
@ -311,10 +257,6 @@
|
|||
#define HAVE_NICE 1
|
||||
#define HAVE_OPENAT 1
|
||||
#define HAVE_PATHCONF 1
|
||||
#define HAVE_LINK 1
|
||||
#define HAVE_LINKAT 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_LUTIMES 1
|
||||
#define HAVE_PAUSE 1
|
||||
#define HAVE_PIPE 1
|
||||
#define HAVE_PIPE2 1
|
||||
|
@ -328,7 +270,47 @@
|
|||
#define HAVE_READV 1
|
||||
#define HAVE_REALPATH 1
|
||||
#define HAVE_RENAMEAT 1
|
||||
#define HAVE_SELECT 1
|
||||
#define HAVE_SENDFILE 1
|
||||
#define HAVE_SETEGID 1
|
||||
#define HAVE_SETEUID 1
|
||||
#define HAVE_SETGID 1
|
||||
#define HAVE_SETHOSTNAME 1
|
||||
#define HAVE_SETITIMER 1
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_SETPGID 1
|
||||
#define HAVE_SETPRIORITY 1
|
||||
#define HAVE_SETREGID 1
|
||||
#define HAVE_SETRESGID 1
|
||||
#define HAVE_SETRESUID 1
|
||||
#define HAVE_SETREUID 1
|
||||
#define HAVE_SETSID 1
|
||||
#define HAVE_SETUID 1
|
||||
#define HAVE_SETVBUF 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SIGALTSTACK 1
|
||||
#define HAVE_SIGINTERRUPT 1
|
||||
#define HAVE_SOCKADDR_STORAGE 1
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_SYMLINKAT 1
|
||||
#define HAVE_SYNC 1
|
||||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_TCGETPGRP 1
|
||||
#define HAVE_TCSETPGRP 1
|
||||
#define HAVE_TEMPNAM 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_TIMES 1
|
||||
#define HAVE_TMPFILE 1
|
||||
#define HAVE_TRUNCATE 1
|
||||
#define HAVE_UNAME 1
|
||||
#define HAVE_UNLINKAT 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_UTIMENSAT 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_WAIT 1
|
||||
#define HAVE_WAIT3 1
|
||||
#define HAVE_WAIT4 1
|
||||
#define HAVE_WAITPID 1
|
||||
|
||||
/* #define HAVE_MREMAP 1 */
|
||||
/* #undef HAVE_PLOCK */
|
||||
|
@ -563,9 +545,11 @@
|
|||
/* Define if `unsetenv` does not return an int. */
|
||||
/* #undef HAVE_BROKEN_UNSETENV */
|
||||
|
||||
#define HAVE_SCHED_SETAFFINITY 1
|
||||
/* #define HAVE_SCHED_SETPARAM 1 */
|
||||
/* #define HAVE_SCHED_SETSCHEDULER 1 */
|
||||
#define HAVE_SCHED_SETAFFINITY 1
|
||||
#define HAVE_SCHED_SETPARAM 1
|
||||
#define HAVE_SCHED_SETSCHEDULER 1
|
||||
#define HAVE_SCHED_GET_PRIORITY_MAX 1
|
||||
#define HAVE_SCHED_RR_GET_INTERVAL 1
|
||||
|
||||
#define Py_NSIG 32
|
||||
#define HAVE_SYSTEM 1
|
||||
|
|
Loading…
Reference in a new issue