[commit: ghc] master: rts/Linker.c: Improve ugly C pre-processor hack (da60e3e)

git at git.haskell.org git at git.haskell.org
Sun Jun 26 18:51:31 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/da60e3e94ea3e737609444615f61649121782a1a/ghc

>---------------------------------------------------------------

commit da60e3e94ea3e737609444615f61649121782a1a
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Mon Jun 27 04:54:47 2016 +1000

    rts/Linker.c: Improve ugly C pre-processor hack
    
    Test Plan: Build on x86_64/linux, x86_64/darwin and powerpc/linux
    
    Reviewers: Phyx, bgamari, simonmar, austin
    
    Reviewed By: Phyx
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2364


>---------------------------------------------------------------

da60e3e94ea3e737609444615f61649121782a1a
 rts/Linker.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index dd36425..af87713 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -327,11 +327,16 @@ static void *lookupSymbolInDLLs ( unsigned char *lbl );
 #ifndef x86_64_HOST_ARCH
  static void zapTrailingAtSign   ( unsigned char *sym );
 #endif
+
+#if defined(x86_64_HOST_ARCH)
+#define ONLY_USED_x86_64_HOST_ARCH(x) (x)
+#else
+#define ONLY_USED_x86_64_HOST_ARCH(x) (x) GNUC3_ATTRIBUTE(__unused__)
+#endif
+
 static char *allocateImageAndTrampolines (
    pathchar* arch_name, char* member_name,
-#if defined(x86_64_HOST_ARCH)
    FILE* f,
-#endif
    int size,
    int isThin);
 #if defined(x86_64_HOST_ARCH)
@@ -2121,11 +2126,8 @@ static HsInt loadArchive_ (pathchar *path)
 #if defined(mingw32_HOST_OS)
             // TODO: We would like to use allocateExec here, but allocateExec
             //       cannot currently allocate blocks large enough.
-            image = allocateImageAndTrampolines(path, fileName,
-#if defined(x86_64_HOST_ARCH)
-               f,
-#endif
-               memberSize, isThin);
+            image = allocateImageAndTrampolines(path, fileName, f, memberSize,
+                                                isThin);
 #elif defined(darwin_HOST_OS)
             if (RTS_LINKER_USE_MMAP)
                 image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0);
@@ -2354,11 +2356,8 @@ preloadObjectFile (pathchar *path)
 
         // TODO: We would like to use allocateExec here, but allocateExec
         //       cannot currently allocate blocks large enough.
-    image = allocateImageAndTrampolines(path, "itself",
-#if defined(x86_64_HOST_ARCH)
-       f,
-#endif
-       fileSize, HS_BOOL_FALSE);
+    image = allocateImageAndTrampolines(path, "itself", f, fileSize,
+                                        HS_BOOL_FALSE);
     if (image == NULL) {
         fclose(f);
         return NULL;
@@ -3074,11 +3073,9 @@ static int verifyCOFFHeader ( COFF_header *hdr, pathchar *filename);
 static char *
 allocateImageAndTrampolines (
    pathchar* arch_name, char* member_name,
-#if defined(x86_64_HOST_ARCH)
-   FILE* f,
-#endif
+   FILE* ONLY_USED_x86_64_HOST_ARCH (f),
    int size,
-   int isThin)
+   int  ONLY_USED_x86_64_HOST_ARCH (isThin))
 {
    char* image;
 #if defined(x86_64_HOST_ARCH)



More information about the ghc-commits mailing list