[commit: ghc] master: Add CBool to Foreign.C.Types (0d769d5)
git at git.haskell.org
git at git.haskell.org
Wed Jan 18 22:40:12 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/0d769d5b96232ee0fe5a44f2ce5717bdb0e7eaa3/ghc
>---------------------------------------------------------------
commit 0d769d5b96232ee0fe5a44f2ce5717bdb0e7eaa3
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Wed Jan 18 16:24:17 2017 -0500
Add CBool to Foreign.C.Types
This adds a `CBool` type wrapping C99's `bool`, i.e., an `unsigned
char`.
Fixes #13136.
Test Plan: ./validate on Tier-1 platforms
Reviewers: austin, hvr, simonmar, bgamari
Reviewed By: simonmar, bgamari
Subscribers: thomie, erikd
Differential Revision: https://phabricator.haskell.org/D2982
GHC Trac Issues: #13136
>---------------------------------------------------------------
0d769d5b96232ee0fe5a44f2ce5717bdb0e7eaa3
libraries/base/Foreign/C/Types.hs | 8 +++++++-
libraries/base/aclocal.m4 | 1 +
libraries/base/changelog.md | 3 +++
libraries/base/configure.ac | 1 +
4 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/libraries/base/Foreign/C/Types.hs b/libraries/base/Foreign/C/Types.hs
index f76ff1c..b2e723f 100644
--- a/libraries/base/Foreign/C/Types.hs
+++ b/libraries/base/Foreign/C/Types.hs
@@ -44,7 +44,7 @@ module Foreign.C.Types
, CShort(..), CUShort(..), CInt(..), CUInt(..)
, CLong(..), CULong(..)
, CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..)
- , CLLong(..), CULLong(..)
+ , CLLong(..), CULLong(..), CBool(..)
, CIntPtr(..), CUIntPtr(..), CIntMax(..), CUIntMax(..)
-- ** Numeric types
@@ -126,6 +126,11 @@ INTEGRAL_TYPE(CLLong,HTYPE_LONG_LONG)
-- | Haskell type representing the C @unsigned long long@ type.
INTEGRAL_TYPE(CULLong,HTYPE_UNSIGNED_LONG_LONG)
+-- | Haskell type representing the C @bool@ type.
+--
+-- @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CBool,bool,HTYPE_BOOL)
+
{-# RULES
"fromIntegral/a->CChar" fromIntegral = \x -> CChar (fromIntegral x)
"fromIntegral/a->CSChar" fromIntegral = \x -> CSChar (fromIntegral x)
@@ -150,6 +155,7 @@ INTEGRAL_TYPE(CULLong,HTYPE_UNSIGNED_LONG_LONG)
"fromIntegral/CULong->a" fromIntegral = \(CULong x) -> fromIntegral x
"fromIntegral/CLLong->a" fromIntegral = \(CLLong x) -> fromIntegral x
"fromIntegral/CULLong->a" fromIntegral = \(CULLong x) -> fromIntegral x
+"fromIntegral/CBool->a" fromIntegral = \(CBool x) -> fromIntegral x
#-}
-- | Haskell type representing the C @float@ type.
diff --git a/libraries/base/aclocal.m4 b/libraries/base/aclocal.m4
index 17b8bca..ece0c6f 100644
--- a/libraries/base/aclocal.m4
+++ b/libraries/base/aclocal.m4
@@ -54,6 +54,7 @@ done
dnl FPTOOLS_HTYPE_INCLUDES
AC_DEFUN([FPTOOLS_HTYPE_INCLUDES],
[
+#include <stdbool.h>
#include <stdio.h>
#include <stddef.h>
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index d687e07..f1a93ee 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -33,6 +33,9 @@
* Add wrappers for `blksize_t`, `blkcnt_t`, `clockid_t`, `fsblkcnt_t`,
`fsfilcnt_t`, `id_t`, `key_t`, and `timer_t` to System.Posix.Types (#12795)
+ * Add `CBool`, a wrapper around C's `bool` type, to `Foreign.C.Types`
+ (#13136)
+
* Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696)
* Add `plusForeignPtr` to `Foreign.ForeignPtr`.
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index e6c8a9b..f6816e7 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -118,6 +118,7 @@ if test "$ac_cv_type_long_long" = yes; then
FPTOOLS_CHECK_HTYPE(long long)
FPTOOLS_CHECK_HTYPE(unsigned long long)
fi
+FPTOOLS_CHECK_HTYPE(bool)
FPTOOLS_CHECK_HTYPE(float)
FPTOOLS_CHECK_HTYPE(double)
FPTOOLS_CHECK_HTYPE(ptrdiff_t)
More information about the ghc-commits
mailing list