Clean up more code

- Found some bugs in LLVM compiler-rt library
- The useless LIBC_STUBS package is now deleted
- Improve the overflow checking story even further
- Get chibicc tests working in MODE=dbg mode again
- The libc/isystem/ headers now have correctly named guards
This commit is contained in:
Justine Tunney 2023-06-18 00:55:09 -07:00
parent afc58a8b41
commit d7c79f43ef
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
294 changed files with 912 additions and 1208 deletions

View file

@ -113,8 +113,7 @@ include build/functions.mk #─┐
include build/definitions.mk # ├──META
include build/config.mk # │ You can build
include build/rules.mk # │ You can topologically order
include build/online.mk # │
include libc/stubs/stubs.mk #─┘
include build/online.mk #─┘
include libc/nexgen32e/nexgen32e.mk #─┐
include libc/sysv/sysv.mk # ├──SYSTEM SUPPORT
include libc/nt/nt.mk # │ You can do math
@ -214,7 +213,6 @@ include tool/lambda/lambda.mk
include tool/plinko/lib/lib.mk
include tool/plinko/plinko.mk
include test/tool/plinko/test.mk
include tool/hash/hash.mk
include tool/net/net.mk
include tool/viz/viz.mk
include tool/tool.mk

View file

@ -25,8 +25,7 @@ DSP_BMP_A_CHECKS = \
DSP_BMP_A_DIRECTDEPS = \
LIBC_NEXGEN32E \
LIBC_TINYMATH \
LIBC_STUBS
LIBC_TINYMATH
DSP_BMP_A_DEPS := \
$(call uniq,$(foreach x,$(DSP_BMP_A_DIRECTDEPS),$($(x))))

View file

@ -20,8 +20,7 @@ DSP_CORE_A_DIRECTDEPS = \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_STR \
LIBC_TINYMATH \
LIBC_STUBS
LIBC_TINYMATH
DSP_CORE_A_DEPS := \
$(call uniq,$(foreach x,$(DSP_CORE_A_DIRECTDEPS),$($(x))))

View file

@ -34,7 +34,6 @@ DSP_MPEG_A_DIRECTDEPS = \
LIBC_RUNTIME \
LIBC_STDIO \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_TIME \
LIBC_TINYMATH \

View file

@ -31,8 +31,6 @@ DSP_SCALE_A_DIRECTDEPS = \
LIBC_NEXGEN32E \
LIBC_RUNTIME \
LIBC_STR \
LIBC_STUBS \
LIBC_STUBS \
LIBC_TIME \
LIBC_TINYMATH \
LIBC_X

View file

@ -35,7 +35,6 @@ DSP_TTY_A_DIRECTDEPS = \
LIBC_NT_KERNEL32 \
LIBC_STR \
LIBC_STDIO \
LIBC_STUBS \
LIBC_SOCK \
LIBC_SYSV \
LIBC_TINYMATH \

View file

@ -7,10 +7,10 @@
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/calls/calls.h"
#include "libc/calls/struct/timespec.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/time/time.h"
/**
* @fileoverview clock() function demo

View file

@ -59,7 +59,6 @@ EXAMPLES_DIRECTDEPS = \
LIBC_SOCK \
LIBC_STDIO \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_SYSV_CALLS \
LIBC_TESTLIB \
@ -77,10 +76,10 @@ EXAMPLES_DIRECTDEPS = \
THIRD_PARTY_DOUBLECONVERSION \
THIRD_PARTY_GDTOA \
THIRD_PARTY_GETOPT \
THIRD_PARTY_HIREDIS \
THIRD_PARTY_LIBCXX \
THIRD_PARTY_LINENOISE \
THIRD_PARTY_LUA \
THIRD_PARTY_HIREDIS \
THIRD_PARTY_MBEDTLS \
THIRD_PARTY_MUSL \
THIRD_PARTY_NSYNC \

View file

@ -43,7 +43,6 @@ EXAMPLES_PACKAGE_DIRECTDEPS = \
EXAMPLES_PACKAGE_LIB \
LIBC_INTRIN \
LIBC_STDIO \
LIBC_STUBS \
LIBC_TINYMATH
# Evaluates the set of transitive package dependencies.

View file

@ -69,10 +69,9 @@ EXAMPLES_PACKAGE_LIB_A_CHECKS = \
# Lists packages whose symbols are or may be directly referenced here.
# Note that linking stubs is always a good idea due to synthetic code.
EXAMPLES_PACKAGE_LIB_A_DIRECTDEPS = \
LIBC_STDIO \
LIBC_INTRIN \
LIBC_NEXGEN32E \
LIBC_STUBS
LIBC_STDIO
# Evaluates variable as set of transitive package dependencies.
EXAMPLES_PACKAGE_LIB_A_DEPS := \

View file

@ -32,7 +32,6 @@
#include "libc/dns/dns.h"
#include "libc/errno.h"
#include "libc/log/bsd.h"
#include "libc/mem/fmt.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/struct/pollfd.h"

View file

@ -40,6 +40,8 @@
#define SIG_DFL ((void (*)(int))0)
#define SIG_IGN ((void (*)(int))1)
#define CLOCKS_PER_SEC 1000000L
#define MAP_FAILED ((void *)-1)
#define WCOREDUMP(s) (128 & (s))
@ -174,6 +176,8 @@ int usleep(unsigned);
int vfork(void) returnstwice;
int wait(int *);
int waitpid(int, int *, int);
int64_t clock(void);
int64_t time(int64_t *);
ssize_t copy_file_range(int, long *, int, long *, size_t, unsigned);
ssize_t lseek(int, int64_t, int);
ssize_t pread(int, void *, size_t, int64_t);
@ -183,10 +187,12 @@ ssize_t readlink(const char *, char *, size_t);
ssize_t readlinkat(int, const char *, char *, size_t);
ssize_t splice(int, int64_t *, int, int64_t *, size_t, unsigned);
ssize_t write(int, const void *, size_t);
unsigned alarm(unsigned);
unsigned getegid(void) nosideeffect;
unsigned geteuid(void) nosideeffect;
unsigned getgid(void) nosideeffect;
unsigned getuid(void) libcesque;
unsigned sleep(unsigned);
unsigned umask(unsigned);
void sync(void);

View file

@ -45,13 +45,12 @@ LIBC_CALLS_A_DIRECTDEPS = \
LIBC_NT_KERNEL32 \
LIBC_NT_NTDLL \
LIBC_NT_PDH \
LIBC_NT_PSAPI \
LIBC_NT_POWRPROF \
LIBC_NT_PSAPI \
LIBC_NT_WS2_32 \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV_CALLS \
LIBC_SYSV \
LIBC_SYSV_CALLS \
THIRD_PARTY_COMPILER_RT
LIBC_CALLS_A_DEPS := \

View file

@ -18,6 +18,7 @@
*/
#include "libc/calls/calls.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
/**
* Copies data between file descriptors the old fashioned way.
@ -43,7 +44,7 @@ ssize_t copyfd(int in, int out, size_t n) {
if (dw != dr) {
// POSIX requires atomic IO up to PIPE_BUF
// The minimum permissible PIPE_BUF is 512
__builtin_trap();
abort();
}
}
return i;

View file

@ -33,6 +33,8 @@
#include "libc/thread/tls.h"
#include "libc/time/time.h"
// TODO(jart): DELETE
static clock_gettime_f *__gettime;
static struct Now {

View file

@ -31,6 +31,8 @@
#include "libc/thread/tls.h"
#include "libc/time/time.h"
// TODO(jart): DELETE
static struct Now {
bool once;
uint64_t k0;

View file

@ -6,44 +6,44 @@
* @fileoverview Types we'd prefer hadn't been invented.
*/
#define blkcnt_t int64_t
#define cc_t uint8_t
#define clock_t int64_t /* uint64_t on xnu */
#define dev_t uint64_t /* int32_t on xnu */
#define fsblkcnt_t uint64_t
#define fsfilcnt_t int64_t /* uint32_t on xnu */
#define gid_t uint32_t
#define id_t uint32_t /* int32_t on linux/freebsd/etc. */
#define in_addr_t uint32_t
#define in_addr_t uint32_t
#define in_port_t uint16_t
#define ino_t uint64_t
#define key_t int32_t
#define loff_t int64_t
#define mode_t uint32_t /* uint16_t on xnu */
#define nfds_t uint64_t
#define off_t int64_t
#define pid_t int32_t
#define register_t int64_t
#define sa_family_t uint16_t /* bsd:uint8_t */
#define socklen_t uint32_t
#define speed_t uint32_t
#define suseconds_t int64_t /* int32_t on xnu */
#define useconds_t uint64_t /* uint32_t on xnu */
#define syscall_arg_t int64_t /* uint64_t on xnu */
#define tcflag_t uint32_t
#define time_t int64_t
#define timer_t void*
#define uid_t uint32_t
#define rlim_t uint64_t /* int64_t on bsd */
#define clockid_t int32_t
typedef int64_t blkcnt_t;
typedef uint8_t cc_t;
typedef int64_t clock_t; /* uint64_t on xnu */
typedef uint64_t dev_t; /* int32_t on xnu */
typedef uint64_t fsblkcnt_t;
typedef int64_t fsfilcnt_t; /* uint32_t on xnu */
typedef uint32_t gid_t;
typedef uint32_t id_t; /* int32_t on linux/freebsd/etc. */
typedef uint32_t in_addr_t;
typedef uint32_t in_addr_t;
typedef uint16_t in_port_t;
typedef uint64_t ino_t;
typedef int32_t key_t;
typedef int64_t loff_t;
typedef uint32_t mode_t; /* uint16_t on xnu */
typedef uint64_t nfds_t;
typedef int64_t off_t;
typedef int32_t pid_t;
typedef int64_t register_t;
typedef uint16_t sa_family_t; /* bsd:uint8_t */
typedef uint32_t socklen_t;
typedef uint32_t speed_t;
typedef int64_t suseconds_t; /* int32_t on xnu */
typedef uint64_t useconds_t; /* uint32_t on xnu */
typedef int64_t syscall_arg_t; /* uint64_t on xnu */
typedef uint32_t tcflag_t;
typedef int64_t time_t;
typedef void *timer_t;
typedef uint32_t uid_t;
typedef uint64_t rlim_t; /* int64_t on bsd */
typedef int32_t clockid_t;
#ifdef __x86_64__
#define blksize_t int64_t /* int32_t on xnu */
#define nlink_t uint64_t
typedef int64_t blksize_t; /* int32_t on xnu */
typedef uint64_t nlink_t;
#elif defined(__aarch64__)
#define blksize_t int32_t
#define nlink_t uint32_t /* uint16_t on xnu */
typedef int32_t blksize_t;
typedef uint32_t nlink_t; /* uint16_t on xnu */
#endif
#define TIME_T_MAX __INT64_MAX__

View file

@ -26,17 +26,16 @@ LIBC_DNS_A_CHECKS = \
LIBC_DNS_A_DIRECTDEPS = \
LIBC_CALLS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_NT_ADVAPI32 \
LIBC_NT_KERNEL32 \
LIBC_RUNTIME \
LIBC_SOCK \
LIBC_STDIO \
LIBC_INTRIN \
LIBC_STUBS \
LIBC_STR \
LIBC_SYSV \
LIBC_NT_ADVAPI32 \
LIBC_NT_KERNEL32
LIBC_SYSV
LIBC_DNS_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_DNS_A_DIRECTDEPS),$($(x))))

View file

