Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed e605968

Be positive: #define PYPY_MAIN_IMPLEMENTATION_FILE when we need the implementation
of the C helper functions.

Comments (0)

Files changed (24)

pypy/module/cpyext/src/thread.c

 #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

pypy/translator/c/genc.py

         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"'
             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"'
             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"'
     #
     # Header
     #
+    print >> f, '#define PYPY_MAIN_IMPLEMENTATION_FILE'
     print >> f, '#include "common_header.h"'
     print >> f
     commondefs(defines)

pypy/translator/c/src/allocator.h

 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); }

pypy/translator/c/src/asm_gcc_x86.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 #  if 0   /* disabled */
 void op_int_overflowed(void)

pypy/translator/c/src/asm_msvc.h

 
 /* 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)

pypy/translator/c/src/asm_ppc.h

 
 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")

pypy/translator/c/src/debug_alloc.h

 /************************************************************/
 
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 struct pypy_debug_alloc_s {
   struct pypy_debug_alloc_s *next;

pypy/translator/c/src/debug_print.c

-#define PYPY_NOT_MAIN_FILE
-
 #include <string.h>
 #include <stddef.h>
 #include <stdlib.h>

pypy/translator/c/src/debug_traceback.h

 /************************************************************/
 
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 int pypydtcount = 0;
 struct pypydtentry_s pypy_debug_tracebacks[PYPY_DEBUG_TRACEBACK_DEPTH];
   abort();
 }
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/c/src/dtoa.c

 #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

pypy/translator/c/src/exception.h

 /************************************************************/
  /***  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 
 
   )
 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)
 {
            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)
 {
 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc)
 {
 }
 #endif   /* !PYPY_STANDALONE */
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
 
 
 

pypy/translator/c/src/instrument.h

 
 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>
 
 #else
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 void instrument_setup() {
 }
 #endif

pypy/translator/c/src/int.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 long long op_llong_mul_ovf(long long a, long long b)
 {
 	}
 }
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
 
 /* implementations */
 

pypy/translator/c/src/ll_strtod.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 double LL_strtod_parts_to_float(
 	char *sign, 
 	return buffer;
 }
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */
 #endif

pypy/translator/c/src/main.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 #ifndef PYPY_MAIN_FUNCTION
 #define PYPY_MAIN_FUNCTION main
     return pypy_main_function(argc, argv);
 }
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/c/src/mem.h

 #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)
 {
 	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 */
 

pypy/translator/c/src/pyobj.h

 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)
 

pypy/translator/c/src/rtyper.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 struct _RPyString_dump_t {
 	struct _RPyString_dump_t *next;
 	return rps;
 }
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/c/src/signals.h

    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))
 /************************************************************/
 /* 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};
   return old_fd;
 }
 
-#endif  /* !PYPY_NOT_MAIN_FILE */
+#endif  /* !PYPY_MAIN_IMPLEMENTATION_FILE */
 
 #endif

pypy/translator/c/src/stack.h

 #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

pypy/translator/c/src/support.h

 
 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,
      ((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();
 
 /* 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 */
 
 #endif /* PYPY_STANDALONE */
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/c/src/thread_nt.h

 
 /* implementations */
 
-#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
 
 static long _pypythread_stacksize = 0;
 
 }
 
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/c/src/thread_pthread.h

 
 /* 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. */
 }
 
 
-#endif /* PYPY_NOT_MAIN_FILE */
+#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */

pypy/translator/tool/cbuild.py

                 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.