mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Make fixes, improvements, and chibicc python bindings
- python now mixes audio 10x faster - python octal notation is restored - chibicc now builds code 3x faster - chibicc now has help documentation - chibicc can now generate basic python bindings - linenoise now supports some paredit-like features See #141
This commit is contained in:
parent
28997f3acb
commit
7061c79c22
121 changed files with 5272 additions and 1928 deletions
52
third_party/python/Include/ceval.h
vendored
52
third_party/python/Include/ceval.h
vendored
|
@ -2,7 +2,6 @@
|
|||
#define Py_CEVAL_H
|
||||
#include "libc/bits/likely.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
|
@ -102,31 +101,34 @@ int Py_GetRecursionLimit(void);
|
|||
#define _Py_MakeEndRecCheck(x) \
|
||||
(--(x) < _Py_RecursionLimitLowerWaterMark(_Py_CheckRecursionLimit))
|
||||
|
||||
int _Py_CheckRecursiveCall(const char *);
|
||||
int Py_EnterRecursiveCall(const char *);
|
||||
void Py_LeaveRecursiveCall(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
extern int _Py_CheckRecursionLimit;
|
||||
|
||||
forceinline int Py_EnterRecursiveCall(const char *where) {
|
||||
const char *rsp, *bot;
|
||||
if (!IsTiny()) {
|
||||
if (IsModeDbg()) {
|
||||
PyThreadState_GET()->recursion_depth++;
|
||||
return _Py_CheckRecursiveCall(where);
|
||||
} else {
|
||||
rsp = __builtin_frame_address(0);
|
||||
asm(".weak\tape_stack_vaddr\n\t"
|
||||
"movabs\t$ape_stack_vaddr+32768,%0" : "=r"(bot));
|
||||
if (UNLIKELY(rsp < bot)) {
|
||||
PyErr_Format(PyExc_MemoryError, "Stack overflow%s", where);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
forceinline void Py_LeaveRecursiveCall(void) {
|
||||
PyThreadState_GET()->recursion_depth--;
|
||||
}
|
||||
int _Py_CheckRecursiveCall(const char *);
|
||||
#define Py_LeaveRecursiveCall() PyThreadState_GET()->recursion_depth--
|
||||
#define Py_EnterRecursiveCall(where) \
|
||||
({ \
|
||||
int rc = 0; \
|
||||
const char *rsp, *bot; \
|
||||
if (!IsTiny()) { \
|
||||
if (IsModeDbg()) { \
|
||||
PyThreadState_GET()->recursion_depth++; \
|
||||
rc = _Py_CheckRecursiveCall(where); \
|
||||
} else { \
|
||||
rsp = __builtin_frame_address(0); \
|
||||
asm(".weak\tape_stack_vaddr\n\t" \
|
||||
"movabs\t$ape_stack_vaddr+32768,%0" : "=r"(bot)); \
|
||||
if (UNLIKELY(rsp < bot)) { \
|
||||
PyErr_Format(PyExc_MemoryError, "Stack overflow%s", where); \
|
||||
rc = -1; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
rc; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define Py_ALLOW_RECURSION \
|
||||
do { \
|
||||
|
|
62
third_party/python/Include/pyctype.h
vendored
62
third_party/python/Include/pyctype.h
vendored
|
@ -6,36 +6,50 @@
|
|||
#define Py_TOLOWER(c) kToLower[255 & (c)]
|
||||
#define Py_TOUPPER(c) kToUpper[255 & (c)]
|
||||
|
||||
forceinline bool Py_ISDIGIT(unsigned char c) {
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
#define Py_ISDIGIT(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
'0' <= c_&& c_ <= '9'; \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISLOWER(unsigned char c) {
|
||||
return 'a' <= c && c <= 'z';
|
||||
}
|
||||
#define Py_ISLOWER(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
'a' <= c_&& c_ <= 'z'; \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISUPPER(unsigned char c) {
|
||||
return 'A' <= c && c <= 'Z';
|
||||
}
|
||||
#define Py_ISUPPER(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
'A' <= c_&& c_ <= 'Z'; \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISALPHA(unsigned char c) {
|
||||
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
|
||||
}
|
||||
#define Py_ISALPHA(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
('A' <= c_ && c_ <= 'Z') || ('a' <= c_ && c_ <= 'z'); \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISALNUM(unsigned char c) {
|
||||
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') ||
|
||||
('a' <= c && c <= 'z');
|
||||
}
|
||||
#define Py_ISALNUM(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(('0' <= c_ && c_ <= '9') || ('A' <= c_ && c_ <= 'Z') || \
|
||||
('a' <= c_ && c_ <= 'z')); \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISSPACE(unsigned char c) {
|
||||
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' ||
|
||||
c == '\v';
|
||||
}
|
||||
#define Py_ISSPACE(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(c_ == ' ' || c_ == '\t' || c_ == '\r' || c_ == '\n' || c_ == '\f' || \
|
||||
c_ == '\v'); \
|
||||
})
|
||||
|
||||
forceinline bool Py_ISXDIGIT(unsigned char c) {
|
||||
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
|
||||
('a' <= c && c <= 'f');
|
||||
}
|
||||
#define Py_ISXDIGIT(C) \
|
||||
({ \
|
||||
unsigned char c_ = (C); \
|
||||
(('0' <= c_ && c_ <= '9') || ('A' <= c_ && c_ <= 'F') || \
|
||||
('a' <= c_ && c_ <= 'f')); \
|
||||
})
|
||||
|
||||
#endif /* !PYCTYPE_H */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue