#include "Rts.h"
#include "Hash.h"
+#if RTS_LINKER_USE_MMAP
+#include <sys/mman.h>
+#endif
+
#include "BeginPrivate.h"
typedef void SymbolAddr;
#define USE_CONTIGUOUS_MMAP 0
#endif
-#include "EndPrivate.h"
-
HsInt isAlreadyLoaded( pathchar *path );
HsInt loadOc( ObjectCode* oc );
ObjectCode* mkOc( pathchar *path, char *image, int imageSize,
- rtsBool mapped, char *archiveMemberName,
+ bool mapped, char *archiveMemberName,
int misalignment
);
-#ifdef darwin_HOST_OS
-int machoGetMisalignment( FILE * f );
-#endif /* darwin_HOST_OS */
-
#if defined (mingw32_HOST_OS)
/* We use myindex to calculate array addresses, rather than
simply doing the normal subscript thing. That's because
arising from using normal C indexing or pointer arithmetic
are just plain wrong. Sigh.
*/
-STATIC_INLINE unsigned char *
+INLINE_HEADER unsigned char *
myindex ( int scale, void* base, int index )
{
return
unsigned char* strtab);
#endif /* mingw32_HOST_OS */
+/* MAP_ANONYMOUS is MAP_ANON on some systems,
+ e.g. OS X (before Sierra), OpenBSD etc */
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
/* Which object file format are we targetting? */
#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
# define OBJFORMAT_ELF
# define OBJFORMAT_MACHO
#endif
+/* In order to simplify control flow a bit, some references to mmap-related
+ definitions are blocked off by a C-level if statement rather than a CPP-level
+ #if statement. Since those are dead branches when !RTS_LINKER_USE_MMAP, we
+ just stub out the relevant symbols here
+*/
+#if !RTS_LINKER_USE_MMAP
+#define munmap(x,y) /* nothing */
+#define MAP_ANONYMOUS 0
+#endif
+
+#include "EndPrivate.h"
#endif /* LINKERINTERNALS_H */