mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Make some foss compatibility improvements
This commit is contained in:
parent
8111462789
commit
5af19b7eed
34 changed files with 319 additions and 48 deletions
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/metalfile.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/pledge.internal.h"
|
||||
#include "libc/calls/struct/bpf.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
#define st_mtime_nsec st_mtim.tv_nsec
|
||||
#define st_ctime_nsec st_ctim.tv_nsec
|
||||
|
||||
#define st_atimensec st_atim.tv_nsec
|
||||
#define st_mtimensec st_mtim.tv_nsec
|
||||
#define st_ctimensec st_ctim.tv_nsec
|
||||
#define st_birthtime st_birthtim.tv_sec
|
||||
#define st_birthtimensec st_birthtim.tv_nsec
|
||||
#define st_atimensec st_atim.tv_nsec
|
||||
#define st_mtimensec st_mtim.tv_nsec
|
||||
#define st_ctimensec st_ctim.tv_nsec
|
||||
#define st_birthtime st_birthtim.tv_sec
|
||||
|
||||
#define st_file_attributes st_flags
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
#define CHAR_BIT 8 /* b/c von neumann */
|
||||
#define ARG_MAX 0xfffe /* for argv and envp; see CreateProcess (32767*2) */
|
||||
#define PATH_MAX 1024 /* b/c _XOPEN_PATH_MAX */
|
||||
#define NAME_MAX 63 /* b/c dns */
|
||||
#define NAME_MAX 255 /* 511 on netbsd */
|
||||
#define CHILD_MAX 16 /* only if malloc isn't linked */
|
||||
#define OPEN_MAX 16 /* only if malloc isn't linked */
|
||||
#define ATEXIT_MAX 32 /* only if malloc isn't linked */
|
||||
|
|
11
libc/isystem/linux/limits.h
Normal file
11
libc/isystem/linux/limits.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LINUX_LIMITS_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LINUX_LIMITS_H_
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
|
||||
#define NR_OPEN 1024
|
||||
#define XATTR_NAME_MAX 255
|
||||
#define XATTR_SIZE_MAX 65536
|
||||
#define XATTR_LIST_MAX 65536
|
||||
#define RTSIG_MAX 32
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LINUX_LIMITS_H_ */
|
25
libc/isystem/linux/types.h
Normal file
25
libc/isystem/linux/types.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LINUX_TYPES_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_LINUX_TYPES_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
typedef uint16_t __u16;
|
||||
typedef uint32_t __u32;
|
||||
typedef uint64_t __u64;
|
||||
|
||||
typedef __u16 __le16;
|
||||
typedef __u16 __be16;
|
||||
typedef __u32 __le32;
|
||||
typedef __u32 __be32;
|
||||
typedef __u64 __le64;
|
||||
typedef __u64 __be64;
|
||||
typedef __u16 __sum16;
|
||||
typedef __u32 __wsum;
|
||||
|
||||
#define __aligned_u64 __u64 __attribute__((__aligned__(8)))
|
||||
#define __aligned_be64 __be64 __attribute__((__aligned__(8)))
|
||||
#define __aligned_le64 __le64 __attribute__((__aligned__(8)))
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LINUX_TYPES_H_ */
|
4
libc/isystem/mntent.h
Normal file
4
libc/isystem/mntent.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_MNTENT_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_MNTENT_H_
|
||||
#include "third_party/musl/mntent.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_MNTENT_H_ */
|
|
@ -16,8 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/efi.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/nopl.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ShouldUseMsabiAttribute() 1
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -25,27 +25,6 @@ extern uint64_t kStartTsc; /* RII */
|
|||
extern char kTmpPath[]; /* RII */
|
||||
extern const char kNtSystemDirectory[]; /* RII */
|
||||
extern const char kNtWindowsDirectory[]; /* RII */
|
||||
extern unsigned char _base[]; /* αpε */
|
||||
extern unsigned char _ehead[]; /* αpε */
|
||||
extern unsigned char _etext[]; /* αpε */
|
||||
extern unsigned char _edata[]; /* αpε */
|
||||
extern unsigned char _ezip[]; /* αpε */
|
||||
extern unsigned char _end[]; /* αpε */
|
||||
extern unsigned char _ereal[]; /* αpε */
|
||||
extern unsigned char __privileged_start[]; /* αpε */
|
||||
extern unsigned char __privileged_addr[]; /* αpε */
|
||||
extern unsigned char __privileged_size[]; /* αpε */
|
||||
extern unsigned char __privileged_end[]; /* αpε */
|
||||
extern unsigned char __test_start[]; /* αpε */
|
||||
extern unsigned char __ro[]; /* αpε */
|
||||
extern unsigned char *__relo_start[]; /* αpε */
|
||||
extern unsigned char *__relo_end[]; /* αpε */
|
||||
extern uint8_t __zip_start[]; /* αpε */
|
||||
extern uint8_t __zip_end[]; /* αpε */
|
||||
extern uint8_t __data_start[]; /* αpε */
|
||||
extern uint8_t __data_end[]; /* αpε */
|
||||
extern uint8_t __bss_start[]; /* αpε */
|
||||
extern uint8_t __bss_end[]; /* αpε */
|
||||
extern size_t __virtualmax;
|
||||
extern bool __isworker;
|
||||
|
||||
|
|
24
libc/stdio/__fseterr.c
Normal file
24
libc/stdio/__fseterr.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/errno.h"
|
||||
#include "libc/stdio/stdio_ext.h"
|
||||
|
||||
void __fseterr(FILE *f) {
|
||||
f->state |= EIO;
|
||||
}
|
|
@ -19,6 +19,7 @@ int __fwriting(FILE *);
|
|||
int __fsetlocking(FILE *, int);
|
||||
void _flushlbf(void);
|
||||
void __fpurge(FILE *);
|
||||
void __fseterr(FILE *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1228,6 +1228,9 @@ syscon mount MNT_SNAPSHOT 0 0x40000000 0x01000000 0 0 0 # confusing
|
|||
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
|
||||
syscon limits PIPE_BUF 4096 512 512 512 512 4096 # bsd consensus
|
||||
syscon limits NGROUPS_MAX 65536 16 1023 16 16 0 #
|
||||
syscon limits LINK_MAX 127 32767 32767 32767 32767 64 # freebsd/windows are educated guesses
|
||||
syscon limits MAX_CANON 255 1024 255 255 255 255 # windows is guessed
|
||||
syscon limits MAX_INPUT 255 1024 255 255 255 255 # windows is guessed
|
||||
syscon limits SOMAXCONN 4096 128 128 128 128 2147483647 # maximum backlog for listen()
|
||||
syscon limits _ARG_MAX 128*1024 1024*1024 512*1024 512*1024 256*1024 32767*2 # bsd consensus
|
||||
syscon limits _NAME_MAX 255 255 255 255 511 255 # probably higher on windows?
|
||||
|
|
|
@ -11,6 +11,9 @@ extern const int _ARG_MAX;
|
|||
extern const int _NAME_MAX;
|
||||
extern const int _NSIG;
|
||||
extern const int _PATH_MAX;
|
||||
extern const int LINK_MAX;
|
||||
extern const int MAX_CANON;
|
||||
extern const int MAX_INPUT;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
@ -22,5 +25,8 @@ COSMOPOLITAN_C_END_
|
|||
#define _NAME_MAX SYMBOLIC(_NAME_MAX)
|
||||
#define _NSIG SYMBOLIC(_NSIG)
|
||||
#define _PATH_MAX SYMBOLIC(_PATH_MAX)
|
||||
#define LINK_MAX SYMBOLIC(LINK_MAX)
|
||||
#define MAX_CANON SYMBOLIC(MAX_CANON)
|
||||
#define MAX_INPUT SYMBOLIC(MAX_INPUT)
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_LIMITS_H_ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/kntprioritycombos.internal.h"
|
||||
#include "libc/errno.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/path.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -23,12 +24,14 @@
|
|||
#include "libc/thread/thread.h"
|
||||
|
||||
const char *__sem_name(const char *name, char path[hasatleast PATH_MAX]) {
|
||||
const char *res;
|
||||
if (_isabspath(name)) {
|
||||
return name;
|
||||
res = name;
|
||||
} else {
|
||||
strlcpy(path, kTmpPath, PATH_MAX);
|
||||
strlcat(path, ".sem-", PATH_MAX);
|
||||
strlcat(path, name, PATH_MAX);
|
||||
return path;
|
||||
res = path;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,12 @@ sem_t *sem_open(const char *name, int oflag, ...) {
|
|||
}
|
||||
|
||||
sem = mmap(0, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (sem != MAP_FAILED) sem->sem_pshared = true;
|
||||
if (sem != MAP_FAILED) {
|
||||
sem->sem_pshared = true;
|
||||
} else {
|
||||
sem = SEM_FAILED;
|
||||
}
|
||||
|
||||
_npassert(!close(fd));
|
||||
return sem;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue