mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 19:43:32 +00:00
bf03b2e64c
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
106 lines
3.2 KiB
C
106 lines
3.2 KiB
C
#ifndef COSMOPOLITAN_LIBC_DCE_H_
|
|
#define COSMOPOLITAN_LIBC_DCE_H_
|
|
#include "libc/nexgen32e/kcpuids.h"
|
|
/*─────────────────────────────────────────────────────────────────────────────╗
|
|
│ cosmopolitan § autotune » dead code elimination │
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
|
|
#ifndef SUPPORT_VECTOR
|
|
/**
|
|
* Supported Platforms Tuning Knob (Runtime & Compile-Time)
|
|
* Tuning this bitmask will remove platform polyfills at compile-time.
|
|
*/
|
|
#define SUPPORT_VECTOR 255
|
|
#endif
|
|
|
|
#define LINUX 1
|
|
#define METAL 2
|
|
#define WINDOWS 4
|
|
#define XNU 8
|
|
#define OPENBSD 16
|
|
#define FREEBSD 32
|
|
#define NETBSD 64
|
|
|
|
#ifdef NDEBUG
|
|
#define NoDebug() 1
|
|
#else
|
|
#define NoDebug() 0
|
|
#endif
|
|
|
|
#ifdef MODE_DBG
|
|
#define IsModeDbg() 1
|
|
#else
|
|
#define IsModeDbg() 0
|
|
#endif
|
|
|
|
#ifdef __MFENTRY__
|
|
#define HaveFentry() 1
|
|
#else
|
|
#define HaveFentry() 0
|
|
#endif
|
|
|
|
#ifdef TRUSTWORTHY
|
|
#define IsTrustworthy() 1
|
|
#else
|
|
#define IsTrustworthy() 0
|
|
#endif
|
|
|
|
#ifdef TINY
|
|
#define IsTiny() 1
|
|
#else
|
|
#define IsTiny() 0
|
|
#endif
|
|
|
|
#ifdef __OPTIMIZE__
|
|
#define IsOptimized() 1
|
|
#else
|
|
#define IsOptimized() 0
|
|
#endif
|
|
|
|
#if defined(__PIE__) || defined(__PIC__)
|
|
#define IsPositionIndependent() 1
|
|
#else
|
|
#define IsPositionIndependent() 0
|
|
#endif
|
|
|
|
#define SupportsLinux() ((SUPPORT_VECTOR & LINUX) == LINUX)
|
|
#define SupportsMetal() ((SUPPORT_VECTOR & METAL) == METAL)
|
|
#define SupportsWindows() ((SUPPORT_VECTOR & WINDOWS) == WINDOWS)
|
|
#define SupportsXnu() ((SUPPORT_VECTOR & XNU) == XNU)
|
|
#define SupportsFreebsd() ((SUPPORT_VECTOR & FREEBSD) == FREEBSD)
|
|
#define SupportsOpenbsd() ((SUPPORT_VECTOR & OPENBSD) == OPENBSD)
|
|
#define SupportsNetbsd() ((SUPPORT_VECTOR & NETBSD) == NETBSD)
|
|
#define SupportsBsd() (!!(SUPPORT_VECTOR & (XNU | FREEBSD | OPENBSD | NETBSD)))
|
|
#define SupportsSystemv() \
|
|
(!!(SUPPORT_VECTOR & (LINUX | XNU | OPENBSD | FREEBSD | NETBSD)))
|
|
|
|
#ifndef __ASSEMBLER__
|
|
#define IsLinux() (SupportsLinux() && (__hostos & LINUX))
|
|
#define IsMetal() (SupportsMetal() && (__hostos & METAL))
|
|
#define IsWindows() (SupportsWindows() && (__hostos & WINDOWS))
|
|
#define IsXnu() (SupportsXnu() && (__hostos & XNU))
|
|
#define IsFreebsd() (SupportsFreebsd() && (__hostos & FREEBSD))
|
|
#define IsOpenbsd() (SupportsOpenbsd() && (__hostos & OPENBSD))
|
|
#define IsNetbsd() (SupportsNetbsd() && (__hostos & NETBSD))
|
|
#define IsBsd() (IsXnu() || IsFreebsd() || IsOpenbsd() || IsNetbsd())
|
|
#else
|
|
/* clang-format off */
|
|
#define IsLinux() $LINUX,__hostos(%rip)
|
|
#define IsMetal() $METAL,__hostos(%rip)
|
|
#define IsWindows() $WINDOWS,__hostos(%rip)
|
|
#define IsBsd() $XNU|FREEBSD|OPENBSD|NETBSD,__hostos(%rip)
|
|
#define IsXnu() $XNU,__hostos(%rip)
|
|
#define IsFreebsd() $FREEBSD,__hostos(%rip)
|
|
#define IsOpenbsd() $OPENBSD,__hostos(%rip)
|
|
#define IsNetbsd() $NETBSD,__hostos(%rip)
|
|
/* clang-format on */
|
|
#endif
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
extern const int __hostos;
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_DCE_H_ */
|