summaryrefslogtreecommitdiff
path: root/rts/linker/M32Alloc.h
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2016-05-24 19:26:56 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2016-05-25 07:32:09 +1000
commitfe8a4e5d77ef8b2bdb2e7e87d50eb477c94bce43 (patch)
tree36b0c877bce4ecc04beb8dccc60f1209c1692dc1 /rts/linker/M32Alloc.h
parent95dfdceb8b4dcc54a366949577d9ee389bad5bc3 (diff)
downloadhaskell-fe8a4e5d77ef8b2bdb2e7e87d50eb477c94bce43.tar.gz
Runtime linker: Break m32 allocator out into its own file
This makes the code a little more modular and allows the removal of some CPP hackery. By providing dummy implementations of of the `m32_*` functions (which simply call `errorBelch`) it means that the call sites for these functions are syntax checked even when `RTS_LINKER_USE_MMAP` is `0`. Also changes some size parameter types from `unsigned int` to `size_t`. Test Plan: Validate on Linux, OS X and Windows Reviewers: Phyx, hsyl20, bgamari, simonmar, austin Reviewed By: simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2237
Diffstat (limited to 'rts/linker/M32Alloc.h')
-rw-r--r--rts/linker/M32Alloc.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/rts/linker/M32Alloc.h b/rts/linker/M32Alloc.h
new file mode 100644
index 0000000000..3d53a26bb3
--- /dev/null
+++ b/rts/linker/M32Alloc.h
@@ -0,0 +1,47 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2000-2012
+ *
+ * RTS Object Linker
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef RTS_LINKER_M32ALLOC
+#define RTS_LINKER_M32ALLOC
+
+#if RTS_LINKER_USE_MMAP
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#endif
+
+/* MAP_ANONYMOUS is MAP_ANON on some systems, e.g. OS X, OpenBSD etc */
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+#include "BeginPrivate.h"
+
+#if RTS_LINKER_USE_MMAP
+#define M32_NO_RETURN /* Nothing */
+#else
+#define M32_NO_RETURN GNUC3_ATTRIBUTE(__noreturn__)
+#endif
+
+void m32_allocator_init(void) M32_NO_RETURN;
+
+void m32_allocator_flush(void) M32_NO_RETURN;
+
+void m32_free(void *addr, size_t size) M32_NO_RETURN;
+
+void * m32_alloc(size_t size, size_t alignment) M32_NO_RETURN;
+
+void * mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset);
+
+#include "EndPrivate.h"
+
+#endif