[pypy-svn] r72344 - in pypy/branch/kill-python-h/pypy/translator/c: src test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 18 04:34:43 CET 2010
Author: arigo
Date: Thu Mar 18 04:34:42 2010
New Revision: 72344
Modified:
pypy/branch/kill-python-h/pypy/translator/c/src/g_include.h
pypy/branch/kill-python-h/pypy/translator/c/src/stack.h
pypy/branch/kill-python-h/pypy/translator/c/src/thread.h
pypy/branch/kill-python-h/pypy/translator/c/src/thread_pthread.h
pypy/branch/kill-python-h/pypy/translator/c/test/test_standalone.py
Log:
Tweak the macro usage until we no longer depend on pyconfig.h at all.
Modified: pypy/branch/kill-python-h/pypy/translator/c/src/g_include.h
==============================================================================
--- pypy/branch/kill-python-h/pypy/translator/c/src/g_include.h (original)
+++ pypy/branch/kill-python-h/pypy/translator/c/src/g_include.h Thu Mar 18 04:34:42 2010
@@ -54,9 +54,6 @@
#ifndef AVR
# include "src/ll_os.h"
# include "src/ll_strtod.h"
-# ifdef RPyExc_thread_error
-# include "src/ll_thread.h"
-# endif
#endif
#endif
Modified: pypy/branch/kill-python-h/pypy/translator/c/src/stack.h
==============================================================================
--- pypy/branch/kill-python-h/pypy/translator/c/src/stack.h (original)
+++ pypy/branch/kill-python-h/pypy/translator/c/src/stack.h Thu Mar 18 04:34:42 2010
@@ -6,9 +6,11 @@
# define MAX_STACK_SIZE (1 << 19)
#endif
+#ifdef _WIN32
/* This include must be done in any case to initialise
- * the header dependencies early (thread -> winsock2, before windows.h) */
-#include "thread.h"
+ * the header dependencies early (winsock2, before windows.h) */
+# include <winsock2.h>
+#endif
void LL_stack_unwind(void);
int LL_stack_too_big_slowpath(void);
Modified: pypy/branch/kill-python-h/pypy/translator/c/src/thread.h
==============================================================================
--- pypy/branch/kill-python-h/pypy/translator/c/src/thread.h (original)
+++ pypy/branch/kill-python-h/pypy/translator/c/src/thread.h Thu Mar 18 04:34:42 2010
@@ -9,20 +9,13 @@
#include "thread_nt.h"
#else
-#include <unistd.h>
-
-#ifndef _POSIX_THREADS
-/* This means pthreads are not implemented in libc headers, hence the macro
- not present in unistd.h. But they still can be implemented as an external
- library (e.g. gnu pth in pthread emulation) */
-# ifdef HAVE_PTHREAD_H
-# include <pthread.h> /* _POSIX_THREADS */
-# endif
-#endif
-
-#ifdef _POSIX_THREADS
+/* We should check if unistd.h defines _POSIX_THREADS, but sometimes
+ it is not defined even though the system implements them as an
+ external library (e.g. gnu pth in pthread emulation). So we just
+ always go ahead and use them, assuming they are supported on all
+ platforms for which we care. If not, do some detecting again.
+*/
#include "thread_pthread.h"
-#endif
#endif /* !_WIN32 */
Modified: pypy/branch/kill-python-h/pypy/translator/c/src/thread_pthread.h
==============================================================================
--- pypy/branch/kill-python-h/pypy/translator/c/src/thread_pthread.h (original)
+++ pypy/branch/kill-python-h/pypy/translator/c/src/thread_pthread.h Thu Mar 18 04:34:42 2010
@@ -1,10 +1,24 @@
/* Posix threads interface (from CPython) */
+/* XXX needs to detect HAVE_BROKEN_POSIX_SEMAPHORES properly; currently
+ it is set only if _POSIX_SEMAPHORES == -1. Seems to be only for
+ SunOS/5.8 and AIX/5.
+*/
+
+#include <unistd.h> /* for the _POSIX_xxx and _POSIX_THREAD_xxx defines */
+#include <stdlib.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <errno.h>
+/* The following is hopefully equivalent to what CPython does
+ (which is trying to compile a snippet of code using it) */
+#ifdef PTHREAD_SCOPE_SYSTEM
+# define PTHREAD_SYSTEM_SCHED_SUPPORTED
+#endif
+
/* The POSIX spec says that implementations supporting the sem_*
family of functions must indicate this by defining
_POSIX_SEMAPHORES. */
@@ -114,11 +128,11 @@
volatile pthread_t threadid;
/* Jump through some hoops for Alpha OSF/1 */
threadid = pthread_self();
-#if SIZEOF_PTHREAD_T <= SIZEOF_LONG
- return (long) threadid;
-#else
- return (long) *(long *) &threadid;
-#endif
+
+ if (sizeof(pthread_t) <= sizeof(long))
+ return (long) threadid;
+ else
+ return (long) *(long *) &threadid;
}
static long _pypythread_stacksize = 0;
@@ -171,11 +185,10 @@
pthread_detach(th);
-#if SIZEOF_PTHREAD_T <= SIZEOF_LONG
- return (long) th;
-#else
- return (long) *(long *) &th;
-#endif
+ if (sizeof(pthread_t) <= sizeof(long))
+ return (long) th;
+ else
+ return (long) *(long *) &th;
}
long RPyThreadGetStackSize(void)
Modified: pypy/branch/kill-python-h/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/branch/kill-python-h/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/branch/kill-python-h/pypy/translator/c/test/test_standalone.py Thu Mar 18 04:34:42 2010
@@ -674,7 +674,10 @@
def entry_point(argv):
os.write(1, "hello world\n")
error = ll_thread.set_stacksize(int(argv[1]))
- assert error == 0
+ if error != 0:
+ os.write(2, "set_stacksize(%d) returned %d\n" % (
+ int(argv[1]), error))
+ raise AssertionError
# malloc a bit
s1 = State(); s2 = State(); s3 = State()
s1.x = 0x11111111; s2.x = 0x22222222; s3.x = 0x33333333
More information about the Pypy-commit
mailing list