Skip to content

Commit

Permalink
Fix Cosmo Libc ABI conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jul 23, 2024
1 parent a3c7388 commit 222064a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion blink/describeflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <stdbool.h>

const char *DescribeFlags(char *p, size_t n, const struct DescribeFlags *d,
const char *DescribeFlagz(char *p, size_t n, const struct DescribeFlagz *d,
size_t m, const char *prefix, unsigned x) {
bool t;
char b[21];
Expand Down
4 changes: 2 additions & 2 deletions blink/describeflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include "blink/builtin.h"

struct DescribeFlags {
struct DescribeFlagz {
unsigned flag;
const char *name;
};

const char *DescribeFlags(char *, size_t, const struct DescribeFlags *, size_t,
const char *DescribeFlagz(char *, size_t, const struct DescribeFlagz *, size_t,
const char *, unsigned);

#endif /* BLINK_DESCRIBEFLAGS_H_ */
42 changes: 21 additions & 21 deletions blink/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ static const char *const kOpenAccmode[] = {
"O_RDWR", //
};

static const struct DescribeFlags kAccessModes[] = {
static const struct DescribeFlagz kAccessModes[] = {
{R_OK_LINUX, "R_OK"}, //
{W_OK_LINUX, "W_OK"}, //
{X_OK_LINUX, "X_OK"}, //
};

static const struct DescribeFlags kOpenFlags[] = {
static const struct DescribeFlagz kOpenFlags[] = {
{O_APPEND_LINUX, "APPEND"}, //
{O_CREAT_LINUX, "CREAT"}, //
{O_EXCL_LINUX, "EXCL"}, //
Expand All @@ -78,7 +78,7 @@ static const struct DescribeFlags kOpenFlags[] = {
{O_DSYNC_LINUX, "DSYNC"}, //
};

static const struct DescribeFlags kProtFlags[] = {
static const struct DescribeFlagz kProtFlags[] = {
{PROT_READ_LINUX, "READ"}, //
{PROT_WRITE_LINUX, "WRITE"}, //
{PROT_EXEC_LINUX, "EXEC"}, //
Expand All @@ -87,7 +87,7 @@ static const struct DescribeFlags kProtFlags[] = {
{PROT_GROWSUP_LINUX, "GROWSUP"}, //
};

static const struct DescribeFlags kMapFlags[] = {
static const struct DescribeFlagz kMapFlags[] = {
{MAP_SHARED_LINUX, "SHARED"}, //
{MAP_PRIVATE_LINUX, "PRIVATE"}, //
{MAP_FIXED_LINUX, "FIXED"}, //
Expand All @@ -103,7 +103,7 @@ static const struct DescribeFlags kMapFlags[] = {
{MAP_UNINITIALIZED_LINUX, "UNINITIALIZED"}, //
};

static const struct DescribeFlags kSaFlags[] = {
static const struct DescribeFlagz kSaFlags[] = {
{SA_NOCLDSTOP_LINUX, "NOCLDSTOP"}, //
{SA_NOCLDWAIT_LINUX, "NOCLDWAIT"}, //
{SA_SIGINFO_LINUX, "SIGINFO"}, //
Expand All @@ -116,7 +116,7 @@ static const struct DescribeFlags kSaFlags[] = {
{SA_RESETHAND_LINUX, "RESETHAND"}, //
};

static const struct DescribeFlags kAtFlags[] = {
static const struct DescribeFlagz kAtFlags[] = {
{AT_SYMLINK_NOFOLLOW_LINUX, "SYMLINK_NOFOLLOW"}, //
{AT_REMOVEDIR_LINUX, "REMOVEDIR"}, //
{AT_EACCESS_LINUX, "EACCESS"}, //
Expand All @@ -125,7 +125,7 @@ static const struct DescribeFlags kAtFlags[] = {
};

#ifndef DISABLE_THREADS
static const struct DescribeFlags kCloneFlags[] = {
static const struct DescribeFlagz kCloneFlags[] = {
{CLONE_VM_LINUX, "VM"}, //
{CLONE_THREAD_LINUX, "THREAD"}, //
{CLONE_FS_LINUX, "FS"}, //
Expand All @@ -149,15 +149,15 @@ static const struct DescribeFlags kCloneFlags[] = {
#endif

#ifndef DISABLE_NONPOSIX
static const struct DescribeFlags kRenameFlags[] = {
static const struct DescribeFlagz kRenameFlags[] = {
{RENAME_NOREPLACE_LINUX, "NOREPLACE"}, //
{RENAME_EXCHANGE_LINUX, "EXCHANGE"}, //
{RENAME_WHITEOUT_LINUX, "WHITEOUT"}, //
};
#endif

#ifdef HAVE_FORK
static const struct DescribeFlags kWaitFlags[] = {
static const struct DescribeFlagz kWaitFlags[] = {
{WNOHANG_LINUX, "WNOHANG"}, //
{WUNTRACED_LINUX, "WUNTRACED"}, //
{WEXITED_LINUX, "WEXITED"}, //
Expand All @@ -170,7 +170,7 @@ static const struct DescribeFlags kWaitFlags[] = {
#endif

#ifndef DISABLE_SOCKETS
static const struct DescribeFlags kSockFlags[] = {
static const struct DescribeFlagz kSockFlags[] = {
{SOCK_CLOEXEC_LINUX, "CLOEXEC"}, //
{SOCK_NONBLOCK_LINUX, "NONBLOCK"}, //
};
Expand Down Expand Up @@ -456,13 +456,13 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
if (!arg) {
APPEND("F_OK");
} else {
DescribeFlags(tmp, sizeof(tmp), kAccessModes, ARRAYLEN(kAccessModes),
DescribeFlagz(tmp, sizeof(tmp), kAccessModes, ARRAYLEN(kAccessModes),
"", arg);
APPEND("%s", tmp);
}
#ifdef HAVE_FORK
} else if (c == I32_WAITFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kWaitFlags, ARRAYLEN(kWaitFlags), "",
DescribeFlagz(tmp, sizeof(tmp), kWaitFlags, ARRAYLEN(kWaitFlags), "",
arg);
APPEND("%s", tmp);
} else if (c == O_WSTATUS[0]) {
Expand All @@ -484,14 +484,14 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
#endif
} else if (c == I32_PROT[0]) {
if (arg) {
DescribeFlags(tmp, sizeof(tmp), kProtFlags, ARRAYLEN(kProtFlags),
DescribeFlagz(tmp, sizeof(tmp), kProtFlags, ARRAYLEN(kProtFlags),
"PROT_", arg);
APPEND("%s", tmp);
} else {
APPEND("PROT_NONE");
}
} else if (c == I32_MAPFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kMapFlags, ARRAYLEN(kMapFlags), "MAP_",
DescribeFlagz(tmp, sizeof(tmp), kMapFlags, ARRAYLEN(kMapFlags), "MAP_",
arg);
APPEND("%s", tmp);
} else if (c == I32_OFLAGS[0]) {
Expand All @@ -501,19 +501,19 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
arg2 &= ~O_ACCMODE_LINUX;
}
if (arg2) {
DescribeFlags(tmp, sizeof(tmp), kOpenFlags, ARRAYLEN(kOpenFlags), "O_",
DescribeFlagz(tmp, sizeof(tmp), kOpenFlags, ARRAYLEN(kOpenFlags), "O_",
arg2);
APPEND("|%s", tmp);
}
if (!(arg & O_CREAT_LINUX) && !(arg & __O_TMPFILE_LINUX)) {
++i; // ignore mode
}
} else if (c == I32_ATFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kAtFlags, ARRAYLEN(kAtFlags), "AT_", arg);
DescribeFlagz(tmp, sizeof(tmp), kAtFlags, ARRAYLEN(kAtFlags), "AT_", arg);
APPEND("%s", tmp);
#ifndef DISABLE_THREADS
} else if (c == I32_CLONEFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kCloneFlags, ARRAYLEN(kCloneFlags),
DescribeFlagz(tmp, sizeof(tmp), kCloneFlags, ARRAYLEN(kCloneFlags),
"CLONE_", arg);
APPEND("%s", tmp);
#endif
Expand Down Expand Up @@ -627,7 +627,7 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
break;
}
if (Read64(sa->flags)) {
DescribeFlags(tmp, sizeof(tmp), kSaFlags, ARRAYLEN(kSaFlags), "SA_",
DescribeFlagz(tmp, sizeof(tmp), kSaFlags, ARRAYLEN(kSaFlags), "SA_",
Read64(sa->flags));
APPEND(", .sa_flags=%s", tmp);
}
Expand Down Expand Up @@ -670,7 +670,7 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
APPEND("%s", GetMagicNumber(kClock, ARRAYLEN(kClock), arg));
#ifndef DISABLE_SOCKETS
} else if (c == I32_SOCKFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kSockFlags, ARRAYLEN(kSockFlags), "SOCK_",
DescribeFlagz(tmp, sizeof(tmp), kSockFlags, ARRAYLEN(kSockFlags), "SOCK_",
arg);
APPEND("%s", tmp);
} else if (IS_ADDR(c)) {
Expand Down Expand Up @@ -704,7 +704,7 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
#endif
#ifndef DISABLE_NONPOSIX
} else if (c == I32_RENFLAGS[0]) {
DescribeFlags(tmp, sizeof(tmp), kRenameFlags, ARRAYLEN(kRenameFlags),
DescribeFlagz(tmp, sizeof(tmp), kRenameFlags, ARRAYLEN(kRenameFlags),
"RENAME_", arg);
APPEND("%s", tmp);
#endif
Expand Down Expand Up @@ -750,7 +750,7 @@ void Strace(struct Machine *m, const char *func, bool isentry, const char *fmt,
}
} else if (arg == F_SETFL_LINUX) {
i32 flags = va_arg(va, i64);
DescribeFlags(tmp, sizeof(tmp), kOpenFlags, ARRAYLEN(kOpenFlags), "O_",
DescribeFlagz(tmp, sizeof(tmp), kOpenFlags, ARRAYLEN(kOpenFlags), "O_",
flags);
APPEND("%s", tmp);
} else if (arg == F_SETOWN_LINUX) {
Expand Down
2 changes: 1 addition & 1 deletion blink/tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define LINUX_VERSION MKVERSION(LINUX_MAJOR, LINUX_MINOR, LINUX_PATCH)
#define BLINK_VERSION MKVERSION(BLINK_MAJOR, BLINK_MINOR, BLINK_PATCH)

#if CAN_64BIT && (defined(__APPLE__) || defined(__COSMOPOLITAN__))
#if CAN_64BIT && defined(__APPLE__)
#define kSkew 0x088800000000
#else
#define kSkew 0x000000000000
Expand Down
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ if config noop "checking for -fno-stack-protector... "; then
UOPFLAGS="-fno-stack-protector ${UOPFLAGS}"
fi

# avoid cosmo libc function call tracing messing up micro-ops
EXTRA_CFLAGS=-fpatchable-function-entry=0,0
if config noop "checking for -fpatchable-function-entry=0,0... "; then
UOPFLAGS="-fpatchable-function-entry=0,0 ${UOPFLAGS}"
fi

# avoid creating stack frames in micro-op functions
if [ "${MODE}" != "prof" ]; then
EXTRA_CFLAGS=-fomit-frame-pointer
Expand Down

0 comments on commit 222064a

Please sign in to comment.