mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 23:48:21 +00:00
The APE_NO_MODIFY_SELF loader payload has been moved out of the examples folder and improved so that it works on BSD systems, and permits general elf program headers. This brings its quality up enough that it should be acceptable to use by default for many programs, e.g. Python, Lua, SQLite and Python. It's the responsibility of the user to define an appropriate TMPDIR if /tmp is considered an adversarial environment. Mac OS shall be supported by APE_NO_MODIFY_SELF soon. Fixes and improvements have been made to program_executable_name as it's now the one true way to get the absolute path of the executing image. This change fixes a memory leak in linenoise history loading, introduced by performance optimizations in51904e2687
This change fixes a longstanding regression with Mach system calls, that23ae9dfceb
back in February which impacted our sched_yield() implementation, which is why no one noticed until now. The Blinkenlights PC emulator has been improved. We now fix rendering on XNU and BSD by not making the assumption that the kernel terminal driver understands UTF8 since that seems to break its internal modeling of \r\n which is now being addressed by using \e[𝑦H instead. The paneling is now more compact in real mode so you won't need to make your font as tiny if you're only emulating an 8086 program. The CLMUL ISA is now emulated too This change also makes improvement to time. CLOCK_MONOTONIC now does the right thing on Windows NT. The nanosecond time module functions added in Python 3.7 have been backported. This change doubles the performance of Argon2 password stretching simply by not using its copy_block and xor_block helper functions, as they were trivial to inline thus resulting in us needing to iterate over each 1024 byte block four fewer times. This change makes code size improvements. _PyUnicode_ToNumeric() was 64k in size and now it's 10k. The CJK codec lookup tables now use lazy delta zigzag deflate (δzd) encoding which reduces their size from 600k to 200k plus the code bloat caused by macro abuse in _decimal.c is now addressed so our fully-loaded statically-linked hermetically-sealed Python virtual interpreter container is now 9.4 megs in the default build mode and 5.5m in MODE=tiny which leaves plenty of room for chibicc. The pydoc web server now accommodates the use case of people who work by SSH'ing into a different machine w/ python.com -m pydoc -p8080 -h0.0.0.0 Finally Python Capsulae delenda est and won't be supported in the future
129 lines
9.1 KiB
C
129 lines
9.1 KiB
C
#ifndef COSMOPOLITAN_LIBC_X_H_
|
|
#define COSMOPOLITAN_LIBC_X_H_
|
|
#include "libc/calls/struct/rusage.h"
|
|
#include "libc/calls/struct/sigaction.h"
|
|
#include "libc/calls/struct/timespec.h"
|
|
#include "libc/calls/struct/timeval.h"
|
|
#include "libc/fmt/pflink.h"
|
|
#include "libc/stdio/stdio.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│─╝
|
|
Standard Library veneers for folks not building embedded RTOS */
|
|
|
|
#define _XPNN paramsnonnull()
|
|
#define _XRET nothrow nocallback nodiscard returnsnonnull
|
|
#define _XMAL returnspointerwithnoaliases _XRET
|
|
#define _XMALPG returnsaligned((PAGESIZE)) _XMAL
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » system calls ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
int xsigaction(int, void *, uint64_t, uint64_t, struct sigaction *);
|
|
int xwrite(int, const void *, uint64_t);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » memory ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
void xdie(void) wontreturn;
|
|
char *xdtoa(double) _XMAL;
|
|
char *xdtoaf(float) _XMAL;
|
|
char *xdtoal(long double) _XMAL;
|
|
char *xasprintf(const char *, ...) printfesque(1) paramsnonnull((1)) _XMAL;
|
|
char *xvasprintf(const char *, va_list) _XPNN _XMAL;
|
|
char *xgetline(struct FILE *) _XPNN mallocesque;
|
|
void *xmalloc(size_t) attributeallocsize((1)) _XMAL;
|
|
void *xrealloc(void *, size_t)
|
|
attributeallocsize((2)) nothrow nocallback nodiscard;
|
|
void *xcalloc(size_t, size_t) attributeallocsize((1, 2)) _XMAL;
|
|
void *xvalloc(size_t) attributeallocsize((1)) _XMALPG;
|
|
void *xmemalign(size_t, size_t) attributeallocalign((1))
|
|
attributeallocsize((2)) _XMAL;
|
|
void *xmemalignzero(size_t, size_t) attributeallocalign((1))
|
|
attributeallocsize((2)) _XMAL;
|
|
char *xstrdup(const char *) _XPNN _XMAL;
|
|
char *xstrndup(const char *, size_t) _XPNN _XMAL;
|
|
char *xstrcat(const char *, ...) paramsnonnull((1)) nullterminated() _XMAL;
|
|
char *xstrmul(const char *, size_t) paramsnonnull((1)) _XMAL;
|
|
char *xinet_ntop(int, const void *) _XPNN _XMAL;
|
|
void *xunbinga(size_t, const char16_t *) attributeallocalign((1)) _XMAL _XRET;
|
|
void *xunbing(const char16_t *) _XMAL _XRET;
|
|
char16_t *utf8toutf16(const char *, size_t, size_t *) nodiscard;
|
|
char *utf16toutf8(const char16_t *, size_t, size_t *) nodiscard;
|
|
wchar_t *utf8toutf32(const char *, size_t, size_t *) nodiscard;
|
|
wchar_t *utf16to32(const char16_t *, size_t, size_t *) nodiscard;
|
|
char *xhomedir(void) nodiscard;
|
|
char *xstripext(const char *) nodiscard;
|
|
char *xstripexts(const char *) nodiscard;
|
|
void *xload(bool *, void **, const void *, size_t, size_t);
|
|
void *xloadzd(bool *, void **, const void *, size_t, size_t, size_t, size_t,
|
|
uint32_t);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » files ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
int rmrf(const char *);
|
|
int makedirs(const char *, unsigned);
|
|
char *xdirname(const char *) paramsnonnull() _XMAL;
|
|
char *xjoinpaths(const char *, const char *) paramsnonnull() _XMAL;
|
|
char *xreadlink(const char *) paramsnonnull() _XMAL;
|
|
char *xreadlinkat(int, const char *) paramsnonnull() _XMAL;
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » time ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
char *xiso8601i(int) mallocesque;
|
|
char *xiso8601tv(struct timeval *) mallocesque;
|
|
char *xiso8601ts(struct timespec *) mallocesque;
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » input / output ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
void *xslurp(const char *, size_t *)
|
|
paramsnonnull((1)) returnspointerwithnoaliases
|
|
returnsaligned((PAGESIZE)) nodiscard;
|
|
int xbarf(const char *, const void *, size_t);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » safety ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#define xstrcat(...) (xstrcat)(__VA_ARGS__, NULL)
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » processes ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
int xspawn(struct rusage *);
|
|
int xvspawn(void (*)(void *), void *, struct rusage *);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » generic typing ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#if __STDC_VERSION__ + 0 >= 201112
|
|
|
|
#define xiso8601(TS) \
|
|
_Generic(*(TS), struct timeval : xiso8601tv, default : xiso8601ts)(TS)
|
|
|
|
#endif /* C11 */
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » link-time optimizations ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
#define xasprintf(FMT, ...) (xasprintf)(PFLINK(FMT), ##__VA_ARGS__)
|
|
#define xvasprintf(FMT, VA) (xvasprintf)(PFLINK(FMT), VA)
|
|
#endif
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_X_H_ */
|