[pypy-commit] pypy remove-PYPY_NOT_MAIN_FILE: Be positive: #define PYPY_MAIN_IMPLEMENTATION_FILE when we need the implementation
amauryfa
noreply at buildbot.pypy.org
Sat Jul 21 21:22:41 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: remove-PYPY_NOT_MAIN_FILE
Changeset: r56382:e605968b764e
Date: 2012-07-21 21:21 +0200
http://bitbucket.org/pypy/pypy/changeset/e605968b764e/
Log: Be positive: #define PYPY_MAIN_IMPLEMENTATION_FILE when we need the
implementation of the C helper functions.
diff --git a/pypy/module/cpyext/src/thread.c b/pypy/module/cpyext/src/thread.c
--- a/pypy/module/cpyext/src/thread.c
+++ b/pypy/module/cpyext/src/thread.c
@@ -1,8 +1,5 @@
#include <Python.h>
#include "pythread.h"
-
-/* With PYPY_NOT_MAIN_FILE only declarations are imported */
-#define PYPY_NOT_MAIN_FILE
#include "src/thread.h"
long
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
@@ -794,7 +794,6 @@
print >> fc, '/***********************************************************/'
print >> fc, '/*** Structure Implementations ***/'
print >> fc
- print >> fc, '#define PYPY_NOT_MAIN_FILE'
print >> fc, '#include "common_header.h"'
print >> fc, '#include "structdef.h"'
print >> fc, '#include "forwarddecl.h"'
@@ -815,7 +814,6 @@
print >> fc, '/***********************************************************/'
print >> fc, '/*** Non-function Implementations ***/'
print >> fc
- print >> fc, '#define PYPY_NOT_MAIN_FILE'
print >> fc, '#include "common_header.h"'
print >> fc, '#include "structdef.h"'
print >> fc, '#include "forwarddecl.h"'
@@ -839,7 +837,6 @@
print >> fc, '/***********************************************************/'
print >> fc, '/*** Implementations ***/'
print >> fc
- print >> fc, '#define PYPY_NOT_MAIN_FILE'
print >> fc, '#define PYPY_FILE_NAME "%s"' % name
print >> fc, '#include "common_header.h"'
print >> fc, '#include "structdef.h"'
@@ -974,6 +971,7 @@
#
# Header
#
+ print >> f, '#define PYPY_MAIN_IMPLEMENTATION_FILE'
print >> f, '#include "common_header.h"'
print >> f
commondefs(defines)
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
@@ -5,7 +5,7 @@
void PyObject_Free(void *p);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#if defined(TRIVIAL_MALLOC_DEBUG)
void *PyObject_Malloc(size_t n) { return malloc(n); }
diff --git a/pypy/translator/c/src/asm_gcc_x86.h b/pypy/translator/c/src/asm_gcc_x86.h
--- a/pypy/translator/c/src/asm_gcc_x86.h
+++ b/pypy/translator/c/src/asm_gcc_x86.h
@@ -110,7 +110,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
# if 0 /* disabled */
void op_int_overflowed(void)
diff --git a/pypy/translator/c/src/asm_msvc.h b/pypy/translator/c/src/asm_msvc.h
--- a/pypy/translator/c/src/asm_msvc.h
+++ b/pypy/translator/c/src/asm_msvc.h
@@ -7,7 +7,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#ifdef PYPY_X86_CHECK_SSE2
#include <intrin.h>
void pypy_x86_check_sse2(void)
diff --git a/pypy/translator/c/src/asm_ppc.h b/pypy/translator/c/src/asm_ppc.h
--- a/pypy/translator/c/src/asm_ppc.h
+++ b/pypy/translator/c/src/asm_ppc.h
@@ -1,7 +1,7 @@
void LL_flush_icache(long base, long size);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#define __dcbst(base, index) \
__asm__ ("dcbst %0, %1" : /*no result*/ : "b%" (index), "r" (base) : "memory")
diff --git a/pypy/translator/c/src/debug_alloc.h b/pypy/translator/c/src/debug_alloc.h
--- a/pypy/translator/c/src/debug_alloc.h
+++ b/pypy/translator/c/src/debug_alloc.h
@@ -19,7 +19,7 @@
/************************************************************/
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
struct pypy_debug_alloc_s {
struct pypy_debug_alloc_s *next;
diff --git a/pypy/translator/c/src/debug_print.c b/pypy/translator/c/src/debug_print.c
--- a/pypy/translator/c/src/debug_print.c
+++ b/pypy/translator/c/src/debug_print.c
@@ -1,5 +1,3 @@
-#define PYPY_NOT_MAIN_FILE
-
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/pypy/translator/c/src/debug_traceback.h b/pypy/translator/c/src/debug_traceback.h
--- a/pypy/translator/c/src/debug_traceback.h
+++ b/pypy/translator/c/src/debug_traceback.h
@@ -70,7 +70,7 @@
/************************************************************/
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
int pypydtcount = 0;
struct pypydtentry_s pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH];
@@ -137,4 +137,4 @@
abort();
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/dtoa.c b/pypy/translator/c/src/dtoa.c
--- a/pypy/translator/c/src/dtoa.c
+++ b/pypy/translator/c/src/dtoa.c
@@ -127,7 +127,6 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
-#define PYPY_NOT_MAIN_FILE
#include "src/asm.h"
#define PyMem_Malloc malloc
#define PyMem_Free free
diff --git a/pypy/translator/c/src/exception.h b/pypy/translator/c/src/exception.h
--- a/pypy/translator/c/src/exception.h
+++ b/pypy/translator/c/src/exception.h
@@ -2,7 +2,7 @@
/************************************************************/
/*** C header subsection: exceptions ***/
-#if defined(PYPY_CPYTHON_EXTENSION) && !defined(PYPY_NOT_MAIN_FILE)
+#if defined(PYPY_CPYTHON_EXTENSION) && defined(PYPY_MAIN_IMPLEMENTATION_FILE)
PyObject *RPythonError;
#endif
@@ -34,7 +34,7 @@
)
void RPyDebugReturnShowException(const char *msg, const char *filename,
long lineno, const char *functionname);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void RPyDebugReturnShowException(const char *msg, const char *filename,
long lineno, const char *functionname)
{
@@ -47,7 +47,7 @@
off the prints of a debug_exc by remaking only testing_1.o */
void RPyDebugReturnShowException(const char *msg, const char *filename,
long lineno, const char *functionname);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void RPyDebugReturnShowException(const char *msg, const char *filename,
long lineno, const char *functionname)
{
@@ -76,7 +76,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc)
{
@@ -134,7 +134,7 @@
}
#endif /* !PYPY_STANDALONE */
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/instrument.h b/pypy/translator/c/src/instrument.h
--- a/pypy/translator/c/src/instrument.h
+++ b/pypy/translator/c/src/instrument.h
@@ -5,7 +5,7 @@
void instrument_count(long);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -70,7 +70,7 @@
#else
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void instrument_setup() {
}
#endif
diff --git a/pypy/translator/c/src/int.h b/pypy/translator/c/src/int.h
--- a/pypy/translator/c/src/int.h
+++ b/pypy/translator/c/src/int.h
@@ -229,7 +229,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
long long op_llong_mul_ovf(long long a, long long b)
{
@@ -266,7 +266,7 @@
}
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
/* implementations */
diff --git a/pypy/translator/c/src/ll_strtod.h b/pypy/translator/c/src/ll_strtod.h
--- a/pypy/translator/c/src/ll_strtod.h
+++ b/pypy/translator/c/src/ll_strtod.h
@@ -18,7 +18,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
double LL_strtod_parts_to_float(
char *sign,
@@ -139,5 +139,5 @@
return buffer;
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
#endif
diff --git a/pypy/translator/c/src/main.h b/pypy/translator/c/src/main.h
--- a/pypy/translator/c/src/main.h
+++ b/pypy/translator/c/src/main.h
@@ -13,7 +13,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#ifndef PYPY_MAIN_FUNCTION
#define PYPY_MAIN_FUNCTION main
@@ -83,4 +83,4 @@
return pypy_main_function(argc, argv);
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -197,7 +197,7 @@
#define OP_GC__ENABLE_FINALIZERS(r) (boehm_gc_finalizer_lock--, \
boehm_gc_finalizer_notifier())
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
int boehm_gc_finalizer_lock = 0;
void boehm_gc_finalizer_notifier(void)
{
@@ -225,7 +225,7 @@
GC_finalize_on_demand = 1;
GC_set_warn_proc(mem_boehm_ignore);
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
#endif /* USING_BOEHM_GC */
diff --git a/pypy/translator/c/src/pyobj.h b/pypy/translator/c/src/pyobj.h
--- a/pypy/translator/c/src/pyobj.h
+++ b/pypy/translator/c/src/pyobj.h
@@ -221,7 +221,7 @@
unsigned long long RPyLong_AsUnsignedLongLong(PyObject *v);
long long RPyLong_AsLongLong(PyObject *v);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#if (PY_VERSION_HEX < 0x02040000)
diff --git a/pypy/translator/c/src/rtyper.h b/pypy/translator/c/src/rtyper.h
--- a/pypy/translator/c/src/rtyper.h
+++ b/pypy/translator/c/src/rtyper.h
@@ -21,7 +21,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
struct _RPyString_dump_t {
struct _RPyString_dump_t *next;
@@ -59,4 +59,4 @@
return rps;
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/signals.h b/pypy/translator/c/src/signals.h
--- a/pypy/translator/c/src/signals.h
+++ b/pypy/translator/c/src/signals.h
@@ -64,7 +64,7 @@
export a function with the correct name for testing */
#undef pypysig_getaddr_occurred
void *pypysig_getaddr_occurred(void);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void *pypysig_getaddr_occurred(void) { return (void *)(&pypysig_counter); }
#endif
#define pypysig_getaddr_occurred() ((void *)(&pypysig_counter))
@@ -72,7 +72,7 @@
/************************************************************/
/* Implementation */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
struct pypysig_long_struct pypysig_counter = {0};
static char volatile pypysig_flags[NSIG] = {0};
@@ -183,6 +183,6 @@
return old_fd;
}
-#endif /* !PYPY_NOT_MAIN_FILE */
+#endif /* !PYPY_MAIN_IMPLEMENTATION_FILE */
#endif
diff --git a/pypy/translator/c/src/stack.h b/pypy/translator/c/src/stack.h
--- a/pypy/translator/c/src/stack.h
+++ b/pypy/translator/c/src/stack.h
@@ -35,7 +35,7 @@
#endif
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
#include <stdio.h>
/* the current stack is in the interval [end-length:end]. We assume a
diff --git a/pypy/translator/c/src/support.h b/pypy/translator/c/src/support.h
--- a/pypy/translator/c/src/support.h
+++ b/pypy/translator/c/src/support.h
@@ -53,7 +53,7 @@
void RPyAssertFailed(const char* filename, long lineno,
const char* function, const char *msg);
-# ifndef PYPY_NOT_MAIN_FILE
+# ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void RPyAssertFailed(const char* filename, long lineno,
const char* function, const char *msg) {
fprintf(stderr,
@@ -89,7 +89,7 @@
((RPyCHECK((array) && (index) >= 0), (array))[index])
void RPyAbort(void);
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
void RPyAbort(void) {
fprintf(stderr, "Invalid RPython operation (NULL ptr or bad array index)\n");
abort();
@@ -133,7 +133,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
/* we need a subclass of 'builtin_function_or_method' which can be used
as methods: builtin function objects that can be bound on instances */
@@ -516,4 +516,4 @@
#endif /* PYPY_STANDALONE */
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/thread_nt.h b/pypy/translator/c/src/thread_nt.h
--- a/pypy/translator/c/src/thread_nt.h
+++ b/pypy/translator/c/src/thread_nt.h
@@ -43,7 +43,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
static long _pypythread_stacksize = 0;
@@ -275,4 +275,4 @@
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/c/src/thread_pthread.h b/pypy/translator/c/src/thread_pthread.h
--- a/pypy/translator/c/src/thread_pthread.h
+++ b/pypy/translator/c/src/thread_pthread.h
@@ -105,7 +105,7 @@
/* implementations */
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
/* The POSIX spec requires that use of pthread_attr_setstacksize
be conditional on _POSIX_THREAD_ATTR_STACKSIZE being defined. */
@@ -579,4 +579,4 @@
}
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
diff --git a/pypy/translator/tool/cbuild.py b/pypy/translator/tool/cbuild.py
--- a/pypy/translator/tool/cbuild.py
+++ b/pypy/translator/tool/cbuild.py
@@ -247,8 +247,11 @@
if not filename.check():
break
f = filename.open("w")
- if being_main:
- f.write("#define PYPY_NOT_MAIN_FILE\n")
+ if not being_main:
+ # This eci is being built independently from a larger
+ # target, so it has to include a copy of the C RPython
+ # helper functions when needed.
+ f.write("#define PYPY_MAIN_IMPLEMENTATION_FILE\n")
self.write_c_header(f)
source = str(source)
f.write(source)
More information about the pypy-commit
mailing list