Skip to content

Commit dbf12c3

Browse files
committed
Make more compatibility improvements
1 parent 11ec60d commit dbf12c3

32 files changed

+158
-16
lines changed

libc/fmt/strerror.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
19-
#include "libc/intrin/safemacros.internal.h"
2019
#include "libc/dce.h"
2120
#include "libc/fmt/fmt.h"
21+
#include "libc/intrin/safemacros.internal.h"
22+
#include "libc/str/errfun.h"
2223
#include "libc/str/str.h"
2324

2425
/**

libc/intrin/describefutexresult.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/fmt/itoa.h"
2020
#include "libc/intrin/describeflags.internal.h"
21-
#include "libc/str/str.h"
21+
#include "libc/str/errfun.h"
2222

2323
const char *(DescribeFutexResult)(char buf[12], int ax) {
2424
const char *s;

libc/intrin/pthread.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#define PTHREAD_ONCE_INIT 0
55

6-
#define PTHREAD_KEYS_MAX 64
6+
#define PTHREAD_KEYS_MAX 64
7+
#define PTHREAD_STACK_MIN 2048
8+
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
79

810
#define PTHREAD_BARRIER_SERIAL_THREAD 31337
911

libc/intrin/strerrno.greg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/fmt/magnumstrs.internal.h"
20-
#include "libc/str/str.h"
20+
#include "libc/str/errfun.h"
2121

2222
/**
2323
* Converts errno value to symbolic name.

libc/intrin/strerror_wr.greg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "libc/nt/enum/formatmessageflags.h"
2525
#include "libc/nt/enum/lang.h"
2626
#include "libc/nt/process.h"
27+
#include "libc/str/errfun.h"
2728
#include "libc/str/str.h"
2829

2930
/**

libc/isystem/limits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#ifndef LIBC_ISYSTEM_LIMITS_H_
22
#define LIBC_ISYSTEM_LIMITS_H_
3+
#include "libc/intrin/pthread.h"
34
#include "libc/limits.h"
45
#include "libc/sysv/consts/_posix.h"
6+
#include "libc/sysv/consts/iov.h"
7+
#include "libc/sysv/consts/limits.h"
8+
#include "libc/sysv/consts/xopen.h"
59
#endif

libc/isystem/unistd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define LIBC_ISYSTEM_UNISTD_H_
33
#include "libc/calls/calls.h"
44
#include "libc/calls/weirdtypes.h"
5+
#include "libc/runtime/pathconf.h"
56
#include "libc/runtime/sysconf.h"
67
#include "libc/sysv/consts/fileno.h"
78
#include "libc/sysv/consts/o.h"

libc/limits.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define INTMAX_MAX __INTMAX_MAX__
3737
#define UINTMAX_MAX __UINTMAX_MAX__
3838

39+
extern int __got_long_min;
3940
#define SCHAR_MIN (-SCHAR_MAX - 1)
4041
#define SHRT_MIN (-SHRT_MAX - 1)
4142
#define INT_MIN (-INT_MAX - 1)
@@ -90,4 +91,21 @@
9091
#define SIG_ATOMIC_MIN INT32_MIN
9192
#define SIG_ATOMIC_MAX INT32_MAX
9293

94+
#define FILESIZEBITS 64
95+
#define SYMLOOP_MAX 40
96+
#define TTY_NAME_MAX 32
97+
#define HOST_NAME_MAX 255
98+
#define TZNAME_MAX 6
99+
#define WORD_BIT 32
100+
#define SEM_VALUE_MAX 0x7fffffff
101+
#define SEM_NSEMS_MAX 256
102+
#define DELAYTIMER_MAX 0x7fffffff
103+
#define MQ_PRIO_MAX 32768
104+
#define LOGIN_NAME_MAX 256
105+
106+
#define NL_ARGMAX 9
107+
#define NL_MSGMAX 32767
108+
#define NL_SETMAX 255
109+
#define NL_TEXTMAX 2048
110+
93111
#endif /* COSMOPOLITAN_LIBC_LIMITS_H_ */

libc/runtime/fpathconf.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
2+
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
3+
╞══════════════════════════════════════════════════════════════════════════════╡
4+
│ Copyright 2022 Justine Alexandra Roberts Tunney │
5+
│ │
6+
│ Permission to use, copy, modify, and/or distribute this software for │
7+
│ any purpose with or without fee is hereby granted, provided that the │
8+
│ above copyright notice and this permission notice appear in all copies. │
9+
│ │
10+
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
11+
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
12+
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
13+
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
14+
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
15+
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
16+
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
17+
│ PERFORMANCE OF THIS SOFTWARE. │
18+
╚─────────────────────────────────────────────────────────────────────────────*/
19+
#include "libc/errno.h"
20+
#include "libc/limits.h"
21+
#include "libc/runtime/pathconf.h"
22+
#include "libc/sysv/consts/_posix.h"
23+
#include "libc/sysv/consts/limits.h"
24+
#include "libc/sysv/errfuns.h"
25+
26+
long fpathconf(int fd, int name) {
27+
if (name == _PC_LINK_MAX) return _POSIX_LINK_MAX;
28+
if (name == _PC_MAX_CANON) return _POSIX_MAX_CANON;
29+
if (name == _PC_MAX_INPUT) return _POSIX_MAX_INPUT;
30+
if (name == _PC_NAME_MAX) return NAME_MAX;
31+
if (name == _PC_PATH_MAX) return PATH_MAX;
32+
if (name == _PC_PIPE_BUF) return PIPE_BUF;
33+
if (name == _PC_CHOWN_RESTRICTED) return 1;
34+
if (name == _PC_NO_TRUNC) return 1;
35+
if (name == _PC_VDISABLE) return 0;
36+
if (name == _PC_SYNC_IO) return 1;
37+
if (name == _PC_ASYNC_IO) return -1;
38+
if (name == _PC_PRIO_IO) return -1;
39+
if (name == _PC_SOCK_MAXBUF) return -1;
40+
if (name == _PC_FILESIZEBITS) return FILESIZEBITS;
41+
if (name == _PC_REC_INCR_XFER_SIZE) return 4096;
42+
if (name == _PC_REC_MAX_XFER_SIZE) return 4096;
43+
if (name == _PC_REC_MIN_XFER_SIZE) return 4096;
44+
if (name == _PC_REC_XFER_ALIGN) return 4096;
45+
if (name == _PC_ALLOC_SIZE_MIN) return 4096;
46+
if (name == _PC_SYMLINK_MAX) return -1;
47+
if (name == _PC_2_SYMLINKS) return 1;
48+
return einval();
49+
}
50+
51+
long pathconf(const char *path, int name) {
52+
return fpathconf(-1, name);
53+
}

libc/runtime/pathconf.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef COSMOPOLITAN_LIBC_RUNTIME_PATHCONF_H_
2+
#define COSMOPOLITAN_LIBC_RUNTIME_PATHCONF_H_
3+
4+
#define _PC_LINK_MAX 0
5+
#define _PC_MAX_CANON 1
6+
#define _PC_MAX_INPUT 2
7+
#define _PC_NAME_MAX 3
8+
#define _PC_PATH_MAX 4
9+
#define _PC_PIPE_BUF 5
10+
#define _PC_CHOWN_RESTRICTED 6
11+
#define _PC_NO_TRUNC 7
12+
#define _PC_VDISABLE 8
13+
#define _PC_SYNC_IO 9
14+
#define _PC_ASYNC_IO 10
15+
#define _PC_PRIO_IO 11
16+
#define _PC_SOCK_MAXBUF 12
17+
#define _PC_FILESIZEBITS 13
18+
#define _PC_REC_INCR_XFER_SIZE 14
19+
#define _PC_REC_MAX_XFER_SIZE 15
20+
#define _PC_REC_MIN_XFER_SIZE 16
21+
#define _PC_REC_XFER_ALIGN 17
22+
#define _PC_ALLOC_SIZE_MIN 18
23+
#define _PC_SYMLINK_MAX 19
24+
#define _PC_2_SYMLINKS 20
25+
26+
#if !(__ASSEMBLER__ + __LINKER__ + 0)
27+
COSMOPOLITAN_C_START_
28+
29+
long fpathconf(int, int);
30+
long pathconf(const char *, int);
31+
32+
COSMOPOLITAN_C_END_
33+
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
34+
#endif /* COSMOPOLITAN_LIBC_RUNTIME_PATHCONF_H_ */

0 commit comments

Comments
 (0)