[pypy-commit] pypy remove-PYPY_NOT_MAIN_FILE: Move allocator.c out of headers

amauryfa noreply at buildbot.pypy.org
Tue Sep 4 22:47:15 CEST 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: remove-PYPY_NOT_MAIN_FILE
Changeset: r57130:34bb1606fec3
Date: 2012-07-21 23:14 +0200
http://bitbucket.org/pypy/pypy/changeset/34bb1606fec3/

Log:	Move allocator.c out of headers

diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -534,9 +534,9 @@
             ('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) $(ASMFILES)'),
             ('debug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT" debug_target'),
             ('debug_exc', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DDO_LOG_EXC" debug_target'),
-            ('debug_mem', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DTRIVIAL_MALLOC_DEBUG" debug_target'),
-            ('no_obmalloc', '', '$(MAKE) CFLAGS="-g -O2 -DRPY_ASSERT -DNO_OBMALLOC" $(TARGET)'),
-            ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" debug_target'),
+            ('debug_mem', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DPYPY_USE_TRIVIAL_MALLOC" debug_target'),
+            ('no_obmalloc', '', '$(MAKE) CFLAGS="-g -O2 -DRPY_ASSERT -DPYPY_NO_OBMALLOC" $(TARGET)'),
+            ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DPPY_USE_LINUXMEMCHK" debug_target'),
             ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'),
             ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'),
             ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'),
@@ -950,6 +950,7 @@
 def add_extra_files(eci):
     srcdir = py.path.local(autopath.pypydir).join('translator', 'c', 'src')
     files = [
+        srcdir / 'allocator.c',
         srcdir / 'profiling.c',
         srcdir / 'debug_print.c',
         srcdir / 'thread.c',
diff --git a/pypy/translator/c/src/allocator.c b/pypy/translator/c/src/allocator.c
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/src/allocator.c
@@ -0,0 +1,24 @@
+/* allocation functions */
+#include "common_header.h"
+
+#if defined(PYPY_USE_TRIVIAL_MALLOC)
+  void *PyObject_Malloc(size_t n) { return malloc(n); }
+  void *PyObject_Realloc(void *p, size_t n) { return realloc(p, n); }
+  void PyObject_Free(void *p) { if (p) { *((int*)p) = 0xDDDDDDDD; } free(p); }
+
+#elif defined(PYPY_USE_LINUXMEMCHK)
+#  include "linuxmemchk.c"
+
+#elif defined(PYPY_NO_OBMALLOC)
+  void *PyObject_Malloc(size_t n) { return malloc(n); }
+  void *PyObject_Realloc(void *p, size_t n) { return realloc(p, n); }
+  void PyObject_Free(void *p) { free(p); }
+
+#else
+#  ifndef WITH_PYMALLOC
+#    define WITH_PYMALLOC
+#  endif
+/* The same obmalloc as CPython */
+#  include "src/obmalloc.c"
+
+#endif
diff --git a/pypy/translator/c/src/allocator.h b/pypy/translator/c/src/allocator.h
--- a/pypy/translator/c/src/allocator.h
+++ b/pypy/translator/c/src/allocator.h
@@ -1,31 +1,4 @@
-
 /* allocation functions prototypes */
 void *PyObject_Malloc(size_t n);
 void *PyObject_Realloc(void *p, size_t n);
 void PyObject_Free(void *p);
-
-
-#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
-
-#if defined(TRIVIAL_MALLOC_DEBUG)
-  void *PyObject_Malloc(size_t n) { return malloc(n); }
-  void *PyObject_Realloc(void *p, size_t n) { return realloc(p, n); }
-  void PyObject_Free(void *p) { if (p) { *((int*)p) = 0xDDDDDDDD; } free(p); }
-
-#elif defined(LINUXMEMCHK)
-#  include "linuxmemchk.c"
-
-#elif defined(NO_OBMALLOC)
-  void *PyObject_Malloc(size_t n) { return malloc(n); }
-  void *PyObject_Realloc(void *p, size_t n) { return realloc(p, n); }
-  void PyObject_Free(void *p) { free(p); }
-
-#else
-#  ifndef WITH_PYMALLOC
-#    define WITH_PYMALLOC
-#  endif
-#  include "obmalloc.c"
-
-#endif
-
-#endif


More information about the pypy-commit mailing list