mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 21:40:30 +00:00
Make improvements
This change progresses our AARCH64 support: - The AARCH64 build and tests are now passing - Add 128-bit floating-point support to printf() - Fix clone() so it initializes cosmo's x28 TLS register - Fix TLS memory layout issue with aarch64 _Alignas vars - Revamp microbenchmarking tools so they work on aarch64 - Make some subtle improvements to aarch64 crash reporting - Make kisdangerous() memory checks more accurate on aarch64 - Remove sys_open() since it's not available on Linux AARCH64 This change makes general improvements to Cosmo and Redbean: - Introduce GetHostIsa() function in Redbean - You can now feature check using pledge(0, 0) - You can now feature check using unveil("",0) - Refactor some more x86-specific asm comments - Refactor and write docs for some libm functions - Make the mmap() API behave more similar to Linux - Fix WIFSIGNALED() which wrongly returned true for zero - Rename some obscure cosmo keywords from noFOO to dontFOO
This commit is contained in:
parent
5655c9a4e7
commit
8f522cb702
116 changed files with 1194 additions and 1025 deletions
|
@ -1196,6 +1196,10 @@ function GetHost() end
|
|||
---@nodiscard
|
||||
function GetHostOs() end
|
||||
|
||||
---@return "X86_64"|"AARCH64"|"POWERPC64"|"S390X" isaname string that describes the host instruction set architecture
|
||||
---@nodiscard
|
||||
function GetHostIsa() end
|
||||
|
||||
---@param str string|integer monospace display width of string.
|
||||
--- This is useful for fixed-width formatting. For example, CJK characters
|
||||
--- typically take up two cells. This function takes into consideration combining
|
||||
|
|
|
@ -1202,6 +1202,15 @@ FUNCTIONS
|
|||
- `"FREEBSD"`
|
||||
- `"OPENBSD"`
|
||||
|
||||
GetHostIsa() → str
|
||||
Returns string describing host instruction set architecture.
|
||||
|
||||
This can return:
|
||||
|
||||
- `"X86_64"` for Intel and AMD systems
|
||||
- `"AARCH64"` for ARM64, M1, and Raspberry Pi systems
|
||||
- `"POWERPC64"` for OpenPOWER Raptor Computing Systems
|
||||
|
||||
GetMonospaceWidth(str|char) → int
|
||||
Returns monospace display width of string. This is useful for
|
||||
fixed-width formatting. For example, CJK characters typically take
|
||||
|
@ -4296,6 +4305,16 @@ UNIX MODULE
|
|||
OpenBSD should ignore the chown functions without crashing. Linux
|
||||
will just EPERM.
|
||||
|
||||
Root access isn't required. Support is limited to OpenBSD and Linux
|
||||
2.6.23+ (i.e. RHEL6 c. 2012) so long as Redbean is running directly
|
||||
on the host system, i.e. not running in a userspace emulator like
|
||||
Blink or Qemu. If your environment isn't supported, then pledge()
|
||||
will return 0 and do nothing, rather than raising ENOSYS, so the
|
||||
apps you share with others will err on the side of not breaking. If
|
||||
a functionality check is needed, please use `unix.pledge(nil, nil)`
|
||||
which is a no-op that will fail appropriately when the necessary
|
||||
system support isn't available to impose security restrictions.
|
||||
|
||||
`promises` is a string that may include any of the following groups
|
||||
delimited by spaces. This list has been curated to focus on the
|
||||
system calls for which this module provides wrappers. See the
|
||||
|
@ -4502,6 +4521,18 @@ UNIX MODULE
|
|||
This system call is supported natively on OpenBSD and polyfilled on
|
||||
Linux using the Landlock LSM[1].
|
||||
|
||||
This function requires OpenBSD or Linux 5.13+ (2022+). If the kernel
|
||||
support isn't available (or we're in an emulator like Qemu or Blink)
|
||||
then zero is returned and nothing happens (instead of raising
|
||||
ENOSYS) because the files are still unveiled. Use `unix.unveil("",
|
||||
nil)` to feature check the host system, which is defined as a no-op
|
||||
that'll fail if the host system doesn't have the necessary features
|
||||
that allow unix.unveil() impose bona-fide security restrictions.
|
||||
Otherwise, if everything is good, a return value `>=0` is returned,
|
||||
where `0` means OpenBSD, and `>=1` means Linux with Landlock LSM, in
|
||||
which case the return code shall be the maximum supported Landlock
|
||||
ABI version.
|
||||
|
||||
`path` is the file or directory to unveil
|
||||
|
||||
`permissions` is a string consisting of zero or more of the
|
||||
|
|
|
@ -213,6 +213,23 @@ int LuaGetHostOs(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LuaGetHostIsa(lua_State *L) {
|
||||
const char *s;
|
||||
#ifdef __x86_64__
|
||||
s = "X86_64";
|
||||
#elif defined(__aarch64__)
|
||||
s = "AARCH64";
|
||||
#elif defined(__powerpc64__)
|
||||
s = "POWERPC64";
|
||||
#elif defined(__s390x__)
|
||||
s = "S390X";
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
lua_pushstring(L, s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaFormatIp(lua_State *L) {
|
||||
char b[16];
|
||||
uint32_t ip;
|
||||
|
|
|
@ -41,6 +41,7 @@ int LuaGetCpuCore(lua_State *);
|
|||
int LuaGetCpuCount(lua_State *);
|
||||
int LuaGetCpuNode(lua_State *);
|
||||
int LuaGetCryptoHash(lua_State *);
|
||||
int LuaGetHostIsa(lua_State *);
|
||||
int LuaGetHostOs(lua_State *);
|
||||
int LuaGetHttpReason(lua_State *);
|
||||
int LuaGetLogLevel(lua_State *);
|
||||
|
|
|
@ -1091,7 +1091,6 @@ static void UpdateLuaPath(const char *s) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void ProgramDirectory(const char *path) {
|
||||
char *s;
|
||||
size_t n;
|
||||
|
@ -5163,6 +5162,7 @@ static const luaL_Reg kLuaFuncs[] = {
|
|||
{"GetHeader", LuaGetHeader}, //
|
||||
{"GetHeaders", LuaGetHeaders}, //
|
||||
{"GetHost", LuaGetHost}, //
|
||||
{"GetHostIsa", LuaGetHostIsa}, //
|
||||
{"GetHostOs", LuaGetHostOs}, //
|
||||
{"GetHttpReason", LuaGetHttpReason}, //
|
||||
{"GetHttpVersion", LuaGetHttpVersion}, //
|
||||
|
@ -6905,6 +6905,7 @@ static int HandleConnection(size_t i) {
|
|||
}
|
||||
|
||||
static void MakeExecutableModifiable(void) {
|
||||
#ifdef __x86_64__
|
||||
int ft;
|
||||
size_t n;
|
||||
extern char ape_rom_vaddr[] __attribute__((__weak__));
|
||||
|
@ -6923,6 +6924,9 @@ static void MakeExecutableModifiable(void) {
|
|||
ftrace_install();
|
||||
ftrace_enabled(ft);
|
||||
}
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
}
|
||||
|
||||
static int HandleReadline(void) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue