summaryrefslogtreecommitdiff
path: root/libraries/base/aclocal.m4
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/aclocal.m4
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/aclocal.m4')
-rw-r--r--libraries/base/aclocal.m453
1 files changed, 35 insertions, 18 deletions
diff --git a/libraries/base/aclocal.m4 b/libraries/base/aclocal.m4
index 50d8168ec0..17b8bca9ce 100644
--- a/libraries/base/aclocal.m4
+++ b/libraries/base/aclocal.m4
@@ -131,26 +131,43 @@ AC_DEFUN([FPTOOLS_CHECK_HTYPE_ELSE],[
if test "$HTYPE_IS_INTEGRAL" -eq 0
then
- FP_COMPUTE_INT([HTYPE_IS_FLOAT],[sizeof($1) == sizeof(float)],
- [FPTOOLS_HTYPE_INCLUDES],
- [AC_CV_NAME_supported=no])
- FP_COMPUTE_INT([HTYPE_IS_DOUBLE],[sizeof($1) == sizeof(double)],
- [FPTOOLS_HTYPE_INCLUDES],
- [AC_CV_NAME_supported=no])
- FP_COMPUTE_INT([HTYPE_IS_LDOUBLE],[sizeof($1) == sizeof(long double)],
- [FPTOOLS_HTYPE_INCLUDES],
- [AC_CV_NAME_supported=no])
- if test "$HTYPE_IS_FLOAT" -eq 1
- then
- AC_CV_NAME=Float
- elif test "$HTYPE_IS_DOUBLE" -eq 1
- then
- AC_CV_NAME=Double
- elif test "$HTYPE_IS_LDOUBLE" -eq 1
+ dnl If the C type isn't an integer, we check if it's a pointer type
+ dnl by trying to dereference one of its values. If that fails to
+ dnl compile, it's not a pointer, so we check to see if it's a
+ dnl floating-point type.
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [FPTOOLS_HTYPE_INCLUDES],
+ [$1 val; *val;]
+ )],
+ [HTYPE_IS_POINTER=yes],
+ [HTYPE_IS_POINTER=no])
+
+ if test "$HTYPE_IS_POINTER" = yes
then
- AC_CV_NAME=LDouble
+ AC_CV_NAME="Ptr ()"
else
- AC_CV_NAME_supported=no
+ FP_COMPUTE_INT([HTYPE_IS_FLOAT],[sizeof($1) == sizeof(float)],
+ [FPTOOLS_HTYPE_INCLUDES],
+ [AC_CV_NAME_supported=no])
+ FP_COMPUTE_INT([HTYPE_IS_DOUBLE],[sizeof($1) == sizeof(double)],
+ [FPTOOLS_HTYPE_INCLUDES],
+ [AC_CV_NAME_supported=no])
+ FP_COMPUTE_INT([HTYPE_IS_LDOUBLE],[sizeof($1) == sizeof(long double)],
+ [FPTOOLS_HTYPE_INCLUDES],
+ [AC_CV_NAME_supported=no])
+ if test "$HTYPE_IS_FLOAT" -eq 1
+ then
+ AC_CV_NAME=Float
+ elif test "$HTYPE_IS_DOUBLE" -eq 1
+ then
+ AC_CV_NAME=Double
+ elif test "$HTYPE_IS_LDOUBLE" -eq 1
+ then
+ AC_CV_NAME=LDouble
+ else
+ AC_CV_NAME_supported=no
+ fi
fi
else
FP_COMPUTE_INT([HTYPE_IS_SIGNED],[(($1)(-1)) < (($1)0)],