@ -4,30 +4,23 @@
#include "libc/elf/struct/phdr.h"
#include "libc/elf/struct/shdr.h"
#include "libc/elf/struct/sym.h"
#include "libc/runtime/ezmap.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#ifdef COSMO
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § executable & linkable format
cosmopolitan § executable linkable format
*/
char *GetElfStringTable(const Elf64_Ehdr *, size_t);
char *GetElfStrs(const Elf64_Ehdr *, size_t, size_t *);
Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *, size_t, Elf64_Xword *);
char *GetElfStringTable(const Elf64_Ehdr *, size_t, const char *);
Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *, size_t, int, Elf64_Xword *);
bool IsElf64Binary(const Elf64_Ehdr *, size_t);
bool IsElfSymbolContent(const Elf64_Sym *);
Elf64_Phdr *GetElfSegmentHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half);
Elf64_Phdr *GetElfProgramHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half);
Elf64_Shdr *GetElfSectionHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half);
void *GetElfSectionAddress(const Elf64_Ehdr *, size_t, const Elf64_Shdr *);
char *GetElfSectionNameStringTable(const Elf64_Ehdr *, size_t);
void GetElfVirtualAddressRange(const Elf64_Ehdr *, size_t, intptr_t *,
intptr_t *);
char *GetElfString(const Elf64_Ehdr *, size_t, const char *, Elf64_Word);
const char *GetElfSectionName(const Elf64_Ehdr *, size_t, Elf64_Shdr *);
Elf64_Sym *GetElfDynSymbolTable(const Elf64_Ehdr *, size_t, Elf64_Xword *);
char *GetElfDynStringTable(const Elf64_Ehdr *, size_t);
#endif /* COSMO */
COSMOPOLITAN_C_END_

View file

@ -27,7 +27,6 @@ LIBC_ELF_A_DIRECTDEPS = \
LIBC_INTRIN \
LIBC_NEXGEN32E \
LIBC_STR \
LIBC_STUBS
LIBC_ELF_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_ELF_A_DIRECTDEPS),$($(x))))

View file

@ -1,36 +0,0 @@
/*-*- 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 2020 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/elf/def.h"
#include "libc/elf/elf.h"
#include "libc/str/str.h"
char *GetElfDynStringTable(const Elf64_Ehdr *elf, size_t mapsize) {
int i;
char *name;
Elf64_Shdr *shdr;
for (i = 0; i < elf->e_shnum; ++i) {
if ((shdr = GetElfSectionHeaderAddress(elf, mapsize, i)) &&
shdr->sh_type == SHT_STRTAB &&
(name = GetElfSectionName(elf, mapsize, shdr)) &&
!strcmp(name, ".dynstr")) {
return GetElfSectionAddress(elf, mapsize, shdr);
}
}
return 0;
}

View file

@ -1,35 +0,0 @@
/*-*- 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 2020 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/elf/def.h"
#include "libc/elf/elf.h"
Elf64_Sym *GetElfDynSymbolTable(const Elf64_Ehdr *elf, size_t mapsize,
Elf64_Xword *out_count) {
int i;
Elf64_Shdr *shdr;
for (i = elf->e_shnum; i-- > 0;) {
if ((shdr = GetElfSectionHeaderAddress(elf, mapsize, i)) && //
shdr->sh_type == SHT_DYNSYM && //
shdr->sh_entsize == sizeof(Elf64_Sym)) {
if (out_count) *out_count = shdr->sh_size / sizeof(Elf64_Sym);
return GetElfSectionAddress(elf, mapsize, shdr);
}
}
return 0;
}

View file

@ -17,16 +17,25 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/elf/elf.h"
#include "libc/stdckdint.h"
#include "libc/elf/scalar.h"
#include "libc/elf/struct/phdr.h"
Elf64_Phdr *GetElfSegmentHeaderAddress(const Elf64_Ehdr *elf, //
/**
* Returns program header at `elf.phdr[i]`.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param i is the program header index, starting at zero
* @return program header pointer, or null on error
*/
Elf64_Phdr *GetElfProgramHeaderAddress(const Elf64_Ehdr *elf, //
size_t mapsize, //
Elf64_Half i) { //
uint64_t last, addr;
uint64_t off;
if (i >= elf->e_phnum) return 0;
if (ckd_add(&addr, (uintptr_t)elf, elf->e_phoff)) return 0;
if (ckd_add(&addr, addr, (unsigned)i * elf->e_phentsize)) return 0;
if (ckd_add(&last, addr, elf->e_phentsize)) return 0;
if (last > (uintptr_t)elf + mapsize) return 0;
return (Elf64_Phdr *)addr;
if (elf->e_phoff <= 0) return 0;
if (elf->e_phoff >= mapsize) return 0;
if (elf->e_phentsize < sizeof(Elf64_Phdr)) return 0;
if ((off = elf->e_phoff + (unsigned)i * elf->e_phentsize) > mapsize) return 0;
return (Elf64_Phdr *)((char *)elf + off);
}

View file

@ -19,14 +19,23 @@
#include "libc/elf/elf.h"
#include "libc/stdckdint.h"
// note: should not be used on bss section
/**
* Returns pointer to elf section file content.
*
* This function shouldn't be used on the bss section.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param shdr is from GetElfSectionHeaderAddress() and null-propagating
* @return pointer to content bytes, or null on error
*/
void *GetElfSectionAddress(const Elf64_Ehdr *elf, // validated
size_t mapsize, // validated
const Elf64_Shdr *shdr) { // foreign
uint64_t addr, last;
uint64_t last;
if (!shdr) return 0;
if (ckd_add(&addr, (uintptr_t)elf, shdr->sh_offset)) return 0;
if (ckd_add(&last, addr, shdr->sh_size)) return 0;
if (last > (uintptr_t)elf + mapsize) return 0;
return (void *)addr;
if (shdr->sh_size <= 0) return 0;
if (ckd_add(&last, shdr->sh_offset, shdr->sh_size)) return 0;
if (last > mapsize) return 0;
return (char *)elf + shdr->sh_offset;
}

View file

@ -17,16 +17,24 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/elf/elf.h"
#include "libc/stdckdint.h"
#include "libc/elf/struct/shdr.h"
/**
* Returns section header object at `elf.section[i]`.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param i is the section header index, starting at zero
* @return section header pointer, or null on error
*/
Elf64_Shdr *GetElfSectionHeaderAddress(const Elf64_Ehdr *elf, //
size_t mapsize, //
Elf64_Half i) { //
uint64_t addr, last;
uint64_t off;
if (i >= elf->e_shnum) return 0;
if (ckd_add(&addr, (uintptr_t)elf, elf->e_shoff)) return 0;
if (ckd_add(&addr, addr, (unsigned)i * elf->e_shentsize)) return 0;
if (ckd_add(&last, addr, elf->e_shentsize)) return 0;
if (last > (uintptr_t)elf + mapsize) return 0;
return (Elf64_Shdr *)addr;
if (elf->e_shoff <= 0) return 0;
if (elf->e_shoff >= mapsize) return 0;
if (elf->e_shentsize < sizeof(Elf64_Shdr)) return 0;
if ((off = elf->e_shoff + (unsigned)i * elf->e_shentsize) > mapsize) return 0;
return (Elf64_Shdr *)((char *)elf + off);
}

View file

@ -17,9 +17,16 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/elf/elf.h"
#include "libc/elf/struct/shdr.h"
/**
* Returns section name string table.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @return double-nul terminated string list, or null on error
*/
char *GetElfSectionNameStringTable(const Elf64_Ehdr *elf, size_t mapsize) {
if (!elf->e_shoff || !elf->e_shentsize) return 0;
return GetElfSectionAddress(
elf, mapsize, GetElfSectionHeaderAddress(elf, mapsize, elf->e_shstrndx));
}

View file

@ -17,17 +17,28 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/elf/elf.h"
#include "libc/stdckdint.h"
#include "libc/elf/scalar.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/str/str.h"
/**
* Returns `strtab + i` from elf string table.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param strtab is double-nul string list from GetElfStringTable()
* @param i is byte index into strtab where needed string starts
* @return pointer to nul terminated string, or null on error
*/
char *GetElfString(const Elf64_Ehdr *elf, // validated
size_t mapsize, // validated
const char *strtab, // validated
Elf64_Word rva) { // foreign
uintptr_t addr;
if (!strtab) return 0;
if (ckd_add(&addr, (uintptr_t)strtab, rva)) return 0;
if (addr >= (uintptr_t)elf + mapsize) return 0;
if (!memchr((char *)addr, 0, (uintptr_t)elf + mapsize - addr)) return 0;
return (char *)addr;
Elf64_Word i) { // foreign
const char *e;
e = (const char *)elf;
if (strtab < e) return 0;
if (strtab >= e + mapsize) return 0;
if (strtab + i >= e + mapsize) return 0;
if (!memchr(strtab + i, 0, (e + mapsize) - (strtab + i))) return 0;
return (char *)strtab + i;
}

View file

@ -18,9 +18,21 @@
*/
#include "libc/elf/def.h"
#include "libc/elf/elf.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/elf/struct/shdr.h"
#include "libc/str/str.h"
char *GetElfStringTable(const Elf64_Ehdr *elf, size_t mapsize) {
/**
* Returns pointer to elf string table.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param section_name is usually `".strtab"`, `".dynstr"`, or null
* @return pointer to double-nul terminated string list or null on error
*/
char *GetElfStringTable(const Elf64_Ehdr *elf, //
size_t mapsize, //
const char *section_name) {
int i;
char *name;
Elf64_Shdr *shdr;
@ -28,9 +40,9 @@ char *GetElfStringTable(const Elf64_Ehdr *elf, size_t mapsize) {
if ((shdr = GetElfSectionHeaderAddress(elf, mapsize, i)) &&
shdr->sh_type == SHT_STRTAB &&
(name = GetElfSectionName(elf, mapsize, shdr)) &&
!strcmp(name, ".strtab")) {
(!section_name || !strcmp(name, section_name))) {
return GetElfSectionAddress(elf, mapsize, shdr);
}
}
return NULL;
return 0;
}

View file

@ -1,37 +0,0 @@
/*-*- 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 2020 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/elf/def.h"
#include "libc/elf/elf.h"
#include "libc/str/str.h"
char *GetElfStrs(const Elf64_Ehdr *elf, size_t mapsize, size_t *out_size) {
int i;
char *name;
Elf64_Shdr *shdr;
for (i = 0; i < elf->e_shnum; ++i) {
if ((shdr = GetElfSectionHeaderAddress(elf, mapsize, i)) &&
shdr->sh_type == SHT_STRTAB &&
(name = GetElfSectionName(elf, mapsize, shdr)) &&
!strcmp(name, ".strtab")) {
if (out_size) *out_size = shdr->sh_size;
return GetElfSectionAddress(elf, mapsize, shdr);
}
}
return 0;
}

View file

@ -18,20 +18,32 @@
*/
#include "libc/elf/def.h"
#include "libc/elf/elf.h"
#include "libc/elf/scalar.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/elf/struct/sym.h"
Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *elf, size_t mapsize,
/**
* Returns pointer to elf symbol table.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @param section_type is usually `SHT_SYMTAB` or `SHT_DYNSYM`
* @param out_count optionally receives number of elements in res
* @return pointer to symbol array, or null on error
*/
Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *elf, //
size_t mapsize, //
int section_type, //
Elf64_Xword *out_count) {
int i;
Elf64_Shdr *shdr;
if (elf->e_shentsize) {
for (i = elf->e_shnum; i > 0; --i) {
shdr = GetElfSectionHeaderAddress(elf, mapsize, i - 1);
if (shdr->sh_type == SHT_SYMTAB) {
if (shdr->sh_entsize != sizeof(Elf64_Sym)) __builtin_trap();
if (out_count) *out_count = shdr->sh_size / sizeof(Elf64_Sym);
return GetElfSectionAddress(elf, mapsize, shdr);
}
for (i = elf->e_shnum; i > 0; --i) {
if ((shdr = GetElfSectionHeaderAddress(elf, mapsize, i - 1)) && //
shdr->sh_entsize == sizeof(Elf64_Sym) && //
shdr->sh_type == section_type) {
if (out_count) *out_count = shdr->sh_size / sizeof(Elf64_Sym);
return GetElfSectionAddress(elf, mapsize, shdr);
}
}
return NULL;
return 0;
}

View file

@ -1,39 +0,0 @@
/*-*- 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 2020 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/elf/elf.h"
#include "libc/limits.h"
void GetElfVirtualAddressRange(const Elf64_Ehdr *elf, size_t elfsize,
intptr_t *out_start, intptr_t *out_end) {
unsigned i;
Elf64_Phdr *phdr;
intptr_t start, end, pstart, pend;
start = INTPTR_MAX;
end = 0;
for (i = 0; i < elf->e_phnum; ++i) {
phdr = GetElfSegmentHeaderAddress(elf, elfsize, i);
if (phdr->p_type != PT_LOAD) continue;
pstart = phdr->p_vaddr;
pend = phdr->p_vaddr + phdr->p_memsz;
if (pstart < start) start = pstart;
if (pend > end) end = pend;
}
if (out_start) *out_start = start;
if (out_end) *out_end = end;
}

View file

@ -16,12 +16,20 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/elf/def.h"
#include "libc/elf/elf.h"
#include "libc/str/str.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/intrin/bits.h"
/**
* Returns true if `elf` is a 64-bit elf executable.
*
* @param elf points to the start of the executable image
* @param mapsize is the number of bytes past `elf` we can access
* @return true if elf header looks legit
*/
bool IsElf64Binary(const Elf64_Ehdr *elf, size_t mapsize) {
if (mapsize < sizeof(Elf64_Ehdr)) return false;
if (memcmp(elf->e_ident, ELFMAG, 4)) return false;
return (elf->e_ident[EI_CLASS] == ELFCLASSNONE ||
elf->e_ident[EI_CLASS] == ELFCLASS64);
if (READ32LE(elf->e_ident) != READ32LE(ELFMAG)) return false;
return elf->e_ident[EI_CLASS] != ELFCLASS32;
}

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ELF_SCALAR_H_
#define COSMOPOLITAN_LIBC_ELF_SCALAR_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define Elf64_Addr uint64_t
#define Elf64_Half uint16_t
@ -13,5 +12,4 @@
#define Elf64_Xword uint64_t
#define Elf_Symndx uint32_t
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_ELF_SCALAR_H_ */

View file

@ -22,14 +22,17 @@ int vsprintf(char *, const char *, va_list)
dontthrow nocallback;
int sscanf(const char *, const char *, ...) scanfesque(2);
int vsscanf(const char *, const char *, va_list);
int vcscanf(int (*)(void *), int (*)(int, void *), void *, const char *,
va_list);
int __fmt(void *, void *, const char *, va_list) _Hide;
char *itoa(int, char *, int) compatfn;
char *fcvt(double, int, int *, int *);
char *ecvt(double, int, int *, int *);
char *gcvt(double, int, char *);
#ifdef COSMO
int __vcscanf(int (*)(void *), int (*)(int, void *), void *, const char *,
va_list);
int __fmt(void *, void *, const char *, va_list) _Hide;
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_FMT_FMT_H_ */

View file

@ -34,11 +34,10 @@ LIBC_FMT_A_CHECKS = \
$(LIBC_FMT_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_FMT_A_DIRECTDEPS = \
LIBC_INTRIN \
LIBC_NEXGEN32E \
LIBC_NT_KERNEL32 \
LIBC_STR \
LIBC_INTRIN \
LIBC_STUBS \
LIBC_SYSV \
LIBC_TINYMATH \
THIRD_PARTY_COMPILER_RT

View file

@ -17,11 +17,12 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/kprintf.h"
#include "libc/runtime/runtime.h"
void __cxa_pure_virtual(void) {
#ifndef NDEBUG
kprintf("__cxa_pure_virtual() called\n"
"Did you call a virtual method from a destructor?\n");
#endif
__builtin_trap();
abort();
}

View file

@ -1,7 +1,7 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
/*-*- 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 2020 Justine Alexandra Roberts Tunney
Copyright 2023 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
@ -16,9 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
// See -mfunction-return=thunk
__x86_return_thunk:
ret
.endfn __x86_return_thunk,weak
// stub version of abort() for low-dependency apps
__attribute__((__noreturn__, __weak__)) void abort(void) {
__builtin_trap();
}

View file

@ -176,7 +176,7 @@ static bool __asan_once(void) {
#define __asan_unreachable() \
do { \
kprintf("%s:%d: __asan_unreachable()\n", __FILE__, __LINE__); \
for (;;) __builtin_trap(); \
__builtin_trap(); \
} while (0)
static int __asan_bsf(uint64_t x) {

View file

@ -15,8 +15,6 @@
#include "third_party/compiler_rt/int_lib.h"
#ifdef CRT_HAS_128BIT
/* Returns: a << b */
/* Precondition: 0 <= b < bits_in_tword */
@ -42,5 +40,3 @@ __ashlti3(ti_int a, si_int b)
}
return result.all;
}
#endif /* CRT_HAS_128BIT */

View file

@ -20,6 +20,7 @@
#include "libc/atomic.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/kprintf.h"
#include "libc/runtime/runtime.h"
privileged void __assert_fail(const char *expr, const char *file, int line) {
static atomic_bool once;

View file

@ -29,13 +29,13 @@ COMPILER_RT_ABI ti_int __divmodti4(ti_int a, ti_int b, tu_int *opt_out_rem) {
}
sa = a >> k; // sa = a < 0 ? -1 : 0
sb = b >> k; // sb = b < 0 ? -1 : 0
x = (a ^ sa) - sa; // negate if sa == -1
y = (b ^ sb) - sb; // negate if sb == -1
x = (tu_int)(a ^ sa) - sa; // negate if sa == -1
y = (tu_int)(b ^ sb) - sb; // negate if sb == -1
sq = sa ^ sb; // sign of quotient
sr = sa; // sign of remainder
q = __udivmodti4(x, y, &r); // unsigned divide
q = (q ^ sq) - sq; // fix quotient sign
r = (r ^ sr) - sr; // fix remainder sign
q = (tu_int)(q ^ sq) - sq; // fix quotient sign
r = (tu_int)(r ^ sr) - sr; // fix remainder sign
if (opt_out_rem) *opt_out_rem = r;
return q;
}

View file

@ -28,12 +28,11 @@ LIBC_INTRIN_A_CHECKS = \
$(LIBC_INTRIN_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_INTRIN_A_DIRECTDEPS = \
LIBC_STUBS \
LIBC_SYSV \
LIBC_SYSV_CALLS \
LIBC_NEXGEN32E \
LIBC_NT_KERNEL32 \
LIBC_NT_WS2_32
LIBC_NT_WS2_32 \
LIBC_SYSV \
LIBC_SYSV_CALLS
LIBC_INTRIN_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_INTRIN_A_DIRECTDEPS),$($(x))))
@ -218,8 +217,12 @@ o/$(MODE)/libc/intrin/aarch64/%.o: libc/intrin/aarch64/%.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/fenv.o: libc/intrin/fenv.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/gcov.o: libc/intrin/gcov.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/futex.o: libc/intrin/futex.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/typeinfo.o: libc/intrin/typeinfo.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kclocknames.o: libc/intrin/kclocknames.S
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
o/$(MODE)/libc/intrin/kdos2errno.o: libc/intrin/kdos2errno.S

View file

@ -26,7 +26,7 @@ __mulodi4(di_int a, di_int b, int* overflow)
const di_int MIN = (du_int)1 << (N-1);
const di_int MAX = ~MIN;
*overflow = 0;
di_int result = (du_int)a * (du_int)b;
di_int result = (du_int)a * b;
if (a == MIN)
{
if (b != 0 && b != 1)

View file

@ -26,7 +26,7 @@ __mulosi4(si_int a, si_int b, int* overflow)
const si_int MIN = (su_int)1 << (N-1);
const si_int MAX = ~MIN;
*overflow = 0;
si_int result = (su_int)a * (su_int)b;
si_int result = (su_int)a * b;
if (a == MIN)
{
if (b != 0 && b != 1)

View file

@ -28,7 +28,7 @@ __muloti4(ti_int a, ti_int b, int* overflow)
const ti_int MIN = (tu_int)1 << (N-1);
const ti_int MAX = ~MIN;
*overflow = 0;
ti_int result = (tu_int)a * (tu_int)b;
ti_int result = (tu_int)a * b;
if (a == MIN)
{
if (b != 0 && b != 1)

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/kprintf.h"
#include "libc/runtime/runtime.h"
/**
* Arithmetic overflow handler.
@ -31,5 +32,5 @@
*/
__attribute__((__weak__)) void __on_arithmetic_overflow(void) {
kprintf("error: -ftrapv caught arithmetic overflow\n");
__builtin_trap();
abort();
}

View file

@ -17,8 +17,9 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/kprintf.h"
#include "libc/runtime/runtime.h"
void __stack_chk_fail(void) {
kprintf("stack smashed\n");
__attribute__((__weak__)) void __stack_chk_fail(void) {
kprintf("%s: stack smashed\n", program_invocation_name);
__builtin_trap();
}

View file

@ -18,6 +18,6 @@
*/
#include "libc/runtime/internal.h"
void __stack_chk_fail_local(void) {
__attribute__((__weak__)) void __stack_chk_fail_local(void) {
__stack_chk_fail();
}

View file

@ -199,7 +199,7 @@ static uintptr_t __ubsan_extend(struct UbsanTypeDescriptor *t, uintptr_t x) {
}
static wontreturn void __ubsan_unreachable(void) {
for (;;) __builtin_trap();
for (;;) abort();
}
static void __ubsan_exit(void) {

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_ASSERT_H_
#define LIBC_ISYSTEM_ASSERT_H_
#ifndef _ASSERT_H
#define _ASSERT_H
#include "libc/assert.h"
#endif
#endif /* _ASSERT_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_BYTESWAP_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_BYTESWAP_H_
#ifndef _BYTESWAP_H
#define _BYTESWAP_H
#include "libc/intrin/bswap.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_BYTESWAP_H_ */
#endif /* _BYTESWAP_H */

View file

@ -1,6 +1,6 @@
#ifndef LIBC_ISYSTEM_COMPLEX_H_
#define LIBC_ISYSTEM_COMPLEX_H_
#ifndef _COMPLEX_H
#define _COMPLEX_H
#include "libc/complex.h"
#include "libc/imag.internal.h"
#include "libc/math.h"
#endif
#endif /* _COMPLEX_H */

View file

@ -30,6 +30,7 @@
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/dce.h"
#include "libc/elf/elf.h"
#include "libc/fmt/itoa.h"
#include "libc/fmt/leb128.h"
#include "libc/intrin/bsf.h"

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_CPIO_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_CPIO_H_
#ifndef _CPIO_H
#define _CPIO_H
#include "libc/sysv/consts/c.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_CPIO_H_ */
#endif /* _CPIO_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_CPUID_INTERNAL_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_CPUID_INTERNAL_H_
#ifndef _CPUID_H
#define _CPUID_H
#include "third_party/intel/cpuid.internal.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_CPUID_INTERNAL_H_ */
#endif /* _CPUID_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_CRYPT_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_CRYPT_H_
#ifndef _CRYPT_H
#define _CRYPT_H
#include "third_party/musl/crypt.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_CRYPT_H_ */
#endif /* _CRYPT_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_CTYPE_H_
#define LIBC_ISYSTEM_CTYPE_H_
#ifndef _CTYPE_H
#define _CTYPE_H
#include "libc/str/str.h"
#endif
#endif /* _CTYPE_H */

View file

@ -1,7 +1,7 @@
#ifndef LIBC_ISYSTEM_DIRENT_H_
#define LIBC_ISYSTEM_DIRENT_H_
#ifndef _DIRENT_H
#define _DIRENT_H
#include "libc/calls/calls.h"
#include "libc/calls/struct/dirent.h"
#include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/dt.h"
#endif
#endif /* _DIRENT_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_SYS_DLFCN_H_
#define LIBC_ISYSTEM_SYS_DLFCN_H_
#ifndef _DLFCN_H
#define _DLFCN_H
#include "libc/runtime/dlfcn.h"
#endif
#endif /* _DLFCN_H */

View file

@ -1,4 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_DOG_PY_
#define COSMOPOLITAN_LIBC_ISYSTEM_DOG_PY_
#include "third_party/intel/dog.py"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_DOG_PY_ */

View file

@ -1,4 +1,22 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ELF_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_ELF_H_
#include "libc/elf/elf.h"
#endif
#ifndef _ELF_H
#define _ELF_H
#include "libc/elf/def.h"
#include "libc/elf/scalar.h"
#include "libc/elf/struct/auxv.h"
#include "libc/elf/struct/chdr.h"
#include "libc/elf/struct/dyn.h"
#include "libc/elf/struct/ehdr.h"
#include "libc/elf/struct/lib.h"
#include "libc/elf/struct/move.h"
#include "libc/elf/struct/nhdr.h"
#include "libc/elf/struct/phdr.h"
#include "libc/elf/struct/rel.h"
#include "libc/elf/struct/rela.h"
#include "libc/elf/struct/shdr.h"
#include "libc/elf/struct/sym.h"
#include "libc/elf/struct/syminfo.h"
#include "libc/elf/struct/verdaux.h"
#include "libc/elf/struct/verdef.h"
#include "libc/elf/struct/vernaux.h"
#include "libc/elf/struct/verneed.h"
#endif /* _ELF_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_ENDIAN_H_
#define LIBC_ISYSTEM_ENDIAN_H_
#ifndef _ENDIAN_H
#define _ENDIAN_H
#include "libc/intrin/newbie.h"
#include "libc/sysv/consts/endian.h"
#endif /* LIBC_ISYSTEM_ENDIAN_H_ */
#endif /* _ENDIAN_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_ERR_H_
#define LIBC_ISYSTEM_ERR_H_
#ifndef _ERR_H
#define _ERR_H
#include "libc/log/bsd.h"
#endif
#endif /* _ERR_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_ERRNO_H_
#define LIBC_ISYSTEM_ERRNO_H_
#ifndef _ERRNO_H
#define _ERRNO_H
#include "libc/errno.h"
#endif
#endif /* _ERRNO_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_SYS_FCNTL_H_
#define LIBC_ISYSTEM_SYS_FCNTL_H_
#ifndef _FCNTL_H
#define _FCNTL_H
#include "libc/calls/calls.h"
#include "libc/calls/struct/flock.h"
#include "libc/calls/weirdtypes.h"
@ -10,4 +10,4 @@
#include "libc/sysv/consts/posix.h"
#include "libc/sysv/consts/s.h"
#include "libc/sysv/consts/splice.h"
#endif
#endif /* _FCNTL_H */

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FEATURES_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_FEATURES_H_
#ifndef _FEATURES_H
#define _FEATURES_H
#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
@ -35,4 +35,4 @@
#define _Noreturn
#endif
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FEATURES_H_ */
#endif /* _FEATURES_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FENV_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_FENV_H_
#ifndef _FENV_H
#define _FENV_H
#include "libc/runtime/fenv.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FENV_H_ */
#endif /* _FENV_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_FLOAT_H_
#define LIBC_ISYSTEM_FLOAT_H_
#ifndef _FLOAT_H
#define _FLOAT_H
#include "libc/math.h"
#include "libc/runtime/fenv.h"
#endif
#endif /* _FLOAT_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_
#ifndef _FNMATCH_H
#define _FNMATCH_H
#include "third_party/musl/fnmatch.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_ */
#endif /* _FNMATCH_H */

View file

@ -1,6 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_
#ifndef _FTW_H
#define _FTW_H
#include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/s.h"
#include "third_party/musl/ftw.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FTW_H_ */
#endif /* _FTW_H */

View file

@ -1,4 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FUN_PY_
#define COSMOPOLITAN_LIBC_ISYSTEM_FUN_PY_
#include "third_party/intel/fun.py"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FUN_PY_ */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_GETOPT_H_
#define LIBC_ISYSTEM_GETOPT_H_
#ifndef _GETOPT_H
#define _GETOPT_H
#include "third_party/getopt/getopt.h"
#endif
#endif /* _GETOPT_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_
#ifndef _GLOB_H
#define _GLOB_H
#include "third_party/musl/glob.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_GLOB_H_ */
#endif /* _GLOB_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_GRP_H_
#define LIBC_ISYSTEM_GRP_H_
#ifndef _GRP_H
#define _GRP_H
#include "libc/calls/calls.h"
#include "third_party/musl/passwd.h"
#endif
#endif /* _GRP_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_
#ifndef _ICONV_H
#define _ICONV_H
#include "libc/stdio/iconv.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_ */
#endif /* _ICONV_H */

View file

@ -1,7 +1,7 @@
#ifndef LIBC_ISYSTEM_INTTYPES_H_
#define LIBC_ISYSTEM_INTTYPES_H_
#ifndef _INTTYPES_H
#define _INTTYPES_H
#include "libc/fmt/conv.h"
#include "libc/inttypes.h"
#include "libc/limits.h"
#include "libc/literal.h"
#endif /* LIBC_ISYSTEM_INTTYPES_H_ */
#endif /* _INTTYPES_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ISO646_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_ISO646_H_
#ifndef _ISO646_H
#define _ISO646_H
#include "libc/iso646.internal.h"
#endif
#endif /* _ISO646_H */

View file

@ -1,6 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_
#ifndef _LANGINFO_H
#define _LANGINFO_H
#include "libc/str/langinfo.h"
#include "libc/str/locale.h"
#include "libc/str/nltypes.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LANGINFO_H_ */
#endif /* _LANGINFO_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_
#ifndef _LIBGEN_H
#define _LIBGEN_H
#include "libc/fmt/conv.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LIBGEN_H_ */
#endif /* _LIBGEN_H */

View file

@ -1,9 +1,9 @@
#ifndef LIBC_ISYSTEM_LIMITS_H_
#define LIBC_ISYSTEM_LIMITS_H_
#ifndef _LIMITS_H
#define _LIMITS_H
#include "libc/limits.h"
#include "libc/sysv/consts/_posix.h"
#include "libc/sysv/consts/iov.h"
#include "libc/sysv/consts/limits.h"
#include "libc/sysv/consts/xopen.h"
#include "libc/thread/thread.h"
#endif
#endif /* _LIMITS_H */

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_
#ifndef _LOCALE_H
#define _LOCALE_H
#include "libc/str/locale.h"
#include "libc/str/unicode.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_LOCALE_H_ */
#endif /* _LOCALE_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_MALLOC_H_
#define LIBC_ISYSTEM_MALLOC_H_
#ifndef _MALLOC_H
#define _MALLOC_H
#include "libc/mem/mem.h"
#endif
#endif /* _MALLOC_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_MATH_H_
#define LIBC_ISYSTEM_MATH_H_
#ifndef _MATH_H
#define _MATH_H
#include "libc/math.h"
#endif
#endif /* _MATH_H */

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_
#ifndef _MEMORY_H
#define _MEMORY_H
#include "libc/mem/alg.h"
#include "libc/str/str.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_ */
#endif /* _MEMORY_H */

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_
#ifndef _NETDB_H
#define _NETDB_H
#include "libc/dns/dns.h"
#include "libc/dns/ent.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_ */
#endif /* _NETDB_H */

View file

@ -1,4 +1,4 @@
#ifndef LIBC_ISYSTEM_SETJMP_H_
#define LIBC_ISYSTEM_SETJMP_H_
#ifndef _SETJMP_H
#define _SETJMP_H
#include "libc/runtime/runtime.h"
#endif
#endif /* _SETJMP_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_SIGNAL_H_
#define LIBC_ISYSTEM_SIGNAL_H_
#ifndef _SIGNAL_H
#define _SIGNAL_H
#include "libc/calls/calls.h"
#include "libc/calls/sigtimedwait.h"
#include "libc/calls/struct/sigaction.h"
@ -7,4 +7,4 @@
#include "libc/sysv/consts/sa.h"
#include "libc/sysv/consts/sicode.h"
#include "libc/sysv/consts/ss.h"
#endif
#endif /* _SIGNAL_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STDALIGN_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_STDALIGN_H_
#ifndef _STDALIGN_H
#define _STDALIGN_H
#include "libc/stdalign.internal.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STDALIGN_H_ */
#endif /* _STDALIGN_H */

View file

@ -1,3 +1,3 @@
#ifndef LIBC_ISYSTEM_STDARG_H_
#define LIBC_ISYSTEM_STDARG_H_
#endif
#ifndef _STDARG_H
#define _STDARG_H
#endif /* _STDARG_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STDATOMIC_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_STDATOMIC_H_
#ifndef _STDATOMIC_H
#define _STDATOMIC_H
#include "libc/intrin/atomic.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STDATOMIC_H_ */
#endif /* _STDATOMIC_H */

View file

@ -1,3 +1,3 @@
#ifndef LIBC_ISYSTEM_STDBOOL_H_
#define LIBC_ISYSTEM_STDBOOL_H_
#endif
#ifndef _STDBOOL_H
#define _STDBOOL_H
#endif /* _STDBOOL_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STDCKDINT_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_STDCKDINT_H_
#ifndef _STDCKDINT_H
#define _STDCKDINT_H
#include "libc/stdckdint.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STDCKDINT_H_ */
#endif /* _STDCKDINT_H */

View file

@ -1,3 +1,3 @@
#ifndef LIBC_ISYSTEM_STDDEF_H_
#define LIBC_ISYSTEM_STDDEF_H_
#endif
#ifndef _STDDEF_H
#define _STDDEF_H
#endif /* _STDDEF_H */

View file

@ -1,6 +1,6 @@
#ifndef LIBC_ISYSTEM_STDINT_H_
#define LIBC_ISYSTEM_STDINT_H_
#ifndef _STDINT_H
#define _STDINT_H
#include "libc/inttypes.h"
#include "libc/limits.h"
#include "libc/literal.h"
#endif
#endif /* _STDINT_H */

View file

@ -1,11 +1,10 @@
#ifndef LIBC_ISYSTEM_STDIO_H_
#define LIBC_ISYSTEM_STDIO_H_
#ifndef _STDIO_H
#define _STDIO_H
#include "libc/calls/calls.h"
#include "libc/stdio/dprintf.h"
#include "libc/calls/weirdtypes.h"
#include "libc/fmt/fmt.h"
#include "libc/mem/fmt.h"
#include "libc/stdio/dprintf.h"
#include "libc/stdio/stdio.h"
#include "libc/stdio/temp.h"
#include "third_party/musl/tempnam.h"
#endif
#endif /* _STDIO_H */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_
#ifndef _STDIO_EXT_H
#define _STDIO_EXT_H
#include "libc/stdio/stdio_ext.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_ */
#endif /* _STDIO_EXT_H */

View file

@ -1,5 +1,5 @@
#ifndef LIBC_ISYSTEM_STDLIB_H_
#define LIBC_ISYSTEM_STDLIB_H_
#ifndef _STDLIB_H
#define _STDLIB_H
#include "libc/calls/calls.h"
#include "libc/calls/termios.h"
#include "libc/fmt/conv.h"
@ -15,4 +15,4 @@
#include "third_party/getopt/getopt.h"
#include "third_party/musl/crypt.h"
#include "third_party/musl/rand48.h"
#endif
#endif /* _STDLIB_H */

Some files were not shown because too many files have changed in this diff Show more