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

@ -18,7 +18,6 @@
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("_ast");

View file

@ -24,7 +24,6 @@
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("_warnings");

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/asdl.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
asdl_seq *
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)

View file

@ -30,7 +30,6 @@
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Modules/unicodedata.h"
/* clang-format off */
static int validate_stmts(asdl_seq *);
static int validate_exprs(asdl_seq *, expr_context_ty, int);

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
#define NEXITFUNCS 32

View file

@ -46,7 +46,6 @@
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("builtins.ArithmeticError");
PYTHON_PROVIDE("builtins.AssertionError");

View file

@ -36,7 +36,6 @@
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Execute compiled code */

View file

@ -9,7 +9,6 @@
#include "libc/thread/thread2.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Python/condvar.h"
/* clang-format off */
/*
* Implementation of the Global Interpreter Lock (GIL).

View file

@ -1,4 +1,3 @@
/* clang-format off */
/*[clinic input]
preserve
[clinic start generated code]*/

View file

@ -1,4 +1,3 @@
/* clang-format off */
/*[clinic input]
preserve
[clinic start generated code]*/

View file

@ -22,7 +22,6 @@
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/ucnhash.h"
#include "third_party/python/Modules/unicodedata.h"
/* clang-format off */
/* ------------------------------------------------------------------------

View file

@ -25,7 +25,6 @@
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Python/wordcode_helpers.inc"
/* clang-format off */
/*
* This file compiles an abstract syntax tree (AST) into Python bytecode.

View file

@ -1,7 +1,6 @@
#ifndef _CONDVAR_H_
#define _CONDVAR_H_
#include "libc/time/time.h"
/* clang-format off */
/*
* Portable condition variable support for windows and pthreads.

View file

@ -44,7 +44,6 @@
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/xed/x86.h"
/* clang-format off */
PYTHON_PROVIDE("cosmo");
PYTHON_PROVIDE("cosmo.exit1");

View file

@ -10,7 +10,6 @@
#include "libc/runtime/runtime.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
/* clang-format off */
/****************************************************************
*

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/dynamic_annotations.h"
/* clang-format off */
/* Copyright (c) 2008-2009, Google Inc.
* All rights reserved.

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* Support for dynamic loading of extension modules */

View file

@ -11,7 +11,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
#define SOABI "cpython36m-x86_64-cosmo"

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* This module provides the necessary stubs for when dynamic loading is
not present. */

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/patchlevel.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
// "activation context" magic - see dl_nt.c...
#if HAVE_SXS

View file

@ -27,7 +27,6 @@
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
_Py_IDENTIFIER(builtins);
_Py_IDENTIFIER(stderr);

View file

@ -14,7 +14,6 @@
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
/* clang-format off */
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(stderr);

View file

@ -7,7 +7,6 @@
#include "libc/calls/calls.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/*
* The file descriptor fd is considered ``interactive'' if either

View file

@ -25,7 +25,6 @@
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
wchar_t* _Py_DecodeUTF8_surrogateescape(const char *, Py_ssize_t);

View file

@ -17,7 +17,6 @@
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
/* Undo the effect of Py_Initialize().

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Global configuration variable declarations are in pydebug.h */
/* XXX (ncoghlan): move those declarations to pylifecycle.h? */

View file

@ -9,7 +9,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/sysmodule.h"
/* clang-format off */
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(stdout);

View file

@ -19,7 +19,6 @@
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pystrtod.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* implements the unicode (as opposed to string) version of the
built-in formatters for string, int, float. that is, the versions

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/import.h"
/* clang-format off */
#include "o//third_party/python/Python/importlib.inc"
#include "o//third_party/python/Python/importlib_external.inc"

View file

@ -15,7 +15,6 @@
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/sysmodule.h"
/* clang-format off */
#ifdef MS_WINDOWS
extern void PyWinFreeze_ExeInit(void);

View file

@ -13,7 +13,6 @@
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
#define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined"
#define ERR_LATE_FUTURE \

View file

@ -18,7 +18,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
/* clang-format off */
#define FLAG_COMPAT 1
#define FLAG_SIZE_T 2

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
#ifndef COMPILER
#ifdef __llvm__

View file

@ -9,7 +9,6 @@
#include "libc/stdio/append.h"
#include "libc/str/str.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
asm(".ident\t\"\\n\\n\
Python 3.6 (https://docs.python.org/3/license.html)\\n\

View file

@ -7,12 +7,10 @@
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "third_party/python/Include/pygetopt.h"
/* clang-format off */
asm(".ident\t\"\\n\\n\
python getopt (isc license)\\n\
Copyright 1992-1994 David Gottner\"");
/* clang-format off */
/*---------------------------------------------------------------------------*
* <RCS keywords>

View file

@ -4,7 +4,6 @@
Python 3
https://docs.python.org/3/license.html │
*/
/* clang-format off */
const char *
Py_GetPlatform(void)

View file

@ -9,7 +9,6 @@
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
PyOS_sighandler_t
PyOS_getsig(int sig)

View file

@ -7,7 +7,6 @@
#include "third_party/python/Include/patchlevel.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Return the full version string. */

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/pgenheaders.h"
/* clang-format off */
/* Generated by Parser/pgen */

View file

@ -10,7 +10,6 @@
#include "libc/calls/struct/stat.macros.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/libgen.h"
#include "libc/intrin/bits.h"
#include "libc/macros.internal.h"
#include "libc/mem/alg.h"
#include "libc/mem/gc.h"
@ -51,8 +50,8 @@
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Include/weakrefobject.h"
#include "third_party/python/Include/yoink.h"
#include "libc/serialize.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
PYTHON_PROVIDE("_imp");
PYTHON_PROVIDE("_imp.__doc__");

View file

@ -12,7 +12,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* Support for dynamic loading of extension modules */

View file

@ -11,7 +11,6 @@
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
_Py_IDENTIFIER(name);

View file

@ -20,7 +20,6 @@
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("_frozen_importlib");
PYTHON_PROVIDE("_frozen_importlib_external");

View file

@ -10,7 +10,6 @@
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("__main__");

View file

@ -9,7 +9,6 @@
#include "third_party/python/Include/intrcheck.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
void
_Py_InitSigs(void)

View file

@ -11,7 +11,6 @@
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
/* PYTHON_YOINK("site"); */
/* PYTHON_YOINK("_sysconfigdata_m_cosmo_x86_64_cosmo"); */

View file

@ -18,7 +18,6 @@
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
/* PYTHON_YOINK("io"); */
/* PYTHON_YOINK("encodings.aliases"); */

View file

@ -32,7 +32,6 @@
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Modules/hashtable.h"
/* clang-format off */
PYTHON_PROVIDE("marshal");

View file

@ -15,7 +15,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/tupleobject.h"
/* clang-format off */
#define FLAG_SIZE_T 1
typedef double va_double;

View file

@ -6,7 +6,6 @@
*/
#include "libc/assert.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
/* snprintf() wrappers. If the platform has vsnprintf, we use it, else we
emulate it in a half-hearted way. Even if the platform has it, we wrap

View file

@ -10,7 +10,6 @@
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
/* Static overflow check values for bases 2 through 36.
* smallmax[base] is the largest unsigned long i such that

View file

@ -4,7 +4,6 @@
Python 3
https://docs.python.org/3/license.html
╚─────────────────────────────────────────────────────────────────────────────*/
/* clang-format off */
static void *const opcode_targets[256] = {
&&_unknown_opcode,

View file

@ -21,7 +21,6 @@
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Python/wordcode_helpers.inc"
#include "third_party/quickjs/internal.h"
/* clang-format off */
/* Peephole optimizations for bytecode compiler. */

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
#ifdef MS_WINDOWS
static wchar_t *progname = L"python";

View file

@ -12,7 +12,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
/* clang-format off */
/* A simple arena block structure.

View file

@ -4,7 +4,6 @@
Python 3
https://docs.python.org/3/license.html │
*/
/* clang-format off */
#include "third_party/python/pyconfig.h"
#include "third_party/python/Include/pyfpe.h"
/*

View file

@ -6,7 +6,6 @@
*/
#include "libc/assert.h"
#include "third_party/python/Include/pyhash.h"
/* clang-format off */
/* Set of hash utility functions to help maintaining the invariant that
if a==b then hash(a)==hash(b)

View file

@ -49,7 +49,6 @@
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/pyconfig.h"
/* clang-format off */
#ifdef X87_DOUBLE_ROUNDING
/* On x86 platforms using an x87 FPU, this function is called from the

View file

@ -16,7 +16,6 @@
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
/* clang-format off */
#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_UNDEFINED__)
__static_yoink("__die"); /* to guarantee backtraces */

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
/* clang-format off */
/* Cross platform case insensitive string compare functions
*/

View file

@ -11,7 +11,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* bytes to hex implementation */

View file

@ -15,7 +15,6 @@
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pystrtod.h"
/* clang-format off */
/* Case-insensitive string match used for nan and inf detection; t should be
lower-case. Returns 1 for a successful match, 0 otherwise. */

View file

@ -9,7 +9,6 @@
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymacro.h"
/* clang-format off */
static wchar_t *default_home = NULL;
static wchar_t env_home[MAXPATHLEN+1];

View file

@ -34,7 +34,6 @@
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */

View file

@ -16,7 +16,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymath.h"
/* clang-format off */
#define _PyTime_check_mul_overflow(a, b) \
(assert(b > 0), \

View file

@ -25,7 +25,6 @@
#include "third_party/python/Include/pyhash.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
#ifdef Py_DEBUG
int _Py_HashSecret_Initialized = 0;

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "third_party/python/Include/ceval.h"
/* clang-format off */
int
(Py_EnterRecursiveCall)(const char *where)

View file

@ -7,7 +7,6 @@
#include "libc/calls/calls.h"
#include "libc/sysv/consts/sig.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
*

View file

@ -6,7 +6,6 @@
*/
#include "third_party/python/Include/intrcheck.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
/* Sigcheck is similar to intrcheck() but sets an exception when an
interrupt occurs. It can't be in the intrcheck.c file since that

View file

@ -11,7 +11,6 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Map C struct members to Python object attributes */

View file

@ -17,7 +17,6 @@
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/symtable.h"
/* clang-format off */
/* error strings used for warnings */
#define GLOBAL_AFTER_ASSIGN \

View file

@ -49,7 +49,6 @@
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
PYTHON_PROVIDE("sys");
PYTHON_PROVIDE("sys.__displayhook__");

View file

@ -18,7 +18,6 @@
#include "third_party/python/Include/pythread.h"
#include "third_party/python/Include/structseq.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
/* Thread package.
This is intended to be usable independently from Python.

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/thread/semaphore.h"
/* clang-format off */
/* Posix threads interface */

View file

@ -24,7 +24,6 @@
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
/* clang-format off */
#define OFF(x) offsetof(PyTracebackObject, x)

View file

@ -5,7 +5,6 @@
https://docs.python.org/3/license.html
╚─────────────────────────────────────────────────────────────────────────────*/
#include "third_party/python/Include/code.h"
/* clang-format off */
/* This file contains code shared by the compiler and the peephole
optimizer.

View file

@ -25,7 +25,6 @@
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/xed/x86.h"
/* clang-format off */
PYTHON_PROVIDE("xed");
PYTHON_PROVIDE("xed.ild");

View file

@ -24,7 +24,6 @@
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("xterm");
PYTHON_PROVIDE("xterm.rgb2xterm256");