summaryrefslogtreecommitdiff
path: root/includes/Stg.h
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2016-03-08 08:14:08 +0000
committerSergei Trofimovich <siarheit@google.com>2016-03-08 08:14:27 +0000
commit90e1e160b783644c2d3cc0a05e3a804cea549cf9 (patch)
treec150978c9ee9efbe0b3e19da9e21d1a7c10e7154 /includes/Stg.h
parent82e36edcbd831e9b7c05e1c2cb918ad5de56cd3a (diff)
downloadhaskell-90e1e160b783644c2d3cc0a05e3a804cea549cf9.tar.gz
Split external symbol prototypes (EF_) (Trac #11395)
Before the patch both Cmm and C symbols were declared with 'EF_' macro: #define EF_(f) extern StgFunPtr f() but for Cmm symbols we know exact prototypes. The patch splits there prototypes in to: #define EFF_(f) void f() /* See Note [External function prototypes] */ #define EF_(f) StgFunPtr f(void) Cmm functions are 'EF_' (External Functions), C functions are 'EFF_' (External Foreign Functions). While at it changed external C function prototype to return 'void' to workaround ghc bug on m68k. Described in detail in Trac #11395. This makes simple tests work on m68k-linux target! Thanks to Michael Karcher for awesome analysis happening in Trac #11395. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: ran "hello world" on m68k successfully Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1975 GHC Trac Issues: #11395
Diffstat (limited to 'includes/Stg.h')
-rw-r--r--includes/Stg.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/includes/Stg.h b/includes/Stg.h
index 899e685635..a8ab5ca8e8 100644
--- a/includes/Stg.h
+++ b/includes/Stg.h
@@ -222,11 +222,21 @@ typedef StgFunPtr F_;
#define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
#define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void)
#define FN_(f) StgFunPtr f(void)
-#define EF_(f) extern StgFunPtr f() /* See Note [External function prototypes] */
+#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
+#define EFF_(f) void f() /* See Note [External function prototypes] */
-/* Note [External function prototypes] See Trac #8965
+/* Note [External function prototypes] See Trac #8965, #11395
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The external-function macro EF_(F) used to be defined as
+In generated C code we need to distinct between two types
+of external symbols:
+1. Cmm functions declared by 'EF_' macro (External Functions)
+2. C functions declared by 'EFF_' macro (External Foreign Functions)
+
+Cmm functions are simple as they are internal to GHC.
+
+C functions are trickier:
+
+The external-function macro EFF_(F) used to be defined as
extern StgFunPtr f(void)
i.e a function of zero arguments. On most platforms this doesn't
matter very much: calls to these functions put the parameters in the
@@ -249,6 +259,10 @@ unspecified argument list rather than a void argument list. This is no
worse for platforms that don't care either way, and allows a successful
bootstrap of GHC 7.8 on little-endian Linux ppc64 (which uses the ELFv2
ABI).
+
+Another case is m68k ABI where 'void*' return type is returned by 'a0'
+register while 'long' return type is returned by 'd0'. Thus we trick
+external prototype return neither of these types to workaround #11395.
*/