mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 04:20:30 +00:00
Fix bugs in cosmocc toolchain
This change integrates e58abc1110b335a3341e8ad5821ad8e3880d9bb2 from https://github.com/ahgamut/musl-cross-make/ which fixes the issues we were having with our C language extension for symbolic constants. This change also performs some code cleanup and bug fixes to getaddrinfo(). It's now possible to compile projects like ncurses, readline and python without needing to patch anything upstream, except maybe a line or two. Pretty soon it should be possible to build a Linux distro on Cosmo.
This commit is contained in:
parent
22f81a8d50
commit
23e235b7a5
272 changed files with 3491 additions and 4350 deletions
|
@ -88,7 +88,7 @@ wontreturn void _Exit(int exitcode) {
|
|||
"lidt\t(%rsp)");
|
||||
for (;;) asm("ud2");
|
||||
#else
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,11 @@ privileged wontreturn void _Exit1(int rc) {
|
|||
: /* no outputs */
|
||||
: "a"(__NR_exit_group), "D"(rc)
|
||||
: "rcx", "r11", "memory");
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
} else if (IsWindows()) {
|
||||
__imp_ExitThread(rc);
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
notpossible;
|
||||
#elif defined(__aarch64__)
|
||||
|
|
|
@ -35,7 +35,7 @@ STATIC_YOINK("_init_g_fds");
|
|||
#endif
|
||||
|
||||
struct Fds g_fds;
|
||||
static struct Fd g_fds_static[8];
|
||||
static struct Fd g_fds_static[OPEN_MAX];
|
||||
|
||||
static textwindows dontinline void SetupWinStd(struct Fds *fds, int i, int x) {
|
||||
int64_t h;
|
||||
|
@ -46,7 +46,7 @@ static textwindows dontinline void SetupWinStd(struct Fds *fds, int i, int x) {
|
|||
atomic_store_explicit(&fds->f, i + 1, memory_order_relaxed);
|
||||
}
|
||||
|
||||
textstartup void InitializeFileDescriptors(void) {
|
||||
textstartup void __init_fds(void) {
|
||||
struct Fds *fds;
|
||||
__fds_lock_obj._type = PTHREAD_MUTEX_RECURSIVE;
|
||||
fds = VEIL("r", &g_fds);
|
||||
|
@ -59,7 +59,7 @@ textstartup void InitializeFileDescriptors(void) {
|
|||
kMemtrackFdsStart + kMemtrackFdsSize);
|
||||
} else {
|
||||
fds->p = g_fds_static;
|
||||
fds->e = g_fds_static + ARRAYLEN(g_fds_static);
|
||||
fds->e = g_fds_static + OPEN_MAX;
|
||||
}
|
||||
if (IsMetal()) {
|
||||
extern const char vga_console[];
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
.init.start 305,_init_g_fds
|
||||
push %rdi
|
||||
push %rsi
|
||||
call InitializeFileDescriptors
|
||||
call __init_fds
|
||||
pop %rsi
|
||||
pop %rdi
|
||||
.init.end 305,_init_g_fds
|
||||
|
|
|
@ -267,6 +267,7 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
p = b;
|
||||
f = fmt;
|
||||
e = p + n; // assume if n was negative e < p will be the case
|
||||
tib = __tls_enabled ? __get_tls_privileged() : 0;
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
if (!(c = *f++) || c == '%') break;
|
||||
|
@ -377,7 +378,6 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
goto FormatUnsigned;
|
||||
|
||||
case 'P':
|
||||
tib = __tls_enabled ? __get_tls_privileged() : 0;
|
||||
if (!(tib && (tib->tib_flags & TIB_FLAG_VFORKED))) {
|
||||
if (tib) {
|
||||
x = atomic_load_explicit(&tib->tib_tid, memory_order_relaxed);
|
||||
|
@ -524,7 +524,7 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
case 'm': {
|
||||
int unixerr;
|
||||
uint32_t winerr;
|
||||
unixerr = errno;
|
||||
unixerr = tib ? tib->tib_errno : __errno;
|
||||
winerr = 0;
|
||||
if (IsWindows()) {
|
||||
if (type == 1 && _weaken(__imp_WSAGetLastError)) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
|
||||
// Decentralized section for leaky functions.
|
||||
.section .piro.relo.sort.leaky.1,"aw",@nobits
|
||||
.section .piro.relo.sort.leaky.1,"aw",@progbits
|
||||
.type _leaky_start,@object
|
||||
.type _leaky_end,@object
|
||||
.globl _leaky_start,_leaky_end
|
||||
|
@ -32,7 +32,7 @@ _leaky_start:
|
|||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .piro.relo.sort.leaky.3,"aw",@nobits
|
||||
*/.section .piro.relo.sort.leaky.3,"aw",@progbits
|
||||
_leaky_end:
|
||||
.quad 0
|
||||
.overrun
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/thread/tls2.h"
|
||||
|
||||
/**
|
||||
* Return path for failed Win32 API calls.
|
||||
|
@ -38,6 +39,10 @@ privileged int64_t __winerr(void) {
|
|||
} else {
|
||||
e = ENOSYS;
|
||||
}
|
||||
errno = e;
|
||||
if (__tls_enabled) {
|
||||
__get_tls_privileged()->tib_errno = e;
|
||||
} else {
|
||||
__errno = e;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue