Commit 0d769d5b authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari
Browse files

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
parent 181688ab
......@@ -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.
......
......@@ -54,6 +54,7 @@ done
dnl FPTOOLS_HTYPE_INCLUDES
AC_DEFUN([FPTOOLS_HTYPE_INCLUDES],
[
#include <stdbool.h>
#include <stdio.h>
#include <stddef.h>
......
......@@ -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`.
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment