mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +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
|
@ -49,7 +49,7 @@ void List(const char *path) {
|
|||
const char *vpath;
|
||||
if (strcmp(path, ".") == 0) {
|
||||
vpath = "";
|
||||
} else if (!_endswith(path, "/")) {
|
||||
} else if (!endswith(path, "/")) {
|
||||
vpath = _gc(xasprintf("%s/", path));
|
||||
} else {
|
||||
vpath = path;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/zipos.internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -43,7 +44,6 @@
|
|||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/x/xsigaction.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "libc/runtime/zipos.internal.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
#include "third_party/libcxx/vector"
|
||||
#include "tool/viz/lib/knobs.h"
|
||||
|
@ -1676,7 +1676,7 @@ char* GetLine(void) {
|
|||
static char* line;
|
||||
static size_t linesize;
|
||||
if (getline(&line, &linesize, stdin) > 0) {
|
||||
return _chomp(line);
|
||||
return chomp(line);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -147,12 +147,12 @@ int main(int argc, char *argv[]) {
|
|||
if (iscntrl(code[0]) && !code[1]) {
|
||||
printf("is CTRL-%c a.k.a. ^%c\r\n", CTRL(code[0]), CTRL(code[0]));
|
||||
if (code[0] == CTRL('C') || code[0] == CTRL('D')) break;
|
||||
} else if (_startswith(code, "\e[") && _endswith(code, "R")) {
|
||||
} else if (startswith(code, "\e[") && endswith(code, "R")) {
|
||||
yn = 1, xn = 1;
|
||||
sscanf(code, "\e[%d;%dR", &yn, &xn);
|
||||
printf("inband signalling says terminal size is %d×%d\r\n", xn, yn);
|
||||
} else if (_startswith(code, "\e[<") &&
|
||||
(_endswith(code, "m") || _endswith(code, "M"))) {
|
||||
} else if (startswith(code, "\e[<") &&
|
||||
(endswith(code, "m") || endswith(code, "M"))) {
|
||||
e = 0, y = 1, x = 1;
|
||||
sscanf(code, "\e[<%d;%d;%d%c", &e, &y, &x, &c);
|
||||
printf("mouse %s at %d×%d\r\n", describemouseevent(e | (c == 'm') << 2),
|
||||
|
|
|
@ -80,7 +80,7 @@ char *GetTime(void) {
|
|||
struct timespec ts;
|
||||
clock_gettime(0, &ts);
|
||||
localtime_r(&ts.tv_sec, &tm);
|
||||
return _chomp(asctime(&tm));
|
||||
return chomp(asctime(&tm));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/errno.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
|
||||
/**
|
||||
* @fileoverview x86 instruction length decoder by way of hex pipe.
|
||||
*
|
||||
* Here's an example of how you can use it to decode a NOP stream:
|
||||
*
|
||||
* $ make -j8 o//examples/x86split.com
|
||||
* $ echo 909090 | o//examples/x86split.com
|
||||
* 90
|
||||
* 90
|
||||
* 90
|
||||
*
|
||||
* If there was a XOR instruction in there, it'd do this:
|
||||
*
|
||||
* $ make -j8 o//examples/x86split.com
|
||||
* $ echo 904531FF90 | o//examples/x86split.com
|
||||
* 90 # NOP
|
||||
* 4531FF # XOR R15D,R15D
|
||||
* 90 # NOP
|
||||
*
|
||||
* Now that you're able to split x86 instructions the rest is easy.
|
||||
*/
|
||||
|
||||
int fgethex(FILE *f) {
|
||||
int o, t = -1;
|
||||
while (!((o = fgetc(f)) & ~0xFF)) {
|
||||
switch (t) {
|
||||
case -1:
|
||||
t = isxdigit(o) ? hextoint(o) : -1;
|
||||
break;
|
||||
default:
|
||||
if (isxdigit(o)) {
|
||||
return t * 16 + hextoint(o);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (t >= 0) return einval();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[argc]) {
|
||||
int err;
|
||||
unsigned c, i, j, l;
|
||||
struct XedDecodedInst xedd;
|
||||
unsigned char buf[XED_MAX_INSTRUCTION_BYTES];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
for (i = 0;;) {
|
||||
if (i < XED_MAX_INSTRUCTION_BYTES) {
|
||||
c = fgethex(stdin);
|
||||
if (c != -1) {
|
||||
buf[i++] = c;
|
||||
continue;
|
||||
} else if (i == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((err = xed_instruction_length_decode(
|
||||
xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LONG_64),
|
||||
buf, i))) {
|
||||
errno = err;
|
||||
break;
|
||||
}
|
||||
l = xedd.length;
|
||||
if (l <= 0 || l > i) abort();
|
||||
for (j = 0; j < l; ++j) {
|
||||
fputc("0123456789ABCDEF"[(buf[j] & 0xf0) >> 4], stdout);
|
||||
fputc("0123456789ABCDEF"[(buf[j] & 0x0f) >> 0], stdout);
|
||||
}
|
||||
putchar('\n');
|
||||
memcpy(&buf[0], &buf[l], i -= l);
|
||||
}
|
||||
return errno;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue