cosmopolitan/libc/x/x.h

102 lines
4.4 KiB
C
Raw Normal View History

2020-06-15 14:18:57 +00:00
#ifndef COSMOPOLITAN_LIBC_X_H_
#define COSMOPOLITAN_LIBC_X_H_
#ifdef _COSMO_SOURCE
#define xwrite __xwrite
#define xdie __xdie
#define xmalloc __xmalloc
#define xrealloc __xrealloc
#define xcalloc __xcalloc
#define xvalloc __xvalloc
#define xmemalign __xmemalign
#define xmemalignzero __xmemalignzero
#define xstrdup __xstrdup
#define xstrndup __xstrndup
#define xstrmul __xstrmul
#define xinet_ntop __xinet_ntop
#define xunbinga __xunbinga
#define xunbing __xunbing
#define utf8to16 __utf8to16
#define utf16to8 __utf16to8
#define utf8to32 __utf8to32
#define utf16to32 __utf16to32
#define utf32to8 __utf32to8
#define xhomedir __xhomedir
#define xstripext __xstripext
#define xstripexts __xstripexts
#define xload __xload
#define rmrf __rmrf
#define xbasename __xbasename
#define xdirname __xdirname
#define xjoinpaths __xjoinpaths
#define xfixpath __xfixpath
#define xslurp __xslurp
#define xbarf __xbarf
#endif /* _COSMO_SOURCE */
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#ifdef _COSMO_SOURCE
COSMOPOLITAN_C_START_
2020-06-15 14:18:57 +00:00
int xwrite(int, const void *, uint64_t);
void xdie(void) wontreturn;
char *xdtoa(double)
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xdtoaf(float)
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xdtoal(long double)
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void *xmalloc(size_t) attributeallocsize((1))
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
Make major improvements to redbean and libraries The most exciting improvement is dynamic pages will soon be able to use the executable itself as an object store. it required a heroic technique for overcoming ETXTBSY restrictions which lets us open the executable in read/write mode, which means (1) wa can restore the APE header, and (2) we can potentially containerize redbean extension code so that modules you download for your redbean online will only impact your redbean. Here's a list of breaking changes to redbean: - Remove /tool/net/ prefix from magic ZIP paths - GetHeader() now returns NIL if header is absent Here's a list of fixes and enhancements to redbean: - Support 64-bit ZIP archives - Record User-Agent header in logs - Add twelve error handlers to accept() - Display octal st_mode on listing page - Show ZIP file comments on listing page - Restore APE MZ header on redbean startup - Track request count on redbean index page - Report server uptime on redbean index page - Don't bind server socket using SO_REUSEPORT - Fix #151 where Lua LoadAsset() could free twice - Report rusage accounting when workers exit w/ -vv - Use ZIP iattr field as text/plain vs. binary hint - Add ParseUrl() API for parsing things like a.href - Add ParseParams() API for parsing HTTP POST bodies - Add IsAcceptablePath() API for checking dots, etc. - Add IsValidHttpToken() API for validating sane ASCII - Add IsAcceptableHostPort() for validating HOST[:PORT] - Send 400 response to HTTP/1.1 requests without a Host - Send 403 response if ZIP or file isn't other readable - Add virtual hosting that tries prepending Host to path - Route requests based on Host in Request-URI if present - Host routing will attempt to remove or add the www. prefix - Sign-extend UNIX timestamps and don't adjust FileTime zone Here's some of the improvements made to Cosmopolitan Libc: - Fix ape.S indentation - Improve consts.sh magnums - Write pretty good URL parser - Improve rusage accounting apis - Bring mremap() closer to working - Added ZIP APIs which will change - Check for overflow in reallocarray() - Remove overly fancy linkage in strerror() - Fix GDB attach on crash w/ OpenBSD msyscall() - Make sigqueue() portable to most UNIX distros - Make integer serialization macros more elegant - Bring back 34x tprecode8to16() performance boost - Make malloc() more resilient to absurdly large sizes
2021-04-18 18:34:59 +00:00
void *xrealloc(void *, size_t)
attributeallocsize((2)) dontthrow nocallback __wur;
void *xcalloc(size_t, size_t) attributeallocsize((1, 2))
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void *xvalloc(size_t) attributeallocsize((1)) returnsaligned((65536))
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void *xmemalign(size_t, size_t) attributeallocalign((1)) attributeallocsize((2))
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void *xmemalignzero(size_t, size_t) attributeallocalign((1)) attributeallocsize(
(2)) returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xstrdup(const char *) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xstrndup(const char *, size_t) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xstrcat(const char *, ...) paramsnonnull((1)) nullterminated()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
2023-04-18 12:02:45 +00:00
#define xstrcat(...) (xstrcat)(__VA_ARGS__, NULL)
char *xstrmul(const char *, size_t) paramsnonnull((1))
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xinet_ntop(int, const void *) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void *xunbinga(size_t, const char16_t *)
attributeallocalign((1)) returnspointerwithnoaliases dontthrow
nocallback __wur returnsnonnull dontthrow nocallback __wur returnsnonnull;
void *xunbing(const char16_t *) returnspointerwithnoaliases dontthrow
nocallback __wur returnsnonnull dontthrow nocallback __wur returnsnonnull;
char16_t *utf8to16(const char *, size_t, size_t *) __wur;
char *utf16to8(const char16_t *, size_t, size_t *) __wur;
wchar_t *utf8to32(const char *, size_t, size_t *) __wur;
wchar_t *utf16to32(const char16_t *, size_t, size_t *) __wur;
char *utf32to8(const wchar_t *, size_t, size_t *) __wur;
char *xhomedir(void) __wur;
char *xstripext(const char *) __wur;
char *xstripexts(const char *) __wur;
void *xload(_Atomic(void *) *, const void *, size_t, size_t);
int rmrf(const char *);
char *xbasename(const char *) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xdirname(const char *) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
char *xjoinpaths(const char *, const char *) paramsnonnull()
returnspointerwithnoaliases dontthrow nocallback __wur returnsnonnull;
void xfixpath(void);
void *xslurp(const char *, size_t *)
paramsnonnull((1)) returnspointerwithnoaliases returnsaligned((4096)) __wur;
int xbarf(const char *, const void *, size_t);
2020-06-15 14:18:57 +00:00
COSMOPOLITAN_C_END_
#endif /* _COSMO_SOURCE */
2020-06-15 14:18:57 +00:00
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_X_H_ */