Reduce header complexity

- Remove most __ASSEMBLER__ __LINKER__ ifdefs
- Rename libc/intrin/bits.h to libc/serialize.h
- Block pthread cancelation in fchmodat() polyfill
- Remove `clang-format off` statements in third_party
This commit is contained in:
Justine Tunney 2023-11-28 14:24:28 -08:00
parent 96f979dfc5
commit fa20edc44d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3057 changed files with 410 additions and 4398 deletions

View file

@ -4,7 +4,6 @@
#include "net/http/url.h"
#include "third_party/lua/lauxlib.h"
#include "third_party/lua/visitor.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct EncoderConfig {
@ -39,5 +38,4 @@ int SerializeObjectEnd(char **, struct Serializer *, int, bool);
int SerializeObjectIndent(char **, struct Serializer *, int);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_COSMO_H_ */

View file

@ -42,7 +42,6 @@
#include "third_party/lua/lua.h"
#include "third_party/lua/lundump.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -4,7 +4,6 @@
#include "third_party/lua/llimits.h"
#include "third_party/lua/lstate.h"
/* clang-format off */
/* Increments 'L->top', checking for stack overflows */
#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lauxlib.h"
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -4,7 +4,6 @@
#include "libc/stdio/stdio.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/luaconf.h"
/* clang-format off */
/* global table */
#define LUA_GNAME "_G"

View file

@ -32,7 +32,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
/* clang-format off */
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -42,7 +42,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -6,7 +6,6 @@
#include "third_party/lua/lopcodes.h"
#include "third_party/lua/lparser.h"
/* clang-format off */
/*
** Marks the end of a patch list. It is an invalid value both as an absolute

View file

@ -31,7 +31,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -32,7 +32,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -42,7 +42,6 @@
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -3,7 +3,6 @@
#include "third_party/lua/lstate.h"
/* clang-format off */
#define pcRel(pc, p) (cast_int((pc) - (p)->code) - 1)

View file

@ -51,7 +51,6 @@
#include "third_party/lua/lundump.h"
#include "third_party/lua/lvm.h"
#include "third_party/lua/lzio.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -5,7 +5,6 @@
#include "third_party/lua/lstate.h"
#include "third_party/lua/lzio.h"
/* clang-format off */
/*
** Macro to check stack size and grow stack if needed. Parameters

View file

@ -32,7 +32,6 @@
#include "third_party/lua/lstate.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lundump.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -37,7 +37,6 @@
#include "third_party/lua/lstate.h"
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -3,7 +3,6 @@
#include "third_party/lua/lobject.h"
/* clang-format off */
#define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \
cast_int(sizeof(TValue)) * (n))

View file

@ -40,7 +40,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -4,7 +4,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/lstate.h"
/* clang-format off */
/*
** Collectable objects may have one of three colors: white, which means

View file

@ -46,7 +46,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -37,7 +37,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -40,7 +40,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lzio.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -10,7 +10,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/lzio.h"
/* clang-format off */
/*
** Single-char tokens (terminal symbols) are represented by their own

View file

@ -5,7 +5,6 @@
#include "libc/math.h"
#include "third_party/lua/lua.h"
/* clang-format off */
/*
** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -36,7 +36,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lstate.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -4,7 +4,6 @@
#include "third_party/lua/llimits.h"
#include "third_party/lua/lua.h"
/* clang-format off */
#define luaM_error(L) luaD_throw(L, LUA_ERRMEM)

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -38,7 +38,6 @@
#include "third_party/lua/lstring.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -5,7 +5,6 @@
#include "third_party/lua/llimits.h"
#include "third_party/lua/lua.h"
/* clang-format off */
/*
** Extra types for collectable non-values

View file

@ -29,7 +29,6 @@
#define LUA_CORE
#include "third_party/lua/lopcodes.h"
#include "third_party/lua/lprefix.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -3,7 +3,6 @@
#include "third_party/lua/llimits.h"
/* clang-format off */
/*===========================================================================
We assume that instructions are unsigned 32-bit integers.

View file

@ -41,7 +41,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -42,7 +42,6 @@
#include "third_party/lua/lstring.h"
#include "third_party/lua/ltable.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -5,7 +5,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/lzio.h"
/* clang-format off */
/*
** Expression and variable descriptor.

View file

@ -48,7 +48,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_
#include "third_party/linenoise/linenoise.h"
#include "third_party/lua/lauxlib.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern bool lua_repl_blocking;
@ -25,5 +24,4 @@ char *lua_readline_hint(const char *, const char **, const char **);
void lua_readline_completions(const char *, linenoiseCompletions *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LREPL_H_ */

View file

@ -42,7 +42,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -7,7 +7,6 @@
#include "third_party/lua/lzio.h"
#include "third_party/lua/tms.h"
/* clang-format off */
/*
** Some notes about garbage-collected objects: All objects in Lua must

View file

@ -36,7 +36,6 @@
#include "third_party/lua/lstate.h"
#include "third_party/lua/lstring.h"
#include "third_party/lua/lua.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -5,7 +5,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/lstate.h"
/* clang-format off */
/*
** Memory-allocation error message must be preallocated (it cannot

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -38,7 +38,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -3,7 +3,6 @@
#include "third_party/lua/lobject.h"
/* clang-format off */
#define gnode(t,i) (&(t)->node[i])
#define gval(n) (&(n)->i_val)

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lprefix.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -43,7 +43,6 @@
#include "third_party/lua/ltable.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -2,7 +2,6 @@
#define ltests_h
#include "third_party/lua/lua.h"
/* clang-format off */
/* test Lua with compatibility code */
#define LUA_COMPAT_MATHLIB

View file

@ -38,7 +38,6 @@
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -3,7 +3,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/luaconf.h"
#include "third_party/lua/tms.h"
/* clang-format off */
/*
** Mask with 1 in all fast-access methods. A 1 in any of these bits

View file

@ -1,9 +1,7 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LUA_H_
#define COSMOPOLITAN_THIRD_PARTY_LUA_LUA_H_
#include "third_party/lua/luaconf.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* clang-format off */
#define LUA_VERSION_MAJOR "5"
#define LUA_VERSION_MINOR "4"
@ -482,5 +480,4 @@ struct lua_Debug {
extern const char *g_lua_path_default;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LUA_H_ */

View file

@ -50,7 +50,6 @@
#include "third_party/lua/lualib.h"
#include "third_party/lua/lunix.h"
#include "tool/args/args.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -43,7 +43,6 @@
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
#include "third_party/lua/lundump.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -10,7 +10,6 @@
#define LUA_USE_POSIX
#define LUA_USE_LINENOISE
/* clang-format off */
/*
** ===================================================================

View file

@ -18,7 +18,7 @@
*/
#include "libc/assert.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/bits.h"
#include "libc/serialize.h"
#include "libc/intrin/likely.h"
#include "libc/log/log.h"
#include "libc/log/rop.internal.h"

View file

@ -18,7 +18,7 @@
*/
#include "libc/assert.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/bits.h"
#include "libc/serialize.h"
#include "libc/log/rop.internal.h"
#include "libc/math.h"
#include "libc/mem/mem.h"
@ -165,7 +165,6 @@ int main(int argc, char *argv[]) {
}
#endif
// clang-format off
static const char kLuaStrXlat[256] = {
1,1,1,1,1,1,1,'a','b','t','n','v','f','r',1,1, // 0x00
1,1,1,1,1,1,1,1,1,1,1,'e',1,1,1,1, // 0x10

View file

@ -2,7 +2,6 @@
#define lualib_h
#include "third_party/lua/lua.h"
/* clang-format off */
/* version suffix for environment variable names */
#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR

View file

@ -19,7 +19,6 @@
#include "third_party/lua/lundump.h"
#include "third_party/lua/lzio.h"
/* clang-format off */
#if !defined(luai_verifycode)
#define luai_verifycode(L,f) /* empty */

View file

@ -4,7 +4,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/lzio.h"
/* clang-format off */
/* data to catch conversion errors */
#define LUAC_DATA "\x19\x93\r\n\x1a\n"

View file

@ -46,7 +46,7 @@
#include "libc/fmt/itoa.h"
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/bits.h"
#include "libc/serialize.h"
#include "libc/intrin/strace.internal.h"
#include "libc/limits.h"
#include "libc/log/log.h"

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_LUNIX_H_
#define COSMOPOLITAN_THIRD_PARTY_LUA_LUNIX_H_
#include "third_party/lua/lauxlib.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct UnixErrno {
@ -14,5 +13,4 @@ int LuaUnix(lua_State *);
int LuaUnixSysretErrno(lua_State *, const char *, int);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_LUNIX_H_ */

View file

@ -12,7 +12,6 @@
#include "third_party/lua/lua.h"
#include "third_party/lua/lualib.h"
/* clang-format off */
#define MAXUNICODE 0x10FFFFu

View file

@ -41,7 +41,6 @@
#include "third_party/lua/ltm.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lvm.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -4,7 +4,6 @@
#include "third_party/lua/lobject.h"
#include "third_party/lua/ltm.h"
/* clang-format off */
#if !defined(LUA_NOCVTN2S)
#define cvt2str(o) ttisnumber(o)

View file

@ -34,7 +34,6 @@
#include "third_party/lua/lstate.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/lzio.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Lua 5.4.3 (MIT License)\\n\

View file

@ -10,7 +10,6 @@
#include "third_party/lua/lmem.h"
#include "third_party/lua/lua.h"
/* clang-format off */
#define EOZ (-1) /* end of stream */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_TMS_H_
#define COSMOPOLITAN_THIRD_PARTY_LUA_TMS_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*
@ -37,5 +36,4 @@ typedef enum {
} TMS;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_TMS_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_LUA_VISITOR_H_
#define COSMOPOLITAN_THIRD_PARTY_LUA_VISITOR_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct LuaVisited {
@ -12,5 +11,4 @@ int LuaPushVisit(struct LuaVisited *, const void *);
void LuaPopVisit(struct LuaVisited *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_LUA_VISITOR_H_ */