summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-05-09 14:53:34 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-05-09 14:53:34 +0000
commite6a38b39a74c451c65f1dec1b4522e1d1e3c5c24 (patch)
treeb162530247265f989140e0dbedcd3877ad75d12a
parente2294ec140f9cc296774722a3cb57ba883e8088e (diff)
downloadhaskell-e6a38b39a74c451c65f1dec1b4522e1d1e3c5c24.tar.gz
Avoid calling varargs functions using the FFI
Calling varargs functions is explicitly deprecated according to the FFI specification. It used to work, just about, but it broke with the recent changes to the via-C backend to not use header files.
-rw-r--r--libraries/base/Control/Exception.hs4
-rw-r--r--libraries/base/Debug/Trace.hs4
-rw-r--r--libraries/base/cbits/PrelIOUtils.c9
-rw-r--r--libraries/base/include/HsBase.h3
4 files changed, 18 insertions, 2 deletions
diff --git a/libraries/base/Control/Exception.hs b/libraries/base/Control/Exception.hs
index 3fc1139ff8..14bdef138c 100644
--- a/libraries/base/Control/Exception.hs
+++ b/libraries/base/Control/Exception.hs
@@ -581,7 +581,9 @@ uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler)
withCString msg $ \cmsg ->
errorBelch cfmt cmsg
-foreign import ccall unsafe "RtsMessages.h errorBelch"
+-- don't use errorBelch() directly, because we cannot call varargs functions
+-- using the FFI.
+foreign import ccall unsafe "HsBase.h errorBelch2"
errorBelch :: CString -> CString -> IO ()
setUncaughtExceptionHandler :: (Exception -> IO ()) -> IO ()
diff --git a/libraries/base/Debug/Trace.hs b/libraries/base/Debug/Trace.hs
index c30c8111d1..742044e4d4 100644
--- a/libraries/base/Debug/Trace.hs
+++ b/libraries/base/Debug/Trace.hs
@@ -41,7 +41,9 @@ putTraceMsg msg = do
withCString msg $ \cmsg ->
debugBelch cfmt cmsg
-foreign import ccall unsafe "RtsMessages.h debugBelch"
+-- don't use debugBelch() directly, because we cannot call varargs functions
+-- using the FFI.
+foreign import ccall unsafe "HsBase.h debugBelch2"
debugBelch :: CString -> CString -> IO ()
#endif
diff --git a/libraries/base/cbits/PrelIOUtils.c b/libraries/base/cbits/PrelIOUtils.c
index f37c4b6726..556736e86b 100644
--- a/libraries/base/cbits/PrelIOUtils.c
+++ b/libraries/base/cbits/PrelIOUtils.c
@@ -7,3 +7,12 @@
#define INLINE
#include "HsBase.h"
+void errorBelch2(const char*s, char *t)
+{
+ return errorBelch(s,t);
+}
+
+void debugBelch2(const char*s, char *t)
+{
+ return debugBelch(s,t);
+}
diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h
index 8e5676abe4..f69e9cf656 100644
--- a/libraries/base/include/HsBase.h
+++ b/libraries/base/include/HsBase.h
@@ -732,5 +732,8 @@ INLINE void * __hscore_from_intptr (intptr_t n) { return (void *)n; }
INLINE uintptr_t __hscore_to_uintptr (void *p) { return (uintptr_t)p; }
INLINE intptr_t __hscore_to_intptr (void *p) { return (intptr_t)p; }
+void errorBelch2(const char*s, char *t);
+void debugBelch2(const char*s, char *t);
+
#endif /* __HSBASE_H__ */