mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 09:50:28 +00:00
changes after review
This commit is contained in:
parent
2da34acf82
commit
988d9067c1
9 changed files with 23 additions and 42 deletions
1
third_party/python/Include/cosmo.h
vendored
1
third_party/python/Include/cosmo.h
vendored
|
@ -2,7 +2,6 @@
|
|||
#define Py_COSMO_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyMODINIT_FUNC PyInit_cosmo(void);
|
||||
|
||||
|
|
7
third_party/python/Include/pymem.h
vendored
7
third_party/python/Include/pymem.h
vendored
|
@ -29,7 +29,6 @@ int _PyMem_SetupAllocators(const char *opt);
|
|||
int _PyMem_PymallocEnabled(void);
|
||||
#endif
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
/* Identifier of an address space (domain) in tracemalloc */
|
||||
typedef unsigned int _PyTraceMalloc_domain_t;
|
||||
|
||||
|
@ -64,9 +63,9 @@ int _PyTraceMalloc_Untrack(
|
|||
PyObject* _PyTraceMalloc_GetTraceback(
|
||||
_PyTraceMalloc_domain_t domain,
|
||||
uintptr_t ptr);
|
||||
#else
|
||||
#define PyTraceMalloc_Track(domain, ptr, size) (-2)
|
||||
#define PyTraceMalloc_Untrack(domain, ptr) (-2)
|
||||
#ifndef MODE_DBG
|
||||
#define _PyTraceMalloc_Track(domain, ptr, size) (-2)
|
||||
#define _PyTraceMalloc_Untrack(domain, ptr) (-2)
|
||||
#define _PyTraceMalloc_GetTraceback(domain, ptr) (&_Py_NoneStruct)
|
||||
#endif
|
||||
|
||||
|
|
6
third_party/python/Modules/_testcapimodule.c
vendored
6
third_party/python/Modules/_testcapimodule.c
vendored
|
@ -4112,7 +4112,7 @@ pyobject_malloc_without_gil(PyObject *self, PyObject *args)
|
|||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#ifdef USE_TRACEMALLOC
|
||||
|
||||
static PyObject *
|
||||
tracemalloc_track(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -4184,7 +4184,7 @@ tracemalloc_get_traceback(PyObject *self, PyObject *args)
|
|||
|
||||
return _PyTraceMalloc_GetTraceback(domain, (uintptr_t)ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
dict_get_version(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -4539,11 +4539,9 @@ static PyMethodDef TestMethods[] = {
|
|||
{"pymem_api_misuse", pymem_api_misuse, METH_NOARGS},
|
||||
{"pymem_malloc_without_gil", pymem_malloc_without_gil, METH_NOARGS},
|
||||
{"pyobject_malloc_without_gil", pyobject_malloc_without_gil, METH_NOARGS},
|
||||
#ifdef USE_TRACEMALLOC
|
||||
{"tracemalloc_track", tracemalloc_track, METH_VARARGS},
|
||||
{"tracemalloc_untrack", tracemalloc_untrack, METH_VARARGS},
|
||||
{"tracemalloc_get_traceback", tracemalloc_get_traceback, METH_VARARGS},
|
||||
#endif
|
||||
{"dict_get_version", dict_get_version, METH_VARARGS},
|
||||
{"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS},
|
||||
{"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS},
|
||||
|
|
6
third_party/python/Modules/_tracemalloc.c
vendored
6
third_party/python/Modules/_tracemalloc.c
vendored
|
@ -1794,7 +1794,7 @@ _PyTraceMalloc_Fini(void)
|
|||
}
|
||||
|
||||
int
|
||||
_PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
|
||||
(_PyTraceMalloc_Track)(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
|
||||
size_t size)
|
||||
{
|
||||
int res;
|
||||
|
@ -1823,7 +1823,7 @@ _PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
|
|||
|
||||
|
||||
int
|
||||
_PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
|
||||
(_PyTraceMalloc_Untrack)(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
|
||||
{
|
||||
if (!tracemalloc_config.tracing) {
|
||||
/* tracemalloc is not tracing: do nothing */
|
||||
|
@ -1839,7 +1839,7 @@ _PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
|
|||
|
||||
|
||||
PyObject*
|
||||
_PyTraceMalloc_GetTraceback(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
|
||||
(_PyTraceMalloc_GetTraceback)(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
|
||||
{
|
||||
traceback_t *traceback;
|
||||
|
||||
|
|
2
third_party/python/Modules/config.c
vendored
2
third_party/python/Modules/config.c
vendored
|
@ -48,7 +48,7 @@ PyObject* PyInit__locale(void);
|
|||
PyObject* PyInit__io(void);
|
||||
PyObject* PyInit_zipimport(void);
|
||||
PyObject* PyInit_faulthandler(void);
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#ifdef MODE_DBG
|
||||
PyObject* PyInit__tracemalloc(void);
|
||||
#endif
|
||||
PyObject* PyInit__symtable(void);
|
||||
|
|
2
third_party/python/Objects/abstract.c
vendored
2
third_party/python/Objects/abstract.c
vendored
|
@ -2210,7 +2210,7 @@ PyObject_CallObject(PyObject *o, PyObject *a)
|
|||
return PyEval_CallObjectWithKeywords(o, a, NULL);
|
||||
}
|
||||
|
||||
#ifdef USE_CHECKFUNCRESULT
|
||||
#ifdef MODE_DBG
|
||||
PyObject*
|
||||
_Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where)
|
||||
{
|
||||
|
|
2
third_party/python/Objects/obmalloc.c
vendored
2
third_party/python/Objects/obmalloc.c
vendored
|
@ -16,7 +16,7 @@
|
|||
#include "third_party/python/Include/pymem.h"
|
||||
/* clang-format off */
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#ifdef MODE_DBG
|
||||
/* Defined in tracemalloc.c */
|
||||
extern void _PyMem_DumpTraceback(int fd, const void *ptr);
|
||||
#endif
|
||||
|
|
6
third_party/python/Python/pylifecycle.c
vendored
6
third_party/python/Python/pylifecycle.c
vendored
|
@ -76,7 +76,7 @@ extern void PyLong_Fini(void);
|
|||
extern int _PyFaulthandler_Init(void);
|
||||
extern void _PyFaulthandler_Fini(void);
|
||||
extern void _PyHash_Fini(void);
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#ifdef MODE_DBG
|
||||
extern int _PyTraceMalloc_Init(void);
|
||||
extern int _PyTraceMalloc_Fini(void);
|
||||
#endif
|
||||
|
@ -477,7 +477,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
|
|||
if (install_sigs)
|
||||
initsigs(); /* Signal handling stuff, including initintr() */
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#ifdef MODE_DBG
|
||||
if (_PyTraceMalloc_Init() < 0)
|
||||
Py_FatalError("Py_Initialize: can't initialize tracemalloc");
|
||||
#endif
|
||||
|
@ -669,7 +669,7 @@ Py_FinalizeEx(void)
|
|||
_PyGC_CollectIfEnabled();
|
||||
#endif
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#ifdef MODE_DBG
|
||||
/* Disable tracemalloc after all Python objects have been destroyed,
|
||||
so it is possible to use tracemalloc in objects destructor. */
|
||||
_PyTraceMalloc_Fini();
|
||||
|
|
33
third_party/python/python.mk
vendored
33
third_party/python/python.mk
vendored
|
@ -49,13 +49,6 @@ THIRD_PARTY_PYTHON_STDLIB_DIRS_OBJS = $(THIRD_PARTY_PYTHON_STDLIB_DIRS:%=o/$(MOD
|
|||
THIRD_PARTY_PYTHON_STDLIB_DATA_OBJS = $(THIRD_PARTY_PYTHON_STDLIB_DATA:%=o/$(MODE)/%.zip.o)
|
||||
THIRD_PARTY_PYTHON_STDLIB_PYCS = $(THIRD_PARTY_PYTHON_STDLIB_PYS:%=o/$(MODE)/%c)
|
||||
|
||||
THIRD_PARTY_PYTHON_FLAGS = \
|
||||
-DNDEBUG \
|
||||
-DPy_BUILD_CORE \
|
||||
-DPLATFORM='"cosmo"' \
|
||||
-DMULTIARCH='"x86_64-cosmo"'
|
||||
|
||||
|
||||
THIRD_PARTY_PYTHON_HDRS = \
|
||||
third_party/python/Include/yoink.h \
|
||||
third_party/python/Include/object.h \
|
||||
|
@ -315,8 +308,9 @@ THIRD_PARTY_PYTHON_INCS = \
|
|||
third_party/python/Modules/unicodedata_db.inc
|
||||
|
||||
THIRD_PARTY_PYTHON_STAGE1_A_SRCS = \
|
||||
third_party/python/Modules/_tracemalloc.c \
|
||||
third_party/python/Modules/faulthandler.c \
|
||||
third_party/python/Objects/abstract.c \
|
||||
third_party/python/Objects/abstract.c \
|
||||
third_party/python/Modules/fspath.c \
|
||||
third_party/python/Modules/gcmodule.c \
|
||||
third_party/python/Modules/getbuildinfo.c \
|
||||
|
@ -471,6 +465,7 @@ THIRD_PARTY_PYTHON_STAGE2_A_SRCS = \
|
|||
third_party/python/Modules/_stat.c \
|
||||
third_party/python/Modules/_struct.c \
|
||||
third_party/python/Modules/_testcapimodule.c \
|
||||
third_party/python/Modules/_tracemalloc.c \
|
||||
third_party/python/Modules/_weakref.c \
|
||||
third_party/python/Modules/arraymodule.c \
|
||||
third_party/python/Modules/atexitmodule.c \
|
||||
|
@ -1472,6 +1467,7 @@ THIRD_PARTY_PYTHON_STDLIB_PYS = \
|
|||
third_party/python/Lib/tokenize.py \
|
||||
third_party/python/Lib/trace.py \
|
||||
third_party/python/Lib/traceback.py \
|
||||
third_party/python/Lib/tracemalloc.py \
|
||||
third_party/python/Lib/tty.py \
|
||||
third_party/python/Lib/types.py \
|
||||
third_party/python/Lib/typing.py \
|
||||
|
@ -1822,6 +1818,7 @@ THIRD_PARTY_PYTHON_STDLIB_PYS = \
|
|||
third_party/python/Lib/test/test_cmd_line.py \
|
||||
third_party/python/Lib/test/test_bool.py \
|
||||
third_party/python/Lib/test/test_urllib2_localnet.py \
|
||||
third_party/python/Lib/test/test_tracemalloc.py \
|
||||
third_party/python/Lib/test/mapping_tests.py \
|
||||
third_party/python/Lib/test/test_tempfile.py \
|
||||
third_party/python/Lib/test/test_socketserver.py \
|
||||
|
@ -2166,21 +2163,6 @@ THIRD_PARTY_PYTHON_STDLIB_PYS = \
|
|||
third_party/python/Lib/test/test_nntplib.py \
|
||||
third_party/python/Lib/test/test_uu.py
|
||||
|
||||
ifeq ($(MODE), dbg)
|
||||
THIRD_PARTY_PYTHON_FLAGS += \
|
||||
-DUSE_TRACEMALLOC \
|
||||
-DUSE_CHECKFUNCRESULT \
|
||||
-DUSE_BADINTERNALCALL
|
||||
THIRD_PARTY_PYTHON_STAGE1_A_SRCS += \
|
||||
third_party/python/Modules/_tracemalloc.c
|
||||
THIRD_PARTY_PYTHON_STAGE2_A_SRCS += \
|
||||
third_party/python/Modules/_tracemalloc.c
|
||||
THIRD_PARTY_PYTHON_STDLIB_PYS += \
|
||||
third_party/python/Lib/tracemalloc.py \
|
||||
third_party/python/Lib/test/test_tracemalloc.py
|
||||
endif
|
||||
|
||||
|
||||
THIRD_PARTY_PYTHON_STAGE1_A_DIRECTDEPS = \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
|
@ -2328,7 +2310,10 @@ o/$(MODE)/third_party/python/Python/sysmodule.o: \
|
|||
$(THIRD_PARTY_PYTHON_STAGE1_A_OBJS) \
|
||||
$(THIRD_PARTY_PYTHON_STAGE2_A_OBJS): \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
$(THIRD_PARTY_PYTHON_FLAGS)
|
||||
-DNDEBUG \
|
||||
-DPy_BUILD_CORE \
|
||||
-DPLATFORM='"cosmo"' \
|
||||
-DMULTIARCH='"x86_64-cosmo"'
|
||||
|
||||
o/$(MODE)/third_party/python/Modules/getbuildinfo.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue