mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +00:00
Add atomics to chibicc
This change also fixes #434 and makes the chibicc assembler better.
This commit is contained in:
parent
5ddf43332e
commit
a988896048
21 changed files with 650 additions and 445 deletions
|
@ -164,9 +164,7 @@ struct ElfWriter *elfwriter_open(const char *path, int mode) {
|
|||
struct ElfWriter *elf;
|
||||
CHECK_NOTNULL((elf = calloc(1, sizeof(struct ElfWriter))));
|
||||
CHECK_NOTNULL((elf->path = strdup(path)));
|
||||
CHECK_NE(-1, asprintf(&elf->tmppath, "%s.%d", elf->path, getpid()));
|
||||
CHECK_NE(-1, (elf->fd = open(elf->tmppath,
|
||||
O_CREAT | O_TRUNC | O_RDWR | O_EXCL, mode)));
|
||||
CHECK_NE(-1, (elf->fd = open(elf->path, O_CREAT | O_TRUNC | O_RDWR, mode)));
|
||||
CHECK_NE(-1, ftruncate(elf->fd, (elf->mapsize = FRAMESIZE)));
|
||||
CHECK_NE(MAP_FAILED, (elf->map = mmap((void *)(intptr_t)kFixedmapStart,
|
||||
elf->mapsize, PROT_READ | PROT_WRITE,
|
||||
|
@ -187,7 +185,6 @@ void elfwriter_close(struct ElfWriter *elf) {
|
|||
CHECK_NE(-1, munmap(elf->map, elf->mapsize));
|
||||
CHECK_NE(-1, ftruncate(elf->fd, elf->wrote));
|
||||
CHECK_NE(-1, close(elf->fd));
|
||||
CHECK_NE(-1, rename(elf->tmppath, elf->path));
|
||||
freeinterner(elf->shstrtab);
|
||||
freeinterner(elf->strtab);
|
||||
free(elf->shdrs->p);
|
||||
|
|
|
@ -34,7 +34,6 @@ struct ElfWriterRela {
|
|||
|
||||
struct ElfWriter {
|
||||
char *path;
|
||||
char *tmppath;
|
||||
int fd;
|
||||
void *map;
|
||||
size_t mapsize;
|
||||
|
|
|
@ -833,11 +833,11 @@ static void DescribeAddress(char buf[40], uint32_t addr, uint16_t port) {
|
|||
char *p;
|
||||
const char *s;
|
||||
p = buf;
|
||||
p = FormatUint64(p, (addr & 0xFF000000) >> 030), *p++ = '.';
|
||||
p = FormatUint64(p, (addr & 0x00FF0000) >> 020), *p++ = '.';
|
||||
p = FormatUint64(p, (addr & 0x0000FF00) >> 010), *p++ = '.';
|
||||
p = FormatUint64(p, (addr & 0x000000FF) >> 000), *p++ = ':';
|
||||
p = FormatUint64(p, port);
|
||||
p = FormatUint32(p, (addr & 0xFF000000) >> 030), *p++ = '.';
|
||||
p = FormatUint32(p, (addr & 0x00FF0000) >> 020), *p++ = '.';
|
||||
p = FormatUint32(p, (addr & 0x0000FF00) >> 010), *p++ = '.';
|
||||
p = FormatUint32(p, (addr & 0x000000FF) >> 000), *p++ = ':';
|
||||
p = FormatUint32(p, port);
|
||||
*p = '\0';
|
||||
assert(p - buf < 40);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue