[commit: ghc] master: Fix #12998 by removing CTimer (513eb6a)

git at git.haskell.org git at git.haskell.org
Sun Dec 18 15:52:18 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/513eb6a0638a1c64b9d76bcab39ed80cdd9dbb27/ghc

>---------------------------------------------------------------

commit 513eb6a0638a1c64b9d76bcab39ed80cdd9dbb27
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sun Dec 18 10:41:48 2016 -0500

    Fix #12998 by removing CTimer
    
    Summary:
    CTimer is a wrapper around `timer_t`, which is a typedef for `void*`
    on most platforms. The issue is that GHC's `FPTOOLS_CHECK_HTYPE` is not robust
    enough to discern pointer types from non-pointer types, so it mistakenly labels
    `timer_t` as a `Double` or `Int32` (depending on how many bits a pointer takes
    up on your platform). This wreaks havoc when trying to give it certain type
    class instances, as noted in
    https://phabricator.haskell.org/rGHCffc2327070dbb664bdb407a804121eacb2a7c734.
    
    For now, the simplest thing to do would be removing `CTimer`, since:
    
    1. The original author (@DanielG) didn't have a particular use in mind for
       `timer_t` when he fixed #12795.
    2. `CTimer` hasn't appeared in a release of `base` yet.
    
    Fixes #12998.
    
    Reviewers: austin, hvr, bgamari, DanielG, trofi
    
    Reviewed By: bgamari, trofi
    
    Subscribers: thomie, DanielG, erikd
    
    Differential Revision: https://phabricator.haskell.org/D2876
    
    GHC Trac Issues: #12795, #12998


>---------------------------------------------------------------

513eb6a0638a1c64b9d76bcab39ed80cdd9dbb27
 libraries/base/System/Posix/Types.hs | 17 +++++++----------
 libraries/base/changelog.md          |  2 +-
 libraries/base/configure.ac          |  1 -
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/libraries/base/System/Posix/Types.hs b/libraries/base/System/Posix/Types.hs
index 0e9e2ae..da4fc60 100644
--- a/libraries/base/System/Posix/Types.hs
+++ b/libraries/base/System/Posix/Types.hs
@@ -92,9 +92,13 @@ module System.Posix.Types (
 #if defined(HTYPE_KEY_T)
   CKey(..),
 #endif
-#if defined(HTYPE_TIMER_T)
-  CTimer(..),
-#endif
+-- We can't support CTimer (timer_t) yet, as FPTOOLS_CHECK_HTYPE doesn't have
+-- the ability to discern pointer types (like void*, which timer_t usually is)
+-- from non-pointer types. See GHC Trac #12998.
+--
+-- #if defined(HTYPE_TIMER_T)
+--   CTimer(..),
+-- #endif
 
   Fd(..),
 
@@ -132,9 +136,6 @@ import GHC.Base
 import GHC.Enum
 import GHC.Num
 import GHC.Real
-#if defined(HTYPE_TIMER_T)
-import GHC.Float
-#endif
 -- import GHC.Prim
 import GHC.Read
 import GHC.Show
@@ -212,10 +213,6 @@ INTEGRAL_TYPE_WITH_CTYPE(CId,id_t,HTYPE_ID_T)
 -- | @since 4.10.0.0
 INTEGRAL_TYPE_WITH_CTYPE(CKey,key_t,HTYPE_KEY_T)
 #endif
-#if defined(HTYPE_TIMER_T)
--- | @since 4.10.0.0
-FLOATING_TYPE_WITH_CTYPE(CTimer,timer_t,HTYPE_TIMER_T)
-#endif
 
 -- Make an Fd type rather than using CInt everywhere
 INTEGRAL_TYPE(Fd,CInt)
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index d2e738b..e0cd384 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -31,7 +31,7 @@
   * Added `Eq1`, `Ord1`, `Read1` and `Show1` instances for `NonEmpty`.
 
   * 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)
+    `fsfilcnt_t`, `id_t`, and `key_t` to System.Posix.Types (#12795)
 
   * Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696)
 
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index e6c8a9b..c99c284 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -155,7 +155,6 @@ FPTOOLS_CHECK_HTYPE(fsblkcnt_t)
 FPTOOLS_CHECK_HTYPE(fsfilcnt_t)
 FPTOOLS_CHECK_HTYPE(id_t)
 FPTOOLS_CHECK_HTYPE(key_t)
-FPTOOLS_CHECK_HTYPE(timer_t)
 
 FPTOOLS_CHECK_HTYPE(intptr_t)
 FPTOOLS_CHECK_HTYPE(uintptr_t)



More information about the ghc-commits mailing list