summaryrefslogtreecommitdiff
path: root/libraries/base/include
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-01-15 11:53:34 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2017-01-15 11:53:34 -0500
commitdb91d17edfbe7deecb62bbb89c804249f9c4a4bd (patch)
tree7c01e3256c19a009625f96bc5e977ac5b673cd4c /libraries/base/include
parent331f88d0d878eae926b3c1c61a3ff344916b62ed (diff)
downloadhaskell-db91d17edfbe7deecb62bbb89c804249f9c4a4bd.tar.gz
Properly introduce CTimer to System.Posix.Types
Summary: In ffc2327070dbb664bdb407a804121eacb2a7c734, an attempt was made at adding a Haskell wrapper around the C `timer_t` type. Unfortunately, GHC's autoconf macros weren't sophisticated enough at the time to properly detect that `timer_t` is represented by a `void *` (i.e., a pointer) on most OSes. This is a second attempt at `CTimer`, this time using `AC_COMPILE_IFELSE` to detect if a type is a pointer type by compiling the following program: ``` type val; *val; ``` This also only derives a small subset of class instances for `CTimer` that are known to be compatible with `Ptr` using a new `OPAQUE_TYPE_WITH_CTYPE` macro. Test Plan: ./validate Reviewers: erikd, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2952 GHC Trac Issues: #12795, #12998
Diffstat (limited to 'libraries/base/include')
-rw-r--r--libraries/base/include/CTypes.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libraries/base/include/CTypes.h b/libraries/base/include/CTypes.h
index 9fa1e4a1c1..e9d19a8401 100644
--- a/libraries/base/include/CTypes.h
+++ b/libraries/base/include/CTypes.h
@@ -19,6 +19,7 @@
#define ARITHMETIC_CLASSES Eq,Ord,Num,Enum,Storable,Real
#define INTEGRAL_CLASSES Bounded,Integral,Bits,FiniteBits
#define FLOATING_CLASSES Fractional,Floating,RealFrac,RealFloat
+#define OPAQUE_CLASSES Eq,Ord,Storable
#define ARITHMETIC_TYPE(T,B) \
newtype T = T B deriving (ARITHMETIC_CLASSES) \
@@ -42,4 +43,9 @@ newtype {-# CTYPE "THE_CTYPE" #-} T = T B \
deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \
deriving newtype (Read, Show);
+#define OPAQUE_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
+newtype {-# CTYPE "THE_CTYPE" #-} T = T (B) \
+ deriving (OPAQUE_CLASSES) \
+ deriving newtype Show;
+
#endif