diff --git a/dsp/tty/sendtitle.c b/dsp/tty/sendtitle.c index dd19db15c..2ecd398c4 100644 --- a/dsp/tty/sendtitle.c +++ b/dsp/tty/sendtitle.c @@ -19,6 +19,7 @@ #include "dsp/tty/tty.h" #include "libc/mem/arraylist2.internal.h" #include "libc/mem/gc.internal.h" +#include "libc/mem/mem.h" #include "libc/x/x.h" /* TODO(jart): DELETE */ diff --git a/libc/calls/internal.h b/libc/calls/internal.h index f5c980256..df04b5438 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -5,6 +5,7 @@ #include "libc/calls/struct/sigval.h" #include "libc/dce.h" #include "libc/macros.internal.h" +#include "libc/stdbool.h" #define kSigactionMinRva 8 /* >SIG_{ERR,DFL,IGN,...} */ @@ -46,6 +47,12 @@ int _park_norestart(uint32_t, uint64_t); int _park_restartable(uint32_t, uint64_t); int sys_openat_metal(int, const char *, int, unsigned); +#ifdef __x86_64__ +bool __iswsl1(void); +#else +#define __iswsl1() false +#endif + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ */ diff --git a/libc/dce.h b/libc/dce.h index 171644845..b96bb6e2b 100644 --- a/libc/dce.h +++ b/libc/dce.h @@ -119,12 +119,6 @@ COSMOPOLITAN_C_START_ extern const int __hostos; -#ifdef __x86_64__ -bool __iswsl1(void); -#else -#define __iswsl1() false -#endif - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* _COSMO_SOURCE */ diff --git a/libc/dns/parsehoststxt.c b/libc/dns/parsehoststxt.c index 38979f2f0..ebb6f0b40 100644 --- a/libc/dns/parsehoststxt.c +++ b/libc/dns/parsehoststxt.c @@ -20,6 +20,7 @@ #include "libc/dns/hoststxt.h" #include "libc/errno.h" #include "libc/mem/arraylist.internal.h" +#include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" diff --git a/libc/elf/elf.h b/libc/elf/elf.h index 294240683..9aea545ea 100644 --- a/libc/elf/elf.h +++ b/libc/elf/elf.h @@ -12,8 +12,8 @@ COSMOPOLITAN_C_START_ ╚────────────────────────────────────────────────────────────────────────────│*/ /* clang-format off */ -bool IsElfSymbolContent(const Elf64_Sym *); -bool IsElf64Binary(const Elf64_Ehdr *, size_t); +bool32 IsElfSymbolContent(const Elf64_Sym *); +bool32 IsElf64Binary(const Elf64_Ehdr *, size_t); char *GetElfStringTable(const Elf64_Ehdr *, size_t, const char *); Elf64_Sym *GetElfSymbols(const Elf64_Ehdr *, size_t, int, Elf64_Xword *); Elf64_Shdr *GetElfSymbolTable(const Elf64_Ehdr *, size_t, int, Elf64_Xword *); diff --git a/libc/elf/iself64binary.c b/libc/elf/iself64binary.c index 1c77c951d..8464cb070 100644 --- a/libc/elf/iself64binary.c +++ b/libc/elf/iself64binary.c @@ -28,7 +28,7 @@ * @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) { +bool32 IsElf64Binary(const Elf64_Ehdr *elf, size_t mapsize) { if (mapsize < sizeof(Elf64_Ehdr)) return false; if (READ32LE(elf->e_ident) != READ32LE(ELFMAG)) return false; return elf->e_ident[EI_CLASS] != ELFCLASS32; diff --git a/libc/elf/iselfsymbolcontent.c b/libc/elf/iselfsymbolcontent.c index 584b3fa7c..b8955a2d6 100644 --- a/libc/elf/iselfsymbolcontent.c +++ b/libc/elf/iselfsymbolcontent.c @@ -19,7 +19,7 @@ #include "libc/elf/def.h" #include "libc/elf/elf.h" -bool IsElfSymbolContent(const Elf64_Sym *sym) { +bool32 IsElfSymbolContent(const Elf64_Sym *sym) { return sym->st_size > 0 && (ELF64_ST_TYPE(sym->st_info) == STT_FUNC || ELF64_ST_TYPE(sym->st_info) == STT_OBJECT); } diff --git a/libc/fmt/formatoctal64.c b/libc/fmt/formatoctal64.c index c82171967..433e4cf1b 100644 --- a/libc/fmt/formatoctal64.c +++ b/libc/fmt/formatoctal64.c @@ -25,7 +25,7 @@ * @param z ensures it starts with zero * @return pointer to nul byte */ -char *FormatOctal64(char p[hasatleast 24], uint64_t x, bool z) { +char *FormatOctal64(char p[hasatleast 24], uint64_t x, bool32 z) { char t; size_t i, a, b; i = 0; diff --git a/libc/fmt/itoa.h b/libc/fmt/itoa.h index 725eee704..438aaec18 100644 --- a/libc/fmt/itoa.h +++ b/libc/fmt/itoa.h @@ -33,8 +33,8 @@ char *FormatInt64(char[hasatleast 21], int64_t); char *FormatUint64(char[hasatleast 21], uint64_t); char *FormatInt64Thousands(char[hasatleast 27], int64_t); char *FormatUint64Thousands(char[hasatleast 27], uint64_t); -char *FormatOctal32(char[hasatleast 13], uint32_t, bool); -char *FormatOctal64(char[hasatleast 24], uint64_t, bool); +char *FormatOctal32(char[hasatleast 13], uint32_t, bool32); +char *FormatOctal64(char[hasatleast 24], uint64_t, bool32); char *FormatBinary64(char[hasatleast 67], uint64_t, char); char *FormatHex64(char[hasatleast 19], uint64_t, char); char *FormatFlex64(char[hasatleast 24], int64_t, char); diff --git a/libc/intrin/cmpxchg.h b/libc/intrin/cmpxchg.h index a130109b8..cd511f14c 100644 --- a/libc/intrin/cmpxchg.h +++ b/libc/intrin/cmpxchg.h @@ -7,7 +7,7 @@ COSMOPOLITAN_C_START_ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86__) #define _cmpxchg(IFTHING, ISEQUALTOME, REPLACEITWITHME) \ ({ \ - bool DidIt; \ + bool32 DidIt; \ autotype(IFTHING) IfThing = (IFTHING); \ typeof(*IfThing) IsEqualToMe = (ISEQUALTOME); \ typeof(*IfThing) ReplaceItWithMe = (REPLACEITWITHME); \ diff --git a/libc/intrin/formatoctal32.c b/libc/intrin/formatoctal32.c index 18f295e20..5af7a00f4 100644 --- a/libc/intrin/formatoctal32.c +++ b/libc/intrin/formatoctal32.c @@ -25,7 +25,7 @@ * @param z ensures it starts with zero * @return pointer to nul byte */ -char *FormatOctal32(char p[hasatleast 13], uint32_t x, bool z) { +char *FormatOctal32(char p[hasatleast 13], uint32_t x, bool32 z) { char t; size_t i, a, b; i = 0; diff --git a/libc/intrin/isatleastwindows10.c b/libc/intrin/isatleastwindows10.c index 5a4f4526a..af715ad94 100644 --- a/libc/intrin/isatleastwindows10.c +++ b/libc/intrin/isatleastwindows10.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/nt/version.h" -bool(IsAtLeastWindows10)(void) { +bool32(IsAtLeastWindows10)(void) { #ifdef __x86_64__ return IsAtLeastWindows10(); #else diff --git a/libc/intrin/iscygwin.c b/libc/intrin/iscygwin.c index 3c84b96fe..5f2632a04 100644 --- a/libc/intrin/iscygwin.c +++ b/libc/intrin/iscygwin.c @@ -19,6 +19,6 @@ #include "libc/runtime/runtime.h" #include "libc/str/str.h" -bool IsCygwin(void) { +bool32 IsCygwin(void) { return IsGenuineBlink() && !strcmp(GetCpuidOs(), "Cygwin"); } diff --git a/libc/intrin/isdebuggerpresent.c b/libc/intrin/isdebuggerpresent.c index e455d55e5..7293deee6 100644 --- a/libc/intrin/isdebuggerpresent.c +++ b/libc/intrin/isdebuggerpresent.c @@ -44,7 +44,7 @@ static textwindows bool IsBeingDebugged(void) { * Determines if gdb, strace, windbg, etc. is controlling process. * @return non-zero if attached, otherwise 0 */ -int IsDebuggerPresent(bool force) { +bool32 IsDebuggerPresent(bool32 force) { /* asan runtime depends on this function */ ssize_t got; int e, fd, res; diff --git a/libc/intrin/isgenuineblink.c b/libc/intrin/isgenuineblink.c index ef519f5b3..db6322fcf 100644 --- a/libc/intrin/isgenuineblink.c +++ b/libc/intrin/isgenuineblink.c @@ -20,6 +20,6 @@ #include "libc/runtime/runtime.h" #include "libc/str/str.h" -bool IsGenuineBlink(void) { +bool32 IsGenuineBlink(void) { return X86_HAVE(HYPERVISOR) && !strcmp(GetCpuidEmulator(), "GenuineBlink"); } diff --git a/libc/intrin/isrunningundermake.c b/libc/intrin/isrunningundermake.c index b6744cf11..f6a77f345 100644 --- a/libc/intrin/isrunningundermake.c +++ b/libc/intrin/isrunningundermake.c @@ -21,12 +21,12 @@ #include "libc/log/log.h" #include "libc/runtime/runtime.h" -bool g_isrunningundermake; +bool32 g_isrunningundermake; /** * Returns true if current process was spawned by GNU Make. */ -bool IsRunningUnderMake(void) { +bool32 IsRunningUnderMake(void) { return g_isrunningundermake; } diff --git a/libc/intrin/isworker.c b/libc/intrin/isworker.c index a2913c1e6..8864ed87c 100644 --- a/libc/intrin/isworker.c +++ b/libc/intrin/isworker.c @@ -25,4 +25,4 @@ * server is a good idea since it'll ask the C runtime to not pull * magical stunts like attaching GDB to the process on crash. */ -bool __isworker; +bool32 __isworker; diff --git a/libc/intrin/kprintf.greg.c b/libc/intrin/kprintf.greg.c index 592480e1e..3b583bfcd 100644 --- a/libc/intrin/kprintf.greg.c +++ b/libc/intrin/kprintf.greg.c @@ -204,7 +204,7 @@ privileged static bool kismapped(int x) { } } -privileged bool kisdangerous(const void *p) { +privileged bool32 kisdangerous(const void *p) { int frame; if (kisimagepointer(p)) return false; if (kiskernelpointer(p)) return false; diff --git a/libc/intrin/kprintf.h b/libc/intrin/kprintf.h index 0b6b7047e..3d6aa0851 100644 --- a/libc/intrin/kprintf.h +++ b/libc/intrin/kprintf.h @@ -21,7 +21,7 @@ size_t ksnprintf(char *, size_t, const char *, ...); void kvprintf(const char *, va_list); size_t kvsnprintf(char *, size_t, const char *, va_list); -bool kisdangerous(const void *); +bool32 kisdangerous(const void *); void klog(const char *, size_t); void _klog_serial(const char *, size_t); @@ -31,26 +31,26 @@ void uprintf(const char *, ...); void uvprintf(const char *, va_list); #ifndef TINY -#define KINFOF(FMT, ...) \ - do { \ - uprintf("\r\e[35m%s:%d: " FMT "\e[0m\n", \ - __FILE__, __LINE__, ## __VA_ARGS__); \ - } while (0) -#define KWARNF(FMT, ...) \ - do { \ - uprintf("\r\e[94;49mwarn: %s:%d: " FMT "\e[0m\n", \ - __FILE__, __LINE__, ## __VA_ARGS__); \ - } while (0) +#define KINFOF(FMT, ...) \ + do { \ + uprintf("\r\e[35m%s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \ + ##__VA_ARGS__); \ + } while (0) +#define KWARNF(FMT, ...) \ + do { \ + uprintf("\r\e[94;49mwarn: %s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \ + ##__VA_ARGS__); \ + } while (0) #else #define KINFOF(FMT, ...) ((void)0) #define KWARNF(FMT, ...) ((void)0) #endif -#define KDIEF(FMT, ...) \ - do { \ - kprintf("\r\e[30;101mfatal: %s:%d: " FMT "\e[0m\n", \ - __FILE__, __LINE__, ## __VA_ARGS__); \ - for (;;) asm volatile("cli\n\thlt"); \ - } while (0) +#define KDIEF(FMT, ...) \ + do { \ + kprintf("\r\e[30;101mfatal: %s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \ + ##__VA_ARGS__); \ + for (;;) asm volatile("cli\n\thlt"); \ + } while (0) COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/isystem/cosmo.h b/libc/isystem/cosmo.h index 4ba2046b3..88fc30024 100644 --- a/libc/isystem/cosmo.h +++ b/libc/isystem/cosmo.h @@ -1,6 +1,5 @@ #ifndef _COSMO_H #define _COSMO_H -#include "libc/stdbool.h" #ifdef _COSMO_SOURCE #define COSMO_ALREADY_DEFINED @@ -24,7 +23,7 @@ * includes core runtime services, third party libraries we've curated, * as well as internal libraries we made that are good enough to share. * - * @see tool/script/cosmocc + * @see tool/cosmocc */ #include "libc/calls/calls.h" diff --git a/libc/log/countbranch.h b/libc/log/countbranch.h index 9b6077589..03b7b6c63 100644 --- a/libc/log/countbranch.h +++ b/libc/log/countbranch.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_ #define COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_ #include "libc/macros.internal.h" +#include "libc/stdbool.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/log/internal.h b/libc/log/internal.h index 74e46ba12..ee6459d41 100644 --- a/libc/log/internal.h +++ b/libc/log/internal.h @@ -5,7 +5,7 @@ COSMOPOLITAN_C_START_ extern bool __nocolor; -extern bool g_isrunningundermake; +extern bool32 g_isrunningundermake; void __start_fatal(const char *, int); void __restore_tty(void); diff --git a/libc/log/log.h b/libc/log/log.h index 0ebb51589..0d09d1512 100644 --- a/libc/log/log.h +++ b/libc/log/log.h @@ -39,12 +39,11 @@ int __watch(void *, size_t); void __die(void) relegated wontreturn; /* print backtrace and abort() */ void _meminfo(int); /* shows malloc statistics &c. */ void _memsummary(int); /* light version of same thing */ -bool IsTerminalInarticulate(void) nosideeffect; const char *commandvenv(const char *, const char *); const char *GetAddr2linePath(void); const char *GetGdbPath(void); -bool32 IsDebuggerPresent(bool); -bool IsRunningUnderMake(void); +bool32 IsDebuggerPresent(bool32); +bool32 IsRunningUnderMake(void); char *GetSymbolByAddr(int64_t); void PrintGarbage(void); void PrintGarbageNumeric(FILE *); diff --git a/libc/mem/arraylist.internal.h b/libc/mem/arraylist.internal.h index d40da7684..5a1cb5c03 100644 --- a/libc/mem/arraylist.internal.h +++ b/libc/mem/arraylist.internal.h @@ -1,7 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_ALG_ARRAYLIST_H_ #define COSMOPOLITAN_LIBC_ALG_ARRAYLIST_H_ #include "libc/intrin/bits.h" -#include "libc/mem/mem.h" +#include "libc/mem/internal.h" #include "libc/str/str.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) diff --git a/libc/mem/arraylist2.internal.h b/libc/mem/arraylist2.internal.h index e86d3a402..1278c1b8f 100644 --- a/libc/mem/arraylist2.internal.h +++ b/libc/mem/arraylist2.internal.h @@ -1,6 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_ALG_ARRAYLIST2_H_ #define COSMOPOLITAN_LIBC_ALG_ARRAYLIST2_H_ -#include "libc/mem/mem.h" +#include "libc/mem/internal.h" #include "libc/str/str.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/mem/critbit0.h b/libc/mem/critbit0.h index bfae0543f..57cc963be 100644 --- a/libc/mem/critbit0.h +++ b/libc/mem/critbit0.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_ALG_CRITBIT0_H_ #define COSMOPOLITAN_LIBC_ALG_CRITBIT0_H_ +#include "libc/stdbool.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ /*───────────────────────────────────────────────────────────────────────────│─╗ diff --git a/libc/mem/internal.h b/libc/mem/internal.h index 9309c5c52..e98064516 100644 --- a/libc/mem/internal.h +++ b/libc/mem/internal.h @@ -10,6 +10,7 @@ struct CritbitNode { }; int __putenv(char *, bool); +bool __grow(void *, size_t *, size_t, size_t) paramsnonnull((1, 2)) libcesque; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/mem/mem.h b/libc/mem/mem.h index 900263481..ec78de68e 100644 --- a/libc/mem/mem.h +++ b/libc/mem/mem.h @@ -57,10 +57,6 @@ size_t malloc_footprint_limit(void); size_t malloc_set_footprint_limit(size_t); void malloc_inspect_all(void (*)(void *, void *, size_t, void *), void *); -#ifdef _COSMO_SOURCE -bool __grow(void *, size_t *, size_t, size_t) paramsnonnull((1, 2)) libcesque; -#endif - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_MEM_MEM_H_ */ diff --git a/libc/nexgen32e/rdtscp.h b/libc/nexgen32e/rdtscp.h index ec90a33ef..053162ef0 100644 --- a/libc/nexgen32e/rdtscp.h +++ b/libc/nexgen32e/rdtscp.h @@ -35,8 +35,8 @@ COSMOPOLITAN_C_START_ */ #define rdpid() \ ({ \ - bool Ok; \ long Msr; \ + bool32 Ok; \ Ok = false; \ if (X86_HAVE(RDPID)) { \ asm volatile("rdpid\t%0" : "=r"(Msr) : /* no inputs */ : "memory"); \ diff --git a/libc/nexgen32e/threaded.c b/libc/nexgen32e/threaded.c index 4230175e5..c0c3ff290 100644 --- a/libc/nexgen32e/threaded.c +++ b/libc/nexgen32e/threaded.c @@ -24,7 +24,7 @@ int __threaded; #ifdef __x86_64__ -bool __tls_enabled; +char __tls_enabled; #endif unsigned __tls_index; diff --git a/libc/nt/efi.h b/libc/nt/efi.h index 1a403d063..3d6d02676 100644 --- a/libc/nt/efi.h +++ b/libc/nt/efi.h @@ -176,7 +176,7 @@ typedef enum { typedef struct { uint32_t Resolution; uint32_t Accuracy; - bool SetsToZero; + bool32 SetsToZero; } EFI_TIME_CAPABILITIES; typedef struct { @@ -231,7 +231,7 @@ typedef struct { int32_t Attribute; int32_t CursorColumn; int32_t CursorRow; - bool CursorVisible; + bool32 CursorVisible; } EFI_SIMPLE_TEXT_OUTPUT_MODE; typedef enum { @@ -359,10 +359,10 @@ typedef EFI_STATUS(EFIAPI *EFI_UPDATE_CAPSULE)( typedef EFI_STATUS(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES)( EFI_CAPSULE_HEADER **CapsuleHeaderArray, uintptr_t CapsuleCount, uint64_t *out_MaximumCapsuleSize, EFI_RESET_TYPE *out_ResetType); -typedef EFI_STATUS(EFIAPI *EFI_GET_WAKEUP_TIME)(bool *out_Enabled, - bool *out_Pending, +typedef EFI_STATUS(EFIAPI *EFI_GET_WAKEUP_TIME)(bool32 *out_Enabled, + bool32 *out_Pending, EFI_TIME *out_Time); -typedef EFI_STATUS(EFIAPI *EFI_SET_WAKEUP_TIME)(bool Enable, +typedef EFI_STATUS(EFIAPI *EFI_SET_WAKEUP_TIME)(bool32 Enable, EFI_TIME *opt_Time); typedef EFI_STATUS(EFIAPI *EFI_SET_WATCHDOG_TIMER)(uintptr_t Timeout, uint64_t WatchdogCode, @@ -390,12 +390,12 @@ typedef EFI_STATUS(EFIAPI *EFI_CONVERT_POINTER)(uintptr_t DebugDisposition, void **inout_Address); typedef EFI_STATUS(EFIAPI *EFI_INPUT_RESET)( - EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, bool ExtendedVerification); + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, bool32 ExtendedVerification); typedef EFI_STATUS(EFIAPI *EFI_INPUT_READ_KEY)( EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, EFI_INPUT_KEY *out_Key); typedef EFI_STATUS(EFIAPI *EFI_TEXT_RESET)( - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool ExtendedVerification); + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool32 ExtendedVerification); typedef EFI_STATUS(EFIAPI *EFI_TEXT_STRING)( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, char16_t *String); typedef EFI_STATUS(EFIAPI *EFI_TEXT_TEST_STRING)( @@ -412,7 +412,7 @@ typedef EFI_STATUS(EFIAPI *EFI_TEXT_CLEAR_SCREEN)( typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION)( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, uint64_t Column, uint64_t Row); typedef EFI_STATUS(EFIAPI *EFI_TEXT_ENABLE_CURSOR)( - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool Visible); + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool32 Visible); typedef EFI_STATUS(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE)( EFI_GRAPHICS_OUTPUT_PROTOCOL *This, uint32_t ModeNumber, @@ -430,7 +430,7 @@ typedef EFI_STATUS(EFIAPI *EFI_HANDLE_PROTOCOL)(EFI_HANDLE Handle, EFI_GUID *Protocol, void *out_Interface); -typedef EFI_STATUS(EFIAPI *EFI_IMAGE_LOAD)(bool BootPolicy, +typedef EFI_STATUS(EFIAPI *EFI_IMAGE_LOAD)(bool32 BootPolicy, EFI_HANDLE ParentImageHandle, EFI_DEVICE_PATH_PROTOCOL *DevicePath, void *opt_SourceBuffer, diff --git a/libc/nt/version.h b/libc/nt/version.h index 5523a11f4..38b18afd6 100644 --- a/libc/nt/version.h +++ b/libc/nt/version.h @@ -4,7 +4,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -bool IsAtLeastWindows10(void) pureconst; +bool32 IsAtLeastWindows10(void) pureconst; bool32 GetVersionEx(struct NtOsVersionInfo *lpVersionInformation); #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86_64__) diff --git a/libc/runtime/isheap.c b/libc/runtime/isheap.c index 9651ed6ee..1b9ce0ba0 100644 --- a/libc/runtime/isheap.c +++ b/libc/runtime/isheap.c @@ -29,7 +29,7 @@ * @assume stack memory isn't stored beneath %rsp (-mno-red-zone) * @deprecated */ -optimizesize bool _isheap(void *p) { +optimizesize bool32 _isheap(void *p) { intptr_t x, y; x = kAutomapStart; y = x + kAutomapSize; diff --git a/libc/runtime/runtime.h b/libc/runtime/runtime.h index 3648c1e49..6421b7ea2 100644 --- a/libc/runtime/runtime.h +++ b/libc/runtime/runtime.h @@ -81,7 +81,7 @@ extern const char kNtSystemDirectory[]; extern const char kNtWindowsDirectory[]; extern size_t __virtualmax; extern size_t __stackmax; -extern bool __isworker; +extern bool32 __isworker; /* utilities */ void _intsort(int *, size_t); void _longsort(long *, size_t); @@ -111,14 +111,14 @@ void CheckForMemoryLeaks(void); void CheckForFileLeaks(void); void __enable_threads(void); void __oom_hook(size_t); -bool _isheap(void *); +bool32 _isheap(void *); /* code morphing */ void __morph_begin(void); void __morph_end(void); /* portability */ int NtGetVersion(void) pureconst; -bool IsGenuineBlink(void); -bool IsCygwin(void); +bool32 IsGenuineBlink(void); +bool32 IsCygwin(void); const char *GetCpuidOs(void); const char *GetCpuidEmulator(void); void GetCpuidBrand(char[13], uint32_t); diff --git a/libc/stdio/vcscanf.c b/libc/stdio/vcscanf.c index 80373886b..c77220582 100644 --- a/libc/stdio/vcscanf.c +++ b/libc/stdio/vcscanf.c @@ -19,6 +19,7 @@ #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/limits.h" +#include "libc/mem/internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/libc/str/endswith.c b/libc/str/endswith.c index 2b58edd14..4891bcc17 100644 --- a/libc/str/endswith.c +++ b/libc/str/endswith.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param suffix is also NUL-terminated */ -bool endswith(const char *s, const char *suffix) { +bool32 endswith(const char *s, const char *suffix) { size_t n, m; n = strlen(s); m = strlen(suffix); diff --git a/libc/str/endswith16.c b/libc/str/endswith16.c index d6e43ad63..d2ad7e9d8 100644 --- a/libc/str/endswith16.c +++ b/libc/str/endswith16.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param suffix is also NUL-terminated */ -bool endswith16(const char16_t *s, const char16_t *suffix) { +bool32 endswith16(const char16_t *s, const char16_t *suffix) { size_t n, m; n = strlen16(s); m = strlen16(suffix); diff --git a/libc/str/istext.c b/libc/str/istext.c index 66571f4dd..7cbf78327 100644 --- a/libc/str/istext.c +++ b/libc/str/istext.c @@ -21,7 +21,7 @@ /** * Returns true if buffer is most likely plaintext. */ -bool istext(const void *data, size_t size) { +bool32 istext(const void *data, size_t size) { const unsigned char *p, *pe; for (p = data, pe = p + size; p < pe; ++p) { if (*p <= 3) { diff --git a/libc/str/isutf8.c b/libc/str/isutf8.c index 84361ab1c..6c9a6334e 100644 --- a/libc/str/isutf8.c +++ b/libc/str/isutf8.c @@ -49,7 +49,7 @@ static const char kUtf8Dispatch[] = { * * @param size if -1 implies strlen */ -bool isutf8(const void *data, size_t size) { +bool32 isutf8(const void *data, size_t size) { long c; const char *p, *e; if (size == -1) size = data ? strlen(data) : 0; diff --git a/libc/str/slice.h b/libc/str/slice.h index b582f21de..fc71289f8 100644 --- a/libc/str/slice.h +++ b/libc/str/slice.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_STR_SLICE_H_ #define COSMOPOLITAN_LIBC_STR_SLICE_H_ +#include "libc/stdbool.h" #include "libc/str/str.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ @@ -18,7 +19,6 @@ COSMOPOLITAN_C_START_ int CompareSlices(const char *, size_t, const char *, size_t); int CompareSlicesCase(const char *, size_t, const char *, size_t); -bool StartsWithIgnoreCase(const char *, const char *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/str/startswith.c b/libc/str/startswith.c index 7f86aaad4..99159bf9e 100644 --- a/libc/str/startswith.c +++ b/libc/str/startswith.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param prefix is also NUL-terminated */ -bool startswith(const char *s, const char *prefix) { +bool32 startswith(const char *s, const char *prefix) { for (;;) { if (!*prefix) return true; if (!*s) return false; diff --git a/libc/str/startswith16.c b/libc/str/startswith16.c index eefd03dfa..44d8f70e0 100644 --- a/libc/str/startswith16.c +++ b/libc/str/startswith16.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param prefix is also NUL-terminated */ -bool startswith16(const char16_t *s, const char16_t *prefix) { +bool32 startswith16(const char16_t *s, const char16_t *prefix) { for (;;) { if (!*prefix) return true; if (!*s) return false; diff --git a/libc/str/startswithi.c b/libc/str/startswithi.c index c8dd80e70..08ea7bb8c 100644 --- a/libc/str/startswithi.c +++ b/libc/str/startswithi.c @@ -22,7 +22,7 @@ /** * Checks if string starts with prefix, case insensitively. */ -bool startswithi(const char *s, const char *prefix) { +bool32 startswithi(const char *s, const char *prefix) { for (;;) { if (!*prefix) return true; if (!*s) return false; diff --git a/libc/str/str.h b/libc/str/str.h index 797db1e93..aa3f9f58e 100644 --- a/libc/str/str.h +++ b/libc/str/str.h @@ -178,11 +178,11 @@ uint64_t tpenc(uint32_t) pureconst; char *chomp(char *) libcesque; wchar_t *wchomp(wchar_t *) libcesque; uint64_t __fnv(const void *, size_t) strlenesque; -bool startswith(const char *, const char *) strlenesque; -bool startswithi(const char *, const char *) strlenesque; -bool endswith(const char *, const char *) strlenesque; -bool istext(const void *, size_t) libcesque; -bool isutf8(const void *, size_t) libcesque; +bool32 startswith(const char *, const char *) strlenesque; +bool32 startswithi(const char *, const char *) strlenesque; +bool32 endswith(const char *, const char *) strlenesque; +bool32 istext(const void *, size_t) libcesque; +bool32 isutf8(const void *, size_t) libcesque; char *strsignal_r(int, char[21]) returnsnonnull libcesque __wur; int strerror_wr(int, uint32_t, char *, size_t) dontthrow nocallback; @@ -207,12 +207,12 @@ char16_t *strcat16(char16_t *, const char16_t *) memcpyesque; char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque; char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque; char16_t *memset16(char16_t *, char16_t, size_t) memcpyesque; -bool startswith16(const char16_t *, const char16_t *) strlenesque; -bool endswith16(const char16_t *, const char16_t *) strlenesque; +bool32 startswith16(const char16_t *, const char16_t *) strlenesque; +bool32 endswith16(const char16_t *, const char16_t *) strlenesque; axdx_t tprecode8to16(char16_t *, size_t, const char *); axdx_t tprecode16to8(char *, size_t, const char16_t *); -bool wcsstartswith(const wchar_t *, const wchar_t *) strlenesque; -bool wcsendswith(const wchar_t *, const wchar_t *) strlenesque; +bool32 wcsstartswith(const wchar_t *, const wchar_t *) strlenesque; +bool32 wcsendswith(const wchar_t *, const wchar_t *) strlenesque; char *__join_paths(char *, size_t, const char *, const char *) __wur; #endif /* _COSMO_SOURCE */ diff --git a/libc/str/wcsendswith.c b/libc/str/wcsendswith.c index 56579639e..6e9a6c562 100644 --- a/libc/str/wcsendswith.c +++ b/libc/str/wcsendswith.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param suffix is also NUL-terminated */ -bool wcsendswith(const wchar_t *s, const wchar_t *suffix) { +bool32 wcsendswith(const wchar_t *s, const wchar_t *suffix) { size_t n, m; n = wcslen(s); m = wcslen(suffix); diff --git a/libc/str/wcsstartswith.c b/libc/str/wcsstartswith.c index c1591e96b..59863a46c 100644 --- a/libc/str/wcsstartswith.c +++ b/libc/str/wcsstartswith.c @@ -24,7 +24,7 @@ * @param s is a NUL-terminated string * @param prefix is also NUL-terminated */ -bool _wcsstartswith(const wchar_t *s, const wchar_t *prefix) { +bool32 wcsstartswith(const wchar_t *s, const wchar_t *prefix) { for (;;) { if (!*prefix) return true; if (!*s) return false; diff --git a/libc/testlib/testlib.h b/libc/testlib/testlib.h index 397a0dade..8a1622334 100644 --- a/libc/testlib/testlib.h +++ b/libc/testlib/testlib.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_TESTLIB_H_ #define COSMOPOLITAN_LIBC_TESTLIB_H_ +#include "libc/stdbool.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ /*───────────────────────────────────────────────────────────────────────────│─╗ diff --git a/libc/thread/semaphore.h b/libc/thread/semaphore.h index 3c6d7395f..946f94ba4 100644 --- a/libc/thread/semaphore.h +++ b/libc/thread/semaphore.h @@ -1,7 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_SEMAPHORE_H_ #define COSMOPOLITAN_LIBC_CALLS_SEMAPHORE_H_ #include "libc/calls/struct/timespec.h" -#include "libc/stdbool.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ @@ -20,8 +19,8 @@ typedef struct { int64_t sem_dev; /* named only */ int64_t sem_ino; /* named only */ int sem_pid; /* unnamed only */ - bool sem_lazydelete; /* named only */ - bool sem_pshared; + char sem_lazydelete; /* named only */ + char sem_pshared; int *sem_kernel; }; void *sem_space[32]; diff --git a/libc/thread/tls.h b/libc/thread/tls.h index f0a94d76f..45f1a97ff 100644 --- a/libc/thread/tls.h +++ b/libc/thread/tls.h @@ -9,8 +9,8 @@ COSMOPOLITAN_C_START_ struct CosmoFtrace { /* 16 */ - bool ft_once; /* 0 */ - bool ft_noreentry; /* 1 */ + char ft_once; /* 0 */ + char ft_noreentry; /* 1 */ int ft_skew; /* 4 */ int64_t ft_lastaddr; /* 8 */ }; @@ -48,7 +48,7 @@ char *_mktls(struct CosmoTib **); void __bootstrap_tls(struct CosmoTib *, char *); #ifdef __x86_64__ -extern bool __tls_enabled; +extern char __tls_enabled; #define __tls_enabled_set(x) __tls_enabled = x #elif defined(__aarch64__) #define __tls_enabled true diff --git a/libc/tinymath/magicu.h b/libc/tinymath/magicu.h index d822e2642..80ff14772 100644 --- a/libc/tinymath/magicu.h +++ b/libc/tinymath/magicu.h @@ -24,7 +24,7 @@ forceinline uint32_t __magicu_div(uint32_t x, struct magicu d) { /** * Checks if 𝑑 contains a valid initialized divisor. */ -static inline bool __magicu_valid(struct magicu d) { +static inline bool32 __magicu_valid(struct magicu d) { if (!d.M && !d.s) return false; /* uninitialized */ if (d.s & ~(64 | 63)) return false; /* corrupted */ return true; diff --git a/test/libc/calls/sigaction_test.c b/test/libc/calls/sigaction_test.c index 04ef80e5a..55f840ca8 100644 --- a/test/libc/calls/sigaction_test.c +++ b/test/libc/calls/sigaction_test.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/sigaction.h" #include "libc/calls/calls.h" +#include "libc/calls/internal.h" #include "libc/calls/pledge.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" diff --git a/test/libc/runtime/grow_test.c b/test/libc/runtime/grow_test.c index b1889081f..755c200d1 100644 --- a/test/libc/runtime/grow_test.c +++ b/test/libc/runtime/grow_test.c @@ -19,6 +19,7 @@ #include "libc/intrin/pushpop.internal.h" #include "libc/limits.h" #include "libc/macros.internal.h" +#include "libc/mem/internal.h" #include "libc/mem/mem.h" #include "libc/nt/enum/version.h" #include "libc/runtime/runtime.h" diff --git a/test/libc/sock/sendfile_test.c b/test/libc/sock/sendfile_test.c index 4c380e572..1cb39574c 100644 --- a/test/libc/sock/sendfile_test.c +++ b/test/libc/sock/sendfile_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/tool/build/lib/elfwriter.c b/tool/build/lib/elfwriter.c index e0dc8925d..73da420f8 100644 --- a/tool/build/lib/elfwriter.c +++ b/tool/build/lib/elfwriter.c @@ -23,6 +23,7 @@ #include "libc/log/check.h" #include "libc/mem/arraylist2.internal.h" #include "libc/mem/gc.h" +#include "libc/mem/mem.h" #include "libc/runtime/memtrack.internal.h" #include "libc/stdalign.internal.h" #include "libc/str/str.h" diff --git a/tool/cosmocc/bin/cosmocc b/tool/cosmocc/bin/cosmocc index a22f62e8a..831a52966 100755 --- a/tool/cosmocc/bin/cosmocc +++ b/tool/cosmocc/bin/cosmocc @@ -242,9 +242,6 @@ CPPFLAGS_X86_64="$CPPFLAGS -mno-red-zone" CFLAGS_X86_64="$CFLAGS -mno-tls-direct-seg-refs" LDFLAGS_X86_64="$LDFLAGS -L$BIN/../x86_64-linux-cosmo/lib -Wl,-T,$BIN/../x86_64-linux-cosmo/lib/ape.lds -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=16384" LDLIBS_X86_64="-lcosmo" -if [ $MCOSMO -eq 1 ]; then - CPPFLAGS_X86_64="${CPPFLAGS_X86_64} -D_COSMO_SOURCE" -fi CRT_AARCH64="$BIN/../aarch64-linux-cosmo/lib/crt.o" CPPFLAGS_AARCH64="$CPPFLAGS" @@ -262,6 +259,11 @@ if [ x"$PROG" != x"${PROG%++}" ]; then LDLIBS_AARCH64="-lcxx ${LDLIBS_AARCH64}" fi +if [ $MCOSMO -eq 1 ]; then + CPPFLAGS_X86_64="${CPPFLAGS_X86_64} -D_COSMO_SOURCE" + CPPFLAGS_AARCH64="${CPPFLAGS_AARCH64} -D_COSMO_SOURCE" +fi + log_original if [ $INTENT = cpp ]; then