long-double 0.1 → 0.1.1
raw patch · 4 files changed
+101/−5 lines, 4 filesdep +float128dep ~basedep ~integer-gmpPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: float128
Dependency ranges changed: base, integer-gmp
API changes (from Hackage documentation)
- Numeric.LongDouble: LD :: !Word64 -> !Word64 -> LongDouble
Files
- ChangeLog.md +4/−0
- aarch64/Numeric/LongDouble.hs +17/−0
- hs/Numeric/LongDouble/ARM_128.hs +67/−0
- long-double.cabal +13/−5
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for long-double +## 0.1.1 -- 2020-06-15++* Add support for aarch64 where long double == _Float128.+ ## 0.1 -- 2018-03-09 * First release.
+ aarch64/Numeric/LongDouble.hs view
@@ -0,0 +1,17 @@+-----------------------------------------------------------------------------+-- |+-- Module : Numeric.LongDouble+-- Copyright : (C) 2018,2020 Claude Heiland-Allen+-- License : BSD3+-- Maintainer : Claude Heiland-Allen <claude@mathr.co.uk>+-- Stability : experimental+-- Portability : non-portable +--+-- This module re-exports the default platform-specfic ABI for C's long double.+module Numeric.LongDouble ( module Numeric.LongDouble.ARM_128 ) where++import Numeric.LongDouble.ARM_128+ ( LongDouble()+ , truncate', round', ceiling', floor'+ , fromDouble, toDouble, fromInt, toInt+ )
+ hs/Numeric/LongDouble/ARM_128.hs view
@@ -0,0 +1,67 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+-----------------------------------------------------------------------------+-- |+-- Module : Numeric.LongDouble.ARM_128+-- Copyright : (C) 2020 Claude Heiland-Allen+-- License : BSD3+-- Maintainer : Claude Heiland-Allen <claude@mathr.co.uk>+-- Stability : experimental+-- Portability : non-portable (assumes long double == _Float128)+--+-- This module contains a LongDouble type that is the same as Float128, as on aarch64.+--+-- Most code should import Numeric.LongDouble instead, unless a specific ABI+-- is needed. This module is for sizeof(long double) == 16, with the type being+-- a simple alias for _Float128.+module Numeric.LongDouble.ARM_128+ ( + -- * long double data type+ LongDouble(..)+ -- * RealFrac alternatives+ , truncate'+ , round'+ , ceiling'+ , floor'+ -- * Conversions+ , fromDouble+ , toDouble+ , fromInt+ , toInt+ ) where++import Data.Coerce (coerce)+import Foreign (Ptr, with, alloca)+import qualified Numeric.Float128 as F+import Foreign.Storable (Storable(..))+import Numeric (showFloat, readFloat, readSigned)+import System.IO.Unsafe (unsafePerformIO)++-- | The long double type on aarch64: 128 bits of _Float128 in 128bits of space.+newtype LongDouble = LD F.Float128+ deriving (Storable, Eq, Ord, Num, Real, Fractional, RealFrac, Floating, RealFloat)++instance Read LongDouble where+ readsPrec p = coerce . (readsPrec p :: ReadS F.Float128)++instance Show LongDouble where+ showsPrec p (LD x) = showsPrec p x++fromInt :: Int -> LongDouble+fromInt = LD . F.fromInt++toInt :: LongDouble -> Int+toInt (LD f) = F.toInt f++fromDouble :: Double -> LongDouble+fromDouble = LD . F.fromDouble++toDouble :: LongDouble -> Double+toDouble (LD f) = F.toDouble f++-- | Alternate versions of RealFrac methods that+-- keep the value as a long double.+truncate', round', ceiling', floor' :: LongDouble -> LongDouble+truncate' = coerce F.truncate'+round' = coerce F.round'+ceiling' = coerce F.ceiling'+floor' = coerce F.floor'
long-double.cabal view
@@ -1,9 +1,10 @@ name: long-double-version: 0.1+version: 0.1.1 synopsis: FFI bindings for C long double description: This package provides a LongDouble type, being 80bits of x87 data taking up 96bits on i386 and 128bits on x86_64. On arm it is an alias for 64bit double.+ On aarch64 it is an alias for quadruple precision _Float128. It does not provide a CLDouble type usable for FFI without wrapping in Ptr, this needs to be done by the compiler. See <https://ghc.haskell.org/trac/ghc/ticket/3353>.@@ -13,15 +14,17 @@ license-file: LICENSE author: Claude Heiland-Allen maintainer: claude@mathr.co.uk-copyright: (c) 2018 Claude Heiland-Allen+copyright: (c) 2018,2020 Claude Heiland-Allen category: Math build-type: Simple extra-source-files: ChangeLog.md i386/Numeric/LongDouble.hs x86_64/Numeric/LongDouble.hs+ aarch64/Numeric/LongDouble.hs arm/Numeric/LongDouble.hs hs/Numeric/LongDouble/ARM_64.hs+ hs/Numeric/LongDouble/ARM_128.hs hs/Numeric/LongDouble/X87.hs hs/Numeric/LongDouble/X87_96.hs hs/Numeric/LongDouble/X87_128.hs@@ -35,13 +38,13 @@ source-repository this type: git location: https://code.mathr.co.uk/long-double.git- tag: long-double-0.1+ tag: long-double-0.1.1 library exposed-modules: Numeric.LongDouble build-depends:- base >=4.6 && <4.12,+ base >=4.6 && <4.15, integer-gmp >=0.5 && <1.1 c-sources: c/longdouble.c hs-source-dirs: hs@@ -57,7 +60,12 @@ hs-source-dirs: arm other-modules: Numeric.LongDouble.ARM_64 else- buildable: False+ if arch(aarch64)+ hs-source-dirs: aarch64+ other-modules: Numeric.LongDouble.ARM_128+ build-depends: float128 >=0.1 && <0.2+ else+ buildable: False default-language: Haskell2010 other-extensions: CPP,