Skip to content

Commit

Permalink
Release Cosmopolitan v3.6.0
Browse files Browse the repository at this point in the history
This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
  • Loading branch information
jart committed Jul 23, 2024
1 parent 62ace36 commit 5660ec4
Show file tree
Hide file tree
Showing 1,585 changed files with 124,767 additions and 279,058 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ export MODE
export SOURCE_DATE_EPOCH
export TMPDIR

COSMOCC = .cosmocc/3.5.7
COSMOCC = .cosmocc/3.6.0
BOOTSTRAP = $(COSMOCC)/bin
TOOLCHAIN = $(COSMOCC)/bin/$(ARCH)-linux-cosmo-
DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.5.7 596876951b62ad2530c63afc40edd805d751fcb2416e544d249af04ad00bb4ed)
DOWNLOAD := $(shell build/download-cosmocc.sh $(COSMOCC) 3.6.0 4918c45ac3e0972ff260e2a249e25716881e39fb679d5e714ae216a2ef6c3f7e)

AS = $(TOOLCHAIN)as
CC = $(TOOLCHAIN)gcc
Expand Down Expand Up @@ -293,8 +293,7 @@ include third_party/openmp/BUILD.mk # │
include third_party/pcre/BUILD.mk #
include third_party/less/BUILD.mk #
include net/https/BUILD.mk #
include third_party/regex/BUILD.mk #
include third_party/bash/BUILD.mk #─┘
include third_party/regex/BUILD.mk #─┘
include third_party/tidy/BUILD.mk
include third_party/BUILD.mk
include third_party/nsync/testing/BUILD.mk
Expand Down
4 changes: 2 additions & 2 deletions build/definitions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ DEFAULT_CPPFLAGS += \
-isystem libc/isystem

DEFAULT_CFLAGS = \
-std=gnu2x
-std=gnu23

DEFAULT_CXXFLAGS = \
-std=gnu++20 \
-std=gnu++23 \
-fno-rtti \
-fno-exceptions \
-fuse-cxa-atexit \
Expand Down
3 changes: 3 additions & 0 deletions ctl/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <__atomic/fence.h>
#include <stdckdint.h>

#include "libc/mem/mem.h"
#include "libc/str/str.h"

namespace ctl {

void
Expand Down
11,603 changes: 0 additions & 11,603 deletions examples/unbourne.c

This file was deleted.

4 changes: 2 additions & 2 deletions libc/calls/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ int nice(int) libcesque;
int open(const char *, int, ...) libcesque;
int openat(int, const char *, int, ...) libcesque;
int pause(void) libcesque;
int pipe(int[hasatleast 2]) libcesque;
int pipe2(int[hasatleast 2], int) libcesque;
int pipe(int[2]) libcesque;
int pipe2(int[2], int) libcesque;
int posix_fadvise(int, int64_t, int64_t, int) libcesque;
int posix_madvise(void *, uint64_t, int) libcesque;
int raise(int) libcesque;
Expand Down
2 changes: 1 addition & 1 deletion libc/calls/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @asyncsignalsafe
* @see pipe2()
*/
int pipe(int pipefd[hasatleast 2]) {
int pipe(int pipefd[2]) {
int rc;
if (!pipefd) {
// needed for windows which is polyfilled
Expand Down
2 changes: 1 addition & 1 deletion libc/calls/pipe2.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @param flags can have O_CLOEXEC or O_DIRECT or O_NONBLOCK
* @return 0 on success, or -1 w/ errno and pipefd isn't modified
*/
int pipe2(int pipefd[hasatleast 2], int flags) {
int pipe2(int pipefd[2], int flags) {
int rc;
if (flags & ~(O_CLOEXEC | O_NONBLOCK | (O_DIRECT != -1u ? O_DIRECT : 0))) {
return einval();
Expand Down
4 changes: 2 additions & 2 deletions libc/intrin/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ struct Map {
intptr_t hand; /* windows nt only */
union {
struct Tree tree;
struct Map *free;
struct Map *freed;
};
};

struct Maps {
atomic_int lock;
struct Tree *maps;
_Atomic(struct Map *) free;
_Atomic(struct Map *) freed;
size_t count;
size_t pages;
_Atomic(char *) pick;
Expand Down
24 changes: 12 additions & 12 deletions libc/intrin/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static int __muntrack(char *addr, size_t size, int pagesz,
if (addr <= map_addr && addr + PGUP(size) >= map_addr + PGUP(map_size)) {
// remove mapping completely
tree_remove(&__maps.maps, &map->tree);
map->free = *deleted;
map->freed = *deleted;
*deleted = map;
__maps.pages -= (map_size + pagesz - 1) / pagesz;
__maps.count -= 1;
Expand All @@ -155,7 +155,7 @@ static int __muntrack(char *addr, size_t size, int pagesz,
__maps.pages -= (left + pagesz - 1) / pagesz;
leftmap->addr = map_addr;
leftmap->size = left;
leftmap->free = *deleted;
leftmap->freed = *deleted;
*deleted = leftmap;
__maps_check();
} else {
Expand All @@ -171,7 +171,7 @@ static int __muntrack(char *addr, size_t size, int pagesz,
__maps.pages -= (right + pagesz - 1) / pagesz;
rightmap->addr = addr;
rightmap->size = right;
rightmap->free = *deleted;
rightmap->freed = *deleted;
*deleted = rightmap;
__maps_check();
} else {
Expand Down Expand Up @@ -200,7 +200,7 @@ static int __muntrack(char *addr, size_t size, int pagesz,
__maps.count += 1;
middlemap->addr = addr;
middlemap->size = size;
middlemap->free = *deleted;
middlemap->freed = *deleted;
*deleted = middlemap;
__maps_check();
} else {
Expand All @@ -217,9 +217,9 @@ static int __muntrack(char *addr, size_t size, int pagesz,
void __maps_free(struct Map *map) {
map->size = 0;
map->addr = MAP_FAILED;
map->free = atomic_load_explicit(&__maps.free, memory_order_relaxed);
map->freed = atomic_load_explicit(&__maps.freed, memory_order_relaxed);
for (;;) {
if (atomic_compare_exchange_weak_explicit(&__maps.free, &map->free, map,
if (atomic_compare_exchange_weak_explicit(&__maps.freed, &map->freed, map,
memory_order_release,
memory_order_relaxed))
break;
Expand All @@ -229,7 +229,7 @@ void __maps_free(struct Map *map) {
static void __maps_free_all(struct Map *list) {
struct Map *next;
for (struct Map *map = list; map; map = next) {
next = map->free;
next = map->freed;
__maps_free(map);
}
}
Expand Down Expand Up @@ -285,9 +285,9 @@ static void __maps_insert(struct Map *map) {

struct Map *__maps_alloc(void) {
struct Map *map;
map = atomic_load_explicit(&__maps.free, memory_order_relaxed);
map = atomic_load_explicit(&__maps.freed, memory_order_relaxed);
while (map) {
if (atomic_compare_exchange_weak_explicit(&__maps.free, &map, map->free,
if (atomic_compare_exchange_weak_explicit(&__maps.freed, &map, map->freed,
memory_order_acquire,
memory_order_relaxed))
return map;
Expand Down Expand Up @@ -346,7 +346,7 @@ static int __munmap(char *addr, size_t size) {

// delete mappings
int rc = 0;
for (struct Map *map = deleted; map; map = map->free) {
for (struct Map *map = deleted; map; map = map->freed) {
if (!IsWindows()) {
if (sys_munmap(map->addr, map->size))
rc = -1;
Expand All @@ -359,7 +359,7 @@ static int __munmap(char *addr, size_t size) {
}
}

// free mappings
// freed mappings
__maps_free_all(deleted);

return rc;
Expand Down Expand Up @@ -451,7 +451,7 @@ static void *__mmap_chunk(void *addr, size_t size, int prot, int flags, int fd,
}

// polyfill map fixed noreplace
// we assume non-linux gives us addr if it's free
// we assume non-linux gives us addr if it's freed
// that's what linux (e.g. rhel7) did before noreplace
if (noreplace && res.addr != addr) {
if (!IsWindows()) {
Expand Down
1 change: 0 additions & 1 deletion libc/isystem/__threading_support

This file was deleted.

1 change: 1 addition & 0 deletions libc/isystem/amxcomplexintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/amxcomplexintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/amxfp16intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/amxfp16intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/avxifmaintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/avxifmaintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/avxneconvertintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/avxneconvertintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/avxvnniint16intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/avxvnniint16intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/avxvnniint8intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/avxvnniint8intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/bmmintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/bmmintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/cmpccxaddintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/cmpccxaddintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/prfchiintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/prfchiintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/raointintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/raointintrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/sha512intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/sha512intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/sm3intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/sm3intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/sm4intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/sm4intrin.internal.h"
1 change: 1 addition & 0 deletions libc/isystem/usermsrintrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "third_party/intel/usermsrintrin.internal.h"
5 changes: 1 addition & 4 deletions libc/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ typedef double double_t;
#define fpclassify(x) \
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)

#define signbit(x) \
(sizeof(x) == sizeof(long double) ? __builtin_signbitl(x) \
: sizeof(x) == sizeof(float) ? __builtin_signbitf(x) \
: __builtin_signbit(x))
#define signbit(x) __builtin_signbit(x)

extern int signgam;

Expand Down
2 changes: 1 addition & 1 deletion libc/proc/fork-nt.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ textwindows void WinMainForked(void) {
__threaded = false;

// fixup memory manager
__maps.free = 0;
__maps.maps = 0;
__maps.freed = 0;
__maps.count = 0;
__maps.pages = 0;
for (struct Tree *e = tree_first(maps); e; e = tree_next(e)) {
Expand Down
3 changes: 3 additions & 0 deletions libc/stdio/fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ static int __fmt_stoa(int out(const char *, void *, size_t), void *arg,
} else if (signbit == 15) {
precision = strnlen16((const char16_t *)p, precision);
} else {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overread"
precision = strnlen(p, precision);
#pragma GCC diagnostic pop
}
}

Expand Down
2 changes: 1 addition & 1 deletion libc/tinymath/lgamma_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static double sin_pi(double x)
double lgamma_r(double x, int *signgamp)
{
union {double f; uint64_t i;} u = {x};
double_t t,y,z,nadj,p,p1,p2,p3,q,r,w;
double_t t,y,z,nadj=0,p,p1,p2,p3,q,r,w;
uint32_t ix;
int sign,i;

Expand Down
2 changes: 1 addition & 1 deletion libc/tinymath/lgammaf_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static float sin_pi(float x)
float lgammaf_r(float x, int *signgamp)
{
union {float f; uint32_t i;} u = {x};
float t,y,z,nadj,p,p1,p2,p3,q,r,w;
float t,y,z,nadj=0,p,p1,p2,p3,q,r,w;
uint32_t ix;
int i,sign;

Expand Down
2 changes: 1 addition & 1 deletion libc/tinymath/lgammal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static long double sin_pi(long double x)
}

long double lgammal_r(long double x, int *sg) {
long double t, y, z, nadj, p, p1, p2, q, r, w;
long double t, y, z, nadj=0, p, p1, p2, q, r, w;
union ldshape u = {x};
uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
int sign = u.i.se >> 15;
Expand Down
14 changes: 5 additions & 9 deletions test/libc/calls/stackoverflow1_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,19 @@ void SetUp(void) {
sigaction(SIGSEGV, &sa, 0);
}

int StackOverflow(int f(), int n) {
if (n < INT_MAX) {
return f(f, n + 1) - 1;
} else {
return INT_MAX;
}
int StackOverflow(void);
int (*pStackOverflow)(void) = StackOverflow;
int StackOverflow(void) {
return pStackOverflow();
}

int (*pStackOverflow)(int (*)(), int) = StackOverflow;

TEST(stackoverflow, standardStack_altStack_process_longjmp) {
if (IsTiny())
return; // TODO(jart): why?

int jumpcode;
if (!(jumpcode = setjmp(recover))) {
exit(pStackOverflow(pStackOverflow, 0));
exit(pStackOverflow());
}
ASSERT_EQ(123, jumpcode);
ASSERT_TRUE(smashed_stack);
Expand Down
14 changes: 5 additions & 9 deletions test/libc/calls/stackoverflow2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ void CrashHandler(int sig, siginfo_t *si, void *ctx) {
longjmp(recover, 123);
}

int StackOverflow(int f(), int n) {
if (n < INT_MAX) {
return f(f, n + 1) - 1;
} else {
return INT_MAX;
}
int StackOverflow(void);
int (*pStackOverflow)(void) = StackOverflow;
int StackOverflow(void) {
return pStackOverflow();
}

int (*pStackOverflow)(int (*)(), int) = StackOverflow;

void *MyPosixThread(void *arg) {
int jumpcode;
struct sigaction sa, o1, o2;
Expand All @@ -75,7 +71,7 @@ void *MyPosixThread(void *arg) {
sigaction(SIGBUS, &sa, &o1);
sigaction(SIGSEGV, &sa, &o2);
if (!(jumpcode = setjmp(recover))) {
exit(pStackOverflow(pStackOverflow, 0));
exit(pStackOverflow());
}
ASSERT_EQ(123, jumpcode);
sigaction(SIGSEGV, &o2, 0);
Expand Down
14 changes: 5 additions & 9 deletions test/libc/calls/stackoverflow3_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,12 @@ void CrashHandler(int sig, siginfo_t *si, void *arg) {
#endif
}

int StackOverflow(int f(), int n) {
if (n < INT_MAX) {
return f(f, n + 1) - 1;
} else {
return INT_MAX;
}
int StackOverflow(void);
int (*pStackOverflow)(void) = StackOverflow;
int StackOverflow(void) {
return pStackOverflow();
}

int (*pStackOverflow)(int (*)(), int) = StackOverflow;

void *MyPosixThread(void *arg) {
struct sigaction sa;
struct sigaltstack ss;
Expand All @@ -107,7 +103,7 @@ void *MyPosixThread(void *arg) {
sa.sa_sigaction = CrashHandler;
sigaction(SIGBUS, &sa, 0);
sigaction(SIGSEGV, &sa, 0);
exit(pStackOverflow(pStackOverflow, 0));
exit(pStackOverflow());
return 0;
}

Expand Down
14 changes: 5 additions & 9 deletions test/libc/calls/stackoverflow4_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ void CrashHandler(int sig) {
pthread_exit((void *)123L);
}

int StackOverflow(int f(), int n) {
if (n < INT_MAX) {
return f(f, n + 1) - 1;
} else {
return INT_MAX;
}
int StackOverflow(void);
int (*pStackOverflow)(void) = StackOverflow;
int StackOverflow(void) {
return pStackOverflow();
}

int (*pStackOverflow)(int (*)(), int) = StackOverflow;

void *MyPosixThread(void *arg) {
struct sigaction sa;
struct sigaltstack ss;
Expand All @@ -67,7 +63,7 @@ void *MyPosixThread(void *arg) {
sa.sa_handler = CrashHandler;
sigaction(SIGBUS, &sa, 0);
sigaction(SIGSEGV, &sa, 0);
exit(pStackOverflow(pStackOverflow, 0));
exit(pStackOverflow());
return 0;
}

Expand Down
Loading

0 comments on commit 5660ec4

Please sign in to comment.