Author: mattip <matti.pi...@gmail.com>
Branch: cpyext-ext
Changeset: r83213:1c960078443c
Date: 2016-03-21 13:13 +0200
http://bitbucket.org/pypy/pypy/changeset/1c960078443c/

Log:    implement PyThread_init_thread as a NOP, start to implement
        PyThread_start_new_thread

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -429,7 +429,7 @@
     'PyThread_acquire_lock', 'PyThread_release_lock',
     'PyThread_create_key', 'PyThread_delete_key', 'PyThread_set_key_value',
     'PyThread_get_key_value', 'PyThread_delete_key_value',
-    'PyThread_ReInitTLS',
+    'PyThread_ReInitTLS', 'PyThread_init_thread',
 
     'PyStructSequence_InitType', 'PyStructSequence_New',
     'PyStructSequence_UnnamedField',
diff --git a/pypy/module/cpyext/pystate.py b/pypy/module/cpyext/pystate.py
--- a/pypy/module/cpyext/pystate.py
+++ b/pypy/module/cpyext/pystate.py
@@ -54,6 +54,15 @@
         return 0
     return 1
 
+thread_func = lltype.Ptr(lltype.FuncType([rffi.VOIDP], lltype.Void))
+@cpython_api([thread_func, rffi.VOIDP], rffi.INT_real, error=-1)
+def PyThread_start_new_thread(space, func, arg):
+    from pypy.module.thread import os_thread
+    w_args = space.newtuple([arg])
+    XXX # How to wrap func as a space.callable ?
+    os_thread.start_new_thread(space, func, w_args)
+    return 0
+
 # XXX: might be generally useful
 def encapsulator(T, flavor='raw', dealloc=None):
     class MemoryCapsule(object):
diff --git a/pypy/module/cpyext/src/pythread.c 
b/pypy/module/cpyext/src/pythread.c
--- a/pypy/module/cpyext/src/pythread.c
+++ b/pypy/module/cpyext/src/pythread.c
@@ -15,6 +15,17 @@
 #endif
 }
 
+static int initialized;
+
+void
+PyThread_init_thread(void)
+{
+    if (initialized)
+        return;
+    initialized = 1;
+    /*PyThread__init_thread(); a NOP on modern platforms */
+}
+
 PyThread_type_lock
 PyThread_allocate_lock(void)
 {
diff --git a/pypy/module/cpyext/stubsactive.py 
b/pypy/module/cpyext/stubsactive.py
--- a/pypy/module/cpyext/stubsactive.py
+++ b/pypy/module/cpyext/stubsactive.py
@@ -42,7 +42,3 @@
     """
     return -1
 
-thread_func = lltype.Ptr(lltype.FuncType([rffi.VOIDP], lltype.Void))
-@cpython_api([thread_func, rffi.VOIDP], rffi.INT_real, error=-1)
-def PyThread_start_new_thread(space, func, arg):
-    return -1
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to