Commit 5ba655be authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge branch 'zlib'

parents bff16616 aea9ef2d
......@@ -290,7 +290,7 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS := stdlib.release.bc.o
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c $(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c $(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS := structseq.c capsule.c stringobject.c $(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS := pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.c $(EXTRA_STDPYTHON_SRCS)
FROM_CPYTHON_SRCS := $(addprefix from_cpython/Modules/,$(STDMODULE_SRCS)) $(addprefix from_cpython/Objects/,$(STDOBJECT_SRCS)) $(addprefix from_cpython/Python/,$(STDPYTHON_SRCS))
......
......@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
add_custom_target(copy_stdlib ALL DEPENDS ${STDLIB_TARGETS})
# compile specified files in from_cpython/Modules
file(GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c)
file(GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c)
# compile specified files in from_cpython/Objects
file(GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c)
......
......@@ -27,6 +27,7 @@
#define SIZEOF_INT 4
#define SIZEOF_LONG 8
#define SIZEOF_LONG_LONG 8
#define SIZEOF_PTHREAD_T 8
#define HAVE_COPYSIGN 1
#define HAVE_ROUND 1
#define HAVE_HYPOT 1
......
......@@ -283,6 +283,16 @@ extern "C" int PyModule_AddObject(PyObject* _m, const char* name, PyObject* valu
return 0;
}
extern "C" int PyModule_AddStringConstant(PyObject* m, const char* name, const char* value) noexcept {
PyObject* o = PyString_FromString(value);
if (!o)
return -1;
if (PyModule_AddObject(m, name, o) == 0)
return 0;
Py_DECREF(o);
return -1;
}
extern "C" int PyModule_AddIntConstant(PyObject* _m, const char* name, long value) noexcept {
return PyModule_AddObject(_m, name, boxInt(value));
}
......
......@@ -613,10 +613,6 @@ void allowGLReadPreemption() {
}
#endif
extern "C" long PyThread_get_thread_ident(void) noexcept {
return pthread_self();
}
// We don't support CPython's TLS (yet?)
extern "C" void PyThread_ReInitTLS(void) noexcept {
// don't have to do anything since we don't support TLS
......
......@@ -12,8 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <pthread.h>
#include <stddef.h>
#include "Python.h"
#include "pythread.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/objmodel.h"
......@@ -21,6 +25,34 @@
using namespace pyston::threading;
static int initialized;
static void PyThread__init_thread(void); /* Forward */
extern "C" void PyThread_init_thread(void) noexcept {
#ifdef Py_DEBUG
char* p = Py_GETENV("PYTHONTHREADDEBUG");
if (p) {
if (*p)
thread_debug = atoi(p);
else
thread_debug = 1;
}
#endif /* Py_DEBUG */
if (initialized)
return;
initialized = 1;
PyThread__init_thread();
}
/* Support for runtime thread stack size tuning.
A value of 0 means using the platform's default stack size
or the size specified by the THREAD_STACK_SIZE macro. */
static size_t _pythread_stacksize = 0;
#include "thread_pthread.h"
namespace pyston {
BoxedModule* thread_module;
......
This diff is collapsed.
......@@ -61,6 +61,7 @@ extern "C" void initselect();
extern "C" void initfcntl();
extern "C" void inittime();
extern "C" void initarray();
extern "C" void initzlib();
namespace pyston {
......@@ -1321,6 +1322,7 @@ void setupRuntime() {
initfcntl();
inittime();
initarray();
initzlib();
setupSysEnd();
......
import zlib
s = "hello world!"
s2 = zlib.compress(s)
print repr(s2)
s3 = zlib.decompress(s2)
print repr(s3)
......@@ -2,7 +2,13 @@ import os
import sys
def file_is_from_cpython(fn):
return 'from_cpython' in fn
if 'from_cpython' in fn:
return True
if fn.endswith("/thread_pthread.h"):
return True
return False
def verify_include_guard(_, dir, files):
for bn in files:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment