mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-24 11:30:29 +00:00
Replace COSMO define with _COSMO_SOURCE
This change might cause ABI breakages for /opt/cosmos. It's needed to help us better conform to header declaration practices.
This commit is contained in:
parent
a033b65a33
commit
c776a32f75
238 changed files with 858 additions and 1069 deletions
14
third_party/chibicc/as.c
vendored
14
third_party/chibicc/as.c
vendored
|
@ -481,11 +481,11 @@ static void ReadFlags(struct As *a, int argc, char *argv[]) {
|
|||
for (i = 1; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "-o")) {
|
||||
a->outpath = StrDup(a, argv[++i]);
|
||||
} else if (_startswith(argv[i], "-o")) {
|
||||
} else if (startswith(argv[i], "-o")) {
|
||||
a->outpath = StrDup(a, argv[i] + 2);
|
||||
} else if (!strcmp(argv[i], "-I")) {
|
||||
SaveString(&a->incpaths, strdup(argv[++i]));
|
||||
} else if (_startswith(argv[i], "-I")) {
|
||||
} else if (startswith(argv[i], "-I")) {
|
||||
SaveString(&a->incpaths, strdup(argv[i] + 2));
|
||||
} else if (!strcmp(argv[i], "-Z")) {
|
||||
a->inhibiterr = true;
|
||||
|
@ -1669,13 +1669,13 @@ static int GrabSection(struct As *a, int name, int flags, int type, int group,
|
|||
static void OnSection(struct As *a, struct Slice s) {
|
||||
int name, flags, type, group = -1, comdat = -1;
|
||||
name = SliceDup(a, GetSlice(a));
|
||||
if (_startswith(a->strings.p[name], ".text")) {
|
||||
if (startswith(a->strings.p[name], ".text")) {
|
||||
flags = SHF_ALLOC | SHF_EXECINSTR;
|
||||
type = SHT_PROGBITS;
|
||||
} else if (_startswith(a->strings.p[name], ".data")) {
|
||||
} else if (startswith(a->strings.p[name], ".data")) {
|
||||
flags = SHF_ALLOC | SHF_WRITE;
|
||||
type = SHT_PROGBITS;
|
||||
} else if (_startswith(a->strings.p[name], ".bss")) {
|
||||
} else if (startswith(a->strings.p[name], ".bss")) {
|
||||
flags = SHF_ALLOC | SHF_WRITE;
|
||||
type = SHT_NOBITS;
|
||||
} else {
|
||||
|
@ -2609,8 +2609,8 @@ static bool HasXmmOnLine(struct As *a) {
|
|||
int i;
|
||||
for (i = 0; !IsPunct(a, a->i + i, ';'); ++i) {
|
||||
if (IsSlice(a, a->i + i) && a->slices.p[a->things.p[a->i + i].i].n >= 4 &&
|
||||
(_startswith(a->slices.p[a->things.p[a->i + i].i].p, "xmm") ||
|
||||
_startswith(a->slices.p[a->things.p[a->i + i].i].p, "%xmm"))) {
|
||||
(startswith(a->slices.p[a->things.p[a->i + i].i].p, "xmm") ||
|
||||
startswith(a->slices.p[a->things.p[a->i + i].i].p, "%xmm"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
4
third_party/chibicc/asm.c
vendored
4
third_party/chibicc/asm.c
vendored
|
@ -370,7 +370,7 @@ static Token *ParseAsmClobbers(Asm *a, Token *tok) {
|
|||
a->flagclob = true;
|
||||
} else if ((i = GetIndexOfRegisterName(s)) != -1) {
|
||||
a->regclob |= 1 << i;
|
||||
} else if (_startswith(s, "xmm") && isdigit(s[3]) &&
|
||||
} else if (startswith(s, "xmm") && isdigit(s[3]) &&
|
||||
(!s[4] || isdigit(s[4]))) {
|
||||
i = s[3] - '0';
|
||||
if (s[4]) {
|
||||
|
@ -381,7 +381,7 @@ static Token *ParseAsmClobbers(Asm *a, Token *tok) {
|
|||
a->xmmclob |= 1 << i;
|
||||
} else if (!strcmp(s, "st")) {
|
||||
a->x87clob |= 1;
|
||||
} else if (_startswith(s, "st(") && isdigit(s[3]) && s[4] == ')') {
|
||||
} else if (startswith(s, "st(") && isdigit(s[3]) && s[4] == ')') {
|
||||
i = s[3] - '0';
|
||||
i &= 7;
|
||||
a->x87clob |= 1 << i;
|
||||
|
|
26
third_party/chibicc/chibicc.c
vendored
26
third_party/chibicc/chibicc.c
vendored
|
@ -218,7 +218,7 @@ static void parse_args(int argc, char **argv) {
|
|||
atexit(PrintMemoryUsage);
|
||||
} else if (!strcmp(argv[i], "-o")) {
|
||||
opt_o = argv[++i];
|
||||
} else if (_startswith(argv[i], "-o")) {
|
||||
} else if (startswith(argv[i], "-o")) {
|
||||
opt_o = argv[i] + 2;
|
||||
} else if (!strcmp(argv[i], "-S")) {
|
||||
opt_S = true;
|
||||
|
@ -242,19 +242,19 @@ static void parse_args(int argc, char **argv) {
|
|||
opt_P = true;
|
||||
} else if (!strcmp(argv[i], "-I")) {
|
||||
strarray_push(&include_paths, argv[++i]);
|
||||
} else if (_startswith(argv[i], "-I")) {
|
||||
} else if (startswith(argv[i], "-I")) {
|
||||
strarray_push(&include_paths, argv[i] + 2);
|
||||
} else if (!strcmp(argv[i], "-iquote")) {
|
||||
strarray_push(&include_paths, argv[++i]);
|
||||
} else if (_startswith(argv[i], "-iquote")) {
|
||||
} else if (startswith(argv[i], "-iquote")) {
|
||||
strarray_push(&include_paths, argv[i] + strlen("-iquote"));
|
||||
} else if (!strcmp(argv[i], "-isystem")) {
|
||||
strarray_push(&include_paths, argv[++i]);
|
||||
} else if (_startswith(argv[i], "-isystem")) {
|
||||
} else if (startswith(argv[i], "-isystem")) {
|
||||
strarray_push(&include_paths, argv[i] + strlen("-isystem"));
|
||||
} else if (!strcmp(argv[i], "-D")) {
|
||||
define(argv[++i]);
|
||||
} else if (_startswith(argv[i], "-D")) {
|
||||
} else if (startswith(argv[i], "-D")) {
|
||||
define(argv[i] + 2);
|
||||
} else if (!strcmp(argv[i], "-U")) {
|
||||
undef_macro(argv[++i]);
|
||||
|
@ -266,9 +266,9 @@ static void parse_args(int argc, char **argv) {
|
|||
opt_x = parse_opt_x(argv[++i]);
|
||||
} else if (!strncmp(argv[i], "-x", 2)) {
|
||||
opt_x = parse_opt_x(argv[i] + 2);
|
||||
} else if (_startswith(argv[i], "-Wa")) {
|
||||
} else if (startswith(argv[i], "-Wa")) {
|
||||
strarray_push_comma(&as_extra_args, argv[i] + 3);
|
||||
} else if (_startswith(argv[i], "-Wl")) {
|
||||
} else if (startswith(argv[i], "-Wl")) {
|
||||
strarray_push_comma(&ld_extra_args, argv[i] + 3);
|
||||
} else if (!strcmp(argv[i], "-Xassembler")) {
|
||||
strarray_push(&as_extra_args, argv[++i]);
|
||||
|
@ -336,7 +336,7 @@ static void parse_args(int argc, char **argv) {
|
|||
} else if (!strcmp(argv[i], "-L")) {
|
||||
strarray_push(&ld_extra_args, "-L");
|
||||
strarray_push(&ld_extra_args, argv[++i]);
|
||||
} else if (_startswith(argv[i], "-L")) {
|
||||
} else if (startswith(argv[i], "-L")) {
|
||||
strarray_push(&ld_extra_args, "-L");
|
||||
strarray_push(&ld_extra_args, argv[i] + 2);
|
||||
} else {
|
||||
|
@ -563,11 +563,11 @@ static Token *append_tokens(Token *tok1, Token *tok2) {
|
|||
|
||||
static FileType get_file_type(const char *filename) {
|
||||
if (opt_x != FILE_NONE) return opt_x;
|
||||
if (_endswith(filename, ".a")) return FILE_AR;
|
||||
if (_endswith(filename, ".o")) return FILE_OBJ;
|
||||
if (_endswith(filename, ".c")) return FILE_C;
|
||||
if (_endswith(filename, ".s")) return FILE_ASM;
|
||||
if (_endswith(filename, ".S")) return FILE_ASM_CPP;
|
||||
if (endswith(filename, ".a")) return FILE_AR;
|
||||
if (endswith(filename, ".o")) return FILE_OBJ;
|
||||
if (endswith(filename, ".c")) return FILE_C;
|
||||
if (endswith(filename, ".s")) return FILE_ASM;
|
||||
if (endswith(filename, ".S")) return FILE_ASM_CPP;
|
||||
error("<command line>: unknown file extension: %s", filename);
|
||||
}
|
||||
|
||||
|
|
4
third_party/chibicc/codegen.c
vendored
4
third_party/chibicc/codegen.c
vendored
|
@ -985,7 +985,7 @@ static bool gen_builtin_funcall(Node *node, const char *name) {
|
|||
char regprefix;
|
||||
gen_expr(node->args);
|
||||
emitlin("\tor\t$-1,%edi");
|
||||
regprefix = _endswith(name, "l") ? 'r' : 'e';
|
||||
regprefix = endswith(name, "l") ? 'r' : 'e';
|
||||
println("\tbsf\t%%%cax,%%%cax", regprefix, regprefix);
|
||||
emitlin("\tcmovz\t%edi,%eax");
|
||||
emitlin("\tinc\t%eax");
|
||||
|
@ -1413,7 +1413,7 @@ void gen_expr(Node *node) {
|
|||
case ND_FUNCALL: {
|
||||
const char *funcname = NULL;
|
||||
if (node->lhs->kind == ND_VAR) {
|
||||
if (_startswith(nameof(node->lhs->var), "__builtin_")) {
|
||||
if (startswith(nameof(node->lhs->var), "__builtin_")) {
|
||||
funcname = nameof(node->lhs->var) + 10;
|
||||
if (gen_builtin_funcall(node, funcname)) {
|
||||
return;
|
||||
|
|
19
third_party/chibicc/dox1.c
vendored
19
third_party/chibicc/dox1.c
vendored
|
@ -285,23 +285,22 @@ static void LoadPublicDefinitions(struct DoxWriter *dox, Obj *prog) {
|
|||
if (*obj->name == '_') continue;
|
||||
if (strchr(obj->name, '$')) continue;
|
||||
if (obj->visibility && !strcmp(obj->visibility, "hidden")) continue;
|
||||
if (_startswith(obj->name, "nsync_") && _endswith(obj->name, "_"))
|
||||
continue;
|
||||
if (startswith(obj->name, "nsync_") && endswith(obj->name, "_")) continue;
|
||||
if (!obj->is_definition && (!obj->is_function || !obj->params ||
|
||||
!obj->params->name || !*obj->params->name)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (_startswith(obj->name, "__gdtoa_")) continue;
|
||||
if (_startswith(obj->name, "sys_")) continue;
|
||||
if (_startswith(obj->name, "ioctl_")) continue;
|
||||
if (_startswith(obj->name, "nsync_mu_semaphore_")) continue;
|
||||
if (_startswith(obj->name, "Describe")) continue;
|
||||
if (_startswith(obj->name, "__sig")) continue;
|
||||
if (_startswith(obj->name, "__zipos")) continue;
|
||||
if (startswith(obj->name, "__gdtoa_")) continue;
|
||||
if (startswith(obj->name, "sys_")) continue;
|
||||
if (startswith(obj->name, "ioctl_")) continue;
|
||||
if (startswith(obj->name, "nsync_mu_semaphore_")) continue;
|
||||
if (startswith(obj->name, "Describe")) continue;
|
||||
if (startswith(obj->name, "__sig")) continue;
|
||||
if (startswith(obj->name, "__zipos")) continue;
|
||||
if (obj->is_static) continue;
|
||||
if (obj->is_string_literal) continue;
|
||||
if (obj->section && _startswith(obj->section, ".init_array")) continue;
|
||||
if (obj->section && startswith(obj->section, ".init_array")) continue;
|
||||
APPEND(dox->objects);
|
||||
dox->objects.p[dox->objects.n - 1] = obj;
|
||||
}
|
||||
|
|
4
third_party/chibicc/dox2.c
vendored
4
third_party/chibicc/dox2.c
vendored
|
@ -777,7 +777,7 @@ document.addEventListener('DOMContentLoaded', function () {\n\
|
|||
prefix = xasprintf("%s ", o->params.p[j].name);
|
||||
for (k = 0; k < o->javadown->tags.n; ++k) {
|
||||
if (!strcmp(o->javadown->tags.p[k].tag, "param") &&
|
||||
_startswith(o->javadown->tags.p[k].text, prefix)) {
|
||||
startswith(o->javadown->tags.p[k].text, prefix)) {
|
||||
fprintf(f, "<dd>");
|
||||
PrintText(f, o->javadown->tags.p[k].text + strlen(prefix));
|
||||
fprintf(f, "\n");
|
||||
|
@ -911,7 +911,7 @@ document.addEventListener('DOMContentLoaded', function () {\n\
|
|||
prefix = xasprintf("%s ", m->params.p[j].name);
|
||||
for (k = 0; k < m->javadown->tags.n; ++k) {
|
||||
if (!strcmp(m->javadown->tags.p[k].tag, "param") &&
|
||||
_startswith(m->javadown->tags.p[k].text, prefix)) {
|
||||
startswith(m->javadown->tags.p[k].text, prefix)) {
|
||||
fprintf(f, "<dd>");
|
||||
PrintText(f, m->javadown->tags.p[k].text + strlen(prefix));
|
||||
fprintf(f, "\n");
|
||||
|
|
4
third_party/chibicc/test/test.h
vendored
4
third_party/chibicc/test/test.h
vendored
|
@ -3,8 +3,8 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
__static_yoink("sys_mmap"); /* asan needs it */
|
||||
__static_yoink("TrackMemoryInterval"); /* asan needs it */
|
||||
__static_yoink("sys_mmap"); /* asan needs it */
|
||||
__static_yoink("__track_memory"); /* asan needs it */
|
||||
|
||||
#define ASSERT(x, y) Assert2(x, y, #y, __FILE__, __LINE__)
|
||||
#define ASSERT128(x, y) Assert128(x, y, #y, __FILE__, __LINE__)
|
||||
|
|
2
third_party/chibicc/tokenize.c
vendored
2
third_party/chibicc/tokenize.c
vendored
|
@ -653,7 +653,7 @@ static uint32_t read_universal_char(char *p, int len) {
|
|||
uint32_t c = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!isxdigit(p[i])) return 0;
|
||||
c = (c << 4) | hextoint(p[i]);
|
||||
c = (c << 4) | kHexToInt[p[i] & 255];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue