mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Undiamond Python headers
This change gets the Python codebase into a state where it conforms to the conventions of this codebase. It's now possible to include headers from Python, without worrying about ordering. Python has traditionally solved that problem by "diamonding" everything in Python.h, but that's problematic since it means any change to any Python header invalidates all the build artifacts. Lastly it makes tooling not work. Since it is hard to explain to Emacs when I press C-c C-h to add an import line it shouldn't add the header that actually defines the symbol, and instead do follow the nonstandard Python convention. Progress has been made on letting Python load source code from the zip executable structure via the standard C library APIs. System calss now recognizes zip!FILENAME alternative URIs as equivalent to zip:FILENAME since Python uses colon as its delimiter. Some progress has been made on embedding the notice license terms into the Python object code. This is easier said than done since Python has an extremely complicated ownership story. - Some termios APIs have been added - Implement rewinddir() dirstream API - GetCpuCount() API added to Cosmopolitan Libc - More bugs in Cosmopolitan Libc have been fixed - zipobj.com now has flags for mangling the path - Fixed bug a priori with sendfile() on certain BSDs - Polyfill F_DUPFD and F_DUPFD_CLOEXEC across platforms - FIOCLEX / FIONCLEX now polyfilled for fast O_CLOEXEC changes - APE now supports a hybrid solution to no-self-modify for builds - Many BSD-only magnums added, e.g. O_SEARCH, O_SHLOCK, SF_NODISKIO
This commit is contained in:
parent
20bb8db9f8
commit
b420ed8248
762 changed files with 18410 additions and 53772 deletions
12
third_party/python/Parser/acceler.c
vendored
12
third_party/python/Parser/acceler.c
vendored
|
@ -1,3 +1,9 @@
|
|||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
/* clang-format off */
|
||||
/* Parser accelerator module */
|
||||
|
||||
|
@ -10,12 +16,6 @@
|
|||
are not part of the static data structure written on graminit.[ch]
|
||||
by the parser generator. */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
|
||||
/* Forward references */
|
||||
static void fixdfa(grammar *, dfa *);
|
||||
static void fixstate(grammar *, state *);
|
||||
|
|
5
third_party/python/Parser/bitset.c
vendored
5
third_party/python/Parser/bitset.c
vendored
|
@ -1,10 +1,9 @@
|
|||
#include "third_party/python/Include/bitset.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Bitset primitives used by the parser generator */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/bitset.h"
|
||||
|
||||
bitset
|
||||
newbitset(int nbits)
|
||||
{
|
||||
|
|
9
third_party/python/Parser/firstsets.c
vendored
9
third_party/python/Parser/firstsets.c
vendored
|
@ -1,11 +1,12 @@
|
|||
#include "third_party/python/Include/bitset.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Computation of FIRST stets */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
|
||||
extern int Py_DebugFlag;
|
||||
|
||||
/* Forward */
|
||||
|
|
10
third_party/python/Parser/grammar.c
vendored
10
third_party/python/Parser/grammar.c
vendored
|
@ -1,12 +1,12 @@
|
|||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Grammar implementation */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
|
||||
extern int Py_DebugFlag;
|
||||
|
||||
grammar *
|
||||
|
|
9
third_party/python/Parser/grammar1.c
vendored
9
third_party/python/Parser/grammar1.c
vendored
|
@ -1,12 +1,11 @@
|
|||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Grammar subroutines needed by parser */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
|
||||
/* Return the DFA for the given type */
|
||||
|
||||
dfa *
|
||||
|
|
8
third_party/python/Parser/listnode.c
vendored
8
third_party/python/Parser/listnode.c
vendored
|
@ -1,11 +1,11 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* List a node on a file */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
|
||||
/* Forward */
|
||||
static void list1node(FILE *, node *);
|
||||
static void listnode(FILE *, node *);
|
||||
|
|
7
third_party/python/Parser/metagrammar.c
vendored
7
third_party/python/Parser/metagrammar.c
vendored
|
@ -1,9 +1,8 @@
|
|||
/* clang-format off */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/metagrammar.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/metagrammar.h"
|
||||
#include "third_party/python/Include/pgen.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
/* clang-format off */
|
||||
|
||||
static arc arcs_0_0[3] = {
|
||||
{2, 0},
|
||||
|
|
11
third_party/python/Parser/myreadline.c
vendored
11
third_party/python/Parser/myreadline.c
vendored
|
@ -1,3 +1,12 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/intrcheck.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Readline interface for tokenizer.c and [raw_]input() in bltinmodule.c.
|
||||
|
@ -10,8 +19,6 @@
|
|||
- a malloc'ed string ending in \n normally
|
||||
*/
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
PyThreadState* _PyOS_ReadlineTState;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
|
|
10
third_party/python/Parser/node.c
vendored
10
third_party/python/Parser/node.c
vendored
|
@ -1,12 +1,12 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Parse tree node implementation */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
|
||||
node *
|
||||
PyNode_New(int type)
|
||||
{
|
||||
|
|
19
third_party/python/Parser/parser.c
vendored
19
third_party/python/Parser/parser.c
vendored
|
@ -1,20 +1,17 @@
|
|||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Parser implementation */
|
||||
|
||||
/* For a description, see the comments at end of this file */
|
||||
|
||||
/* XXX To do: error recovery */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
extern int Py_DebugFlag;
|
||||
#define D(x) if (!Py_DebugFlag); else x
|
||||
|
|
15
third_party/python/Parser/parser.h
vendored
15
third_party/python/Parser/parser.h
vendored
|
@ -1,11 +1,9 @@
|
|||
#ifndef Py_PARSER_H
|
||||
#define Py_PARSER_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Parser interface */
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#define MAXSTACK 1500
|
||||
|
||||
|
@ -34,9 +32,6 @@ parser_state *PyParser_New(grammar *g, int start);
|
|||
void PyParser_Delete(parser_state *ps);
|
||||
int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset,
|
||||
int *expected_ret);
|
||||
void PyGrammar_AddAccelerators(grammar *g);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_PARSER_H */
|
||||
|
|
20
third_party/python/Parser/parsetok.c
vendored
20
third_party/python/Parser/parsetok.c
vendored
|
@ -1,17 +1,17 @@
|
|||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/graminit.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
#include "third_party/python/Parser/tokenizer.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Parser-tokenizer link implementation */
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Parser/tokenizer.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Parser/parser.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/graminit.h"
|
||||
|
||||
|
||||
/* Forward */
|
||||
static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int *);
|
||||
static int initerr(perrdetail *err_ret, PyObject * filename);
|
||||
|
|
17
third_party/python/Parser/pgen.c
vendored
17
third_party/python/Parser/pgen.c
vendored
|
@ -1,21 +1,18 @@
|
|||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/metagrammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/pgen.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Parser generator */
|
||||
|
||||
/* For a description, see the comments at end of this file */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/metagrammar.h"
|
||||
#include "third_party/python/Include/pgen.h"
|
||||
|
||||
extern int Py_DebugFlag;
|
||||
extern int Py_IgnoreEnvironmentFlag; /* needed by Py_GETENV */
|
||||
|
||||
|
||||
/* PART ONE -- CONSTRUCT NFA -- Cf. Algorithm 3.2 from [Aho&Ullman 77] */
|
||||
|
||||
typedef struct _nfaarc {
|
||||
|
|
22
third_party/python/Parser/pgenmain.c
vendored
22
third_party/python/Parser/pgenmain.c
vendored
|
@ -1,3 +1,13 @@
|
|||
#define PGEN
|
||||
#include "libc/log/log.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/pgen.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Parser generator main program */
|
||||
|
@ -14,15 +24,6 @@
|
|||
- check for duplicate definitions of names (instead of fatal err)
|
||||
*/
|
||||
|
||||
#define PGEN
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/pgen.h"
|
||||
|
||||
int Py_DebugFlag;
|
||||
int Py_VerboseFlag;
|
||||
int Py_IgnoreEnvironmentFlag;
|
||||
|
@ -176,9 +177,6 @@ Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj)
|
|||
return fgets(buf, n, stream);
|
||||
}
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void
|
||||
PySys_WriteStderr(const char *format, ...)
|
||||
{
|
||||
|
|
8
third_party/python/Parser/printgrammar.c
vendored
8
third_party/python/Parser/printgrammar.c
vendored
|
@ -1,12 +1,10 @@
|
|||
#define PGEN
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Print a bunch of C initializers that represent a grammar */
|
||||
|
||||
#define PGEN
|
||||
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
|
||||
/* Forward */
|
||||
static void printarcs(int, dfa *, FILE *);
|
||||
static void printstates(grammar *, FILE *);
|
||||
|
|
35
third_party/python/Parser/tokenizer.c
vendored
35
third_party/python/Parser/tokenizer.c
vendored
|
@ -1,21 +1,28 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Parser/tokenizer.h"
|
||||
#ifndef PGEN
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/bytearrayobject.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/codecs.h"
|
||||
#include "third_party/python/Include/fileobject.h"
|
||||
#include "third_party/python/Include/fileutils.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
#include "third_party/python/Include/pyctype.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/sysmodule.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
#endif
|
||||
/* clang-format off */
|
||||
|
||||
/* Tokenizer implementation */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
|
||||
#include "third_party/python/Parser/tokenizer.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
|
||||
#ifndef PGEN
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/fileobject.h"
|
||||
#include "third_party/python/Include/codecs.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#endif /* PGEN */
|
||||
|
||||
#define is_potential_identifier_start(c) (\
|
||||
(c >= 'a' && c <= 'z')\
|
||||
|| (c >= 'A' && c <= 'Z')\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue