summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2015-11-03 17:10:12 +1100
committerErik de Castro Lopo <erikd@mega-nerd.com>2015-11-04 16:40:26 +1100
commit10647d4e2e8e3b5eb5486bd6aafbe17cda139577 (patch)
treeda9d5c53d5a6417522d48c63452feec498be1478 /rts/Linker.c
parente5479541599eec6237e3a3d784290d76fe01e5bc (diff)
downloadhaskell-10647d4e2e8e3b5eb5486bd6aafbe17cda139577.tar.gz
Linker: #ifdef cleanup
Test Plan: - Run tests on x86_64/linux and powerpc/linux - Cross compile rts/Linker.c with the i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc Linux to Windows cross-compilers. Reviewers: bgamari, austin, hvr, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1429
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 2308275747..fb7653960b 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -161,10 +161,8 @@ typedef void (*init_t) (int argc, char **argv, char **env);
static HsInt isAlreadyLoaded( pathchar *path );
static HsInt loadOc( ObjectCode* oc );
static ObjectCode* mkOc( pathchar *path, char *image, int imageSize,
- rtsBool mapped, char *archiveMemberName
-#if (USE_MMAP == 0) && defined (darwin_HOST_OS)
- , int misalignment
-#endif
+ rtsBool mapped, char *archiveMemberName,
+ int misalignment
);
// Use wchar_t for pathnames on Windows (#5697)
@@ -1475,11 +1473,7 @@ void freeObjectCode (ObjectCode *oc)
static ObjectCode*
mkOc( pathchar *path, char *image, int imageSize,
- rtsBool mapped, char *archiveMemberName
-#if (USE_MMAP == 0) && defined (darwin_HOST_OS)
- , int misalignment
-#endif
- ) {
+ rtsBool mapped, char *archiveMemberName, int misalignment ) {
ObjectCode* oc;
IF_DEBUG(linker, debugBelch("mkOc: start\n"));
@@ -1518,9 +1512,7 @@ mkOc( pathchar *path, char *image, int imageSize,
#endif
oc->imageMapped = mapped;
-#if (USE_MMAP == 0) && defined (darwin_HOST_OS)
- oc->misalignment = misalignment;
-#endif
+ oc->misalignment = misalignment;
/* chain it onto the list of objects */
oc->next = NULL;
@@ -1578,10 +1570,8 @@ static HsInt loadArchive_ (pathchar *path)
#else
#error Unknown Darwin architecture
#endif
-#if (USE_MMAP == 0)
- int misalignment;
-#endif
#endif
+ int misalignment = 0;
/* TODO: don't call barf() on error, instead return an error code, freeing
* all resources correctly. This function is pretty complex, so it needs
@@ -1929,10 +1919,7 @@ static HsInt loadArchive_ (pathchar *path)
path, (int)thisFileNameSize, fileName);
oc = mkOc(path, image, memberSize, rtsFalse, archiveMemberName
-#if (USE_MMAP == 0) && defined(darwin_HOST_OS)
- , misalignment
-#endif
- );
+ , misalignment);
stgFree(archiveMemberName);
@@ -2030,9 +2017,7 @@ preloadObjectFile (pathchar *path)
int r;
void *image;
ObjectCode *oc;
-#if (USE_MMAP == 0) && defined(darwin_HOST_OS)
- int misalignment;
-#endif
+ int misalignment = 0;
r = pathstat(path, &st);
if (r == -1) {
@@ -2120,11 +2105,7 @@ preloadObjectFile (pathchar *path)
#endif /* USE_MMAP */
- oc = mkOc(path, image, fileSize, rtsTrue, NULL
-#if (USE_MMAP == 0) && defined(darwin_HOST_OS)
- , misalignment
-#endif
- );
+ oc = mkOc(path, image, fileSize, rtsTrue, NULL, misalignment);
return oc;
}
@@ -2466,12 +2447,6 @@ addSection (Section *s, SectionKind kind, SectionAlloc alloc,
static int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first )
{
StgWord n;
-#if (USE_MMAP == 0)
- int misalignment = 0;
-#ifdef darwin_HOST_OS
- int aligned;
-#endif
-#endif
#if USE_MMAP
if (USE_CONTIGUOUS_MMAP)
@@ -2510,9 +2485,9 @@ static int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first )
if (oc->symbol_extras == NULL) return 0;
#else
// round up to the nearest 4
- aligned = (oc->fileSize + 3) & ~3;
+ int aligned = (oc->fileSize + 3) & ~3;
- misalignment = oc->misalignment;
+ int misalignment = oc->misalignment;
oc->image -= misalignment;
oc->image = stgReallocBytes( oc->image,
@@ -2696,11 +2671,7 @@ static void
ocFlushInstructionCache( ObjectCode *oc )
{
/* The main object code */
- ocFlushInstructionCacheFrom(oc->image
-#ifdef darwin_HOST_OS
- + oc->misalignment
-#endif
- , oc->fileSize);
+ ocFlushInstructionCacheFrom(oc->image + oc->misalignment, oc->fileSize);
/* Jump Islands */
ocFlushInstructionCacheFrom(oc->symbol_extras, sizeof(SymbolExtra) * oc->n_symbol_extras);