mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-24 03: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
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "tool/build/lib/throw.h"
|
||||
|
@ -44,7 +44,7 @@ uint8_t *GetSegment(struct Machine *m, uint32_t rde, int s) {
|
|||
case 7:
|
||||
OpUd(m, rde);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ uint64_t AddressSi(struct Machine *m, uint32_t rde) {
|
|||
case XED_MODE_LEGACY:
|
||||
return DataSegment(m, rde, Read32(m->si));
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,6 @@ uint64_t AddressDi(struct Machine *m, uint32_t rde) {
|
|||
case XED_MODE_LEGACY:
|
||||
return i + Read32(m->di);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ struct Asmdown *ParseAsmdown(const char *code, size_t size) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
return ad;
|
||||
|
|
|
@ -280,7 +280,7 @@ static char *DisBis(struct Dis *d, uint32_t rde, char *p) {
|
|||
base = "bx";
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
if (base || index) {
|
||||
|
|
|
@ -862,7 +862,7 @@ const char *DisSpecMap1(struct XedDecodedInst *x, char *p) {
|
|||
case 3:
|
||||
return "movsldup %Vq Wq";
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
break;
|
||||
case 0x13:
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/machine.h"
|
||||
#include "tool/build/lib/memory.h"
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "tool/build/lib/throw.h"
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ struct AddrSeg LoadEffectiveAddress(const struct Machine *m, uint32_t rde) {
|
|||
i += Read16(m->bx);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
i &= 0xffff;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ ssize_t PrintPanels(int fd, long pn, struct Panel *p, long tyn, long txn) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
if (x > p[i].right) {
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/pty.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
|
@ -28,7 +29,6 @@
|
|||
#include "libc/str/unicode.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "tool/build/lib/pty.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Pseudoteletypewriter
|
||||
|
@ -1158,7 +1158,7 @@ ssize_t PtyWrite(struct Pty *pty, const void *data, size_t n) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
return n;
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/ssemov.h"
|
||||
#include "libc/intrin/pmovmskb.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/memory.h"
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "tool/build/lib/ssemov.h"
|
||||
#include "tool/build/lib/throw.h"
|
||||
|
||||
static void MovdquVdqWdq(struct Machine *m, uint32_t rde) {
|
||||
|
@ -314,7 +314,7 @@ void OpMovWpsVps(struct Machine *m, uint32_t rde) {
|
|||
MovssWpsVps(m, rde);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ void OpMov0f10(struct Machine *m, uint32_t rde) {
|
|||
MovssVpsWps(m, rde);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +443,7 @@ void OpMov0f12(struct Machine *m, uint32_t rde) {
|
|||
MovsldupVqWq(m, rde);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/stack.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/memory.h"
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "tool/build/lib/stack.h"
|
||||
#include "tool/build/lib/throw.h"
|
||||
|
||||
static const uint8_t kStackOsz[2][3] = {
|
||||
|
@ -76,7 +76,7 @@ static void PushN(struct Machine *m, uint32_t rde, uint64_t x, unsigned osz) {
|
|||
Write64(m->sp, v);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
WriteStackWord(AccessRam(m, v, osz, p, b, false), rde, osz, x);
|
||||
EndStore(m, v, osz, p, b);
|
||||
|
@ -113,7 +113,7 @@ static uint64_t PopN(struct Machine *m, uint32_t rde, uint16_t extra,
|
|||
v += Read64(m->ss);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
return ReadStackWord(AccessRam(m, v, osz, p, b, true), osz);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ void OpPopZvq(struct Machine *m, uint32_t rde) {
|
|||
Write16(RegRexbSrm(m, rde), x);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ void OpLeave(struct Machine *m, uint32_t rde) {
|
|||
Write16(m->bp, Pop(m, rde, 0));
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ relegated void OpPusha(struct Machine *m, uint32_t rde) {
|
|||
case XED_MODE_LONG:
|
||||
OpUd(m, rde);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ relegated void OpPopa(struct Machine *m, uint32_t rde) {
|
|||
case XED_MODE_LONG:
|
||||
OpUd(m, rde);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/string.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include "tool/build/lib/machine.h"
|
||||
#include "tool/build/lib/memory.h"
|
||||
#include "tool/build/lib/modrm.h"
|
||||
#include "tool/build/lib/string.h"
|
||||
#include "tool/build/lib/throw.h"
|
||||
|
||||
static uint64_t ReadInt(uint8_t p[8], unsigned long w) {
|
||||
|
@ -43,7 +43,7 @@ static uint64_t ReadInt(uint8_t p[8], unsigned long w) {
|
|||
case 3:
|
||||
return Read64(p);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ static void WriteInt(uint8_t p[8], uint64_t x, unsigned long w) {
|
|||
Write64(p, x);
|
||||
break;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ static void AddDi(struct Machine *m, uint32_t rde, uint64_t x) {
|
|||
Write16(m->di, Read16(m->di) + x);
|
||||
return;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ static void AddSi(struct Machine *m, uint32_t rde, uint64_t x) {
|
|||
Write16(m->si, Read16(m->si) + x);
|
||||
return;
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ static uint64_t ReadCx(struct Machine *m, uint32_t rde) {
|
|||
case XED_MODE_REAL:
|
||||
return Read16(m->cx);
|
||||
default:
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue