Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r76234:f60fdd5b5b05
Date: 2015-03-04 00:29 +0100
http://bitbucket.org/pypy/pypy/changeset/f60fdd5b5b05/

Log:    Fix compilation of _testcapimodule

diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c
--- a/lib_pypy/_testcapimodule.c
+++ b/lib_pypy/_testcapimodule.c
@@ -2444,8 +2444,6 @@
     return PyLong_FromLong(r);
 }
 
-#endif  /* PYPY_VERSION */
-
 static PyObject *
 test_pytime_object_to_time_t(PyObject *self, PyObject *args)
 {
@@ -2484,6 +2482,8 @@
     return Py_BuildValue("Nl", _PyLong_FromTime_t(sec), nsec);
 }
 
+#endif  /* PYPY_VERSION */
+
 #ifdef WITH_THREAD
 typedef struct {
     PyThread_type_lock start_event;
@@ -2668,10 +2668,10 @@
     {"crash_no_current_thread", (PyCFunction)crash_no_current_thread, 
METH_NOARGS},
 #ifndef PYPY_VERSION
     {"run_in_subinterp",        run_in_subinterp,                METH_VARARGS},
-#endif
     {"pytime_object_to_time_t", test_pytime_object_to_time_t,  METH_VARARGS},
     {"pytime_object_to_timeval", test_pytime_object_to_timeval,  METH_VARARGS},
     {"pytime_object_to_timespec", test_pytime_object_to_timespec,  
METH_VARARGS},
+#endif
 #ifdef WITH_THREAD
     {"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_O,
      PyDoc_STR("set_error_class(error_class) -> None")},
diff --git a/pypy/module/cpyext/include/pymacro.h 
b/pypy/module/cpyext/include/pymacro.h
--- a/pypy/module/cpyext/include/pymacro.h
+++ b/pypy/module/cpyext/include/pymacro.h
@@ -1,6 +1,21 @@
 #ifndef Py_PYMACRO_H
 #define Py_PYMACRO_H
 
+/* Assert a build-time dependency, as an expression.
+
+   Your compile will fail if the condition isn't true, or can't be evaluated
+   by the compiler. This can be used in an expression: its value is 0.
+
+   Example:
+
+   #define foo_to_char(foo)  \
+       ((char *)(foo)        \
+        + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
+
+   Written by Rusty Russell, public domain, http://ccodearchive.net/ */
+#define Py_BUILD_ASSERT_EXPR(cond) \
+    (sizeof(char [1 - 2*!(cond)]) - 1)
+
 /* Get the number of elements in a visible array
 
    This does not work on pointers, or arrays declared as [], or function
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to