[pypy-svn] r31719 - pypy/branch/no-zeroing-assumption/pypy/translator/c/src
mwh at codespeak.net
mwh at codespeak.net
Sun Aug 27 13:06:53 CEST 2006
Author: mwh
Date: Sun Aug 27 13:06:50 2006
New Revision: 31719
Modified:
pypy/branch/no-zeroing-assumption/pypy/translator/c/src/mem.h
Log:
tidy up .h file -- allow a #define to control whether raw malloc zeros or not.
cowardly make raw malloc zero again.
also, we don't need .h support for the no-gc policy any more (this has probably
been true for months and months)
Modified: pypy/branch/no-zeroing-assumption/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/no-zeroing-assumption/pypy/translator/c/src/mem.h (original)
+++ pypy/branch/no-zeroing-assumption/pypy/translator/c/src/mem.h Sun Aug 27 13:06:50 2006
@@ -2,6 +2,24 @@
/************************************************************/
/*** C header subsection: operations on LowLevelTypes ***/
+#define RAW_MALLOC_ZERO_FILLED 0
+
+#if RAW_MALLOC_ZERO_FILLED
+
+#define OP_RAW_MALLOC(size, r, restype) { \
+ r = (restype) PyObject_Malloc(size); \
+ if (r == NULL) { \
+ FAIL_EXCEPTION(PyExc_MemoryError, \
+ "out of memory"); \
+ } \
+ else { \
+ memset((void*)r, 0, size); \
+ COUNT_MALLOC; \
+ } \
+ }
+
+#else
+
#define OP_RAW_MALLOC(size, r, restype) { \
r = (restype) PyObject_Malloc(size); \
if (r == NULL) { \
@@ -13,6 +31,8 @@
} \
}
+#endif
+
#define OP_RAW_FREE(p, r) PyObject_Free(p); COUNT_FREE;
#define OP_RAW_MEMCLEAR(p, size, r) memset((void*)p, 0, size)
@@ -26,7 +46,7 @@
#ifdef USING_BOEHM_GC
#define MALLOC_ZERO_FILLED 1
#else
-#define MALLOC_ZERO_FILLED 0
+#define MALLOC_ZERO_FILLED 1
#endif
#define OP_STACK_MALLOC(size,r,restype) \
@@ -57,11 +77,19 @@
other globals, plus one. This upper bound "approximation" will do... */
#define REFCOUNT_IMMORTAL (INT_MAX/2)
+#if RAW_MALLOC_ZERO_FILLED
+
+#define OP_ZERO_MALLOC OP_RAW_MALLOC
+
+#else
+
#define OP_ZERO_MALLOC(size, r, restype) { \
OP_RAW_MALLOC(size, r, restype); \
if (r != NULL) OP_RAW_MEMCLEAR(r, size, /* */); \
}
+#endif
+
#define OP_FREE(p) OP_RAW_FREE(p, do_not_use)
/*------------------------------------------------------------*/
@@ -118,25 +146,6 @@
#endif /* USING_BOEHM_GC */
-/* for no GC */
-#ifdef USING_NO_GC
-
-#undef OP_ZERO_MALLOC
-
-#define OP_ZERO_MALLOC(size, r, restype) { \
- r = (restype) malloc(size); \
- if (r == NULL) { FAIL_EXCEPTION(PyExc_MemoryError, "out of memory"); } \
- else { \
- memset((void*) r, 0, size); \
- COUNT_MALLOC; \
- } \
- }
-
-#undef PUSH_ALIVE
-#define PUSH_ALIVE(obj)
-
-#endif /* USING_NO_GC */
-
/************************************************************/
/* rcpy support */
More information about the Pypy-commit
mailing list