|
1 | 1 | {-# LANGUAGE CApiFFI #-}
|
2 |
| -{-# LANGUAGE Safe #-} |
| 2 | +{-# LANGUAGE Trustworthy #-} |
| 3 | + |
3 | 4 | -----------------------------------------------------------------------------
|
4 | 5 | -- |
|
5 | 6 | -- Module : System.Posix.Resource
|
@@ -31,6 +32,9 @@ import Foreign.C
|
31 | 32 | import System.IO.Error ( ioeSetLocation )
|
32 | 33 | import GHC.IO.Exception ( unsupportedOperation )
|
33 | 34 | #endif
|
| 35 | +#if __GLASGOW_HASKELL__ >= 905 |
| 36 | +import GHC.Exts ( considerAccessible ) |
| 37 | +#endif |
34 | 38 |
|
35 | 39 | -- -----------------------------------------------------------------------------
|
36 | 40 | -- Resource limits
|
@@ -115,12 +119,20 @@ unpackRLimit :: CRLim -> ResourceLimit
|
115 | 119 | unpackRLimit (#const RLIM_INFINITY) = ResourceLimitInfinity
|
116 | 120 | unpackRLimit other
|
117 | 121 | #if defined(RLIM_SAVED_MAX)
|
118 |
| - | ((#const RLIM_SAVED_MAX) :: CRLim) /= (#const RLIM_INFINITY) && |
119 |
| - other == (#const RLIM_SAVED_MAX) = ResourceLimitUnknown |
| 122 | + | ((#const RLIM_SAVED_MAX) :: CRLim) /= (#const RLIM_INFINITY) |
| 123 | + , other == (#const RLIM_SAVED_MAX) |
| 124 | + = ResourceLimitUnknown |
120 | 125 | #endif
|
121 | 126 | #if defined(RLIM_SAVED_CUR)
|
122 |
| - | ((#const RLIM_SAVED_CUR) :: CRLim) /= (#const RLIM_INFINITY) && |
123 |
| - other == (#const RLIM_SAVED_CUR) = ResourceLimitUnknown |
| 127 | + | ((#const RLIM_SAVED_CUR) :: CRLim) /= (#const RLIM_INFINITY) |
| 128 | + , other == (#const RLIM_SAVED_CUR) |
| 129 | +#if __GLASGOW_HASKELL__ >= 905 |
| 130 | + , considerAccessible |
| 131 | +#endif |
| 132 | + = ResourceLimitUnknown |
| 133 | + -- (*) This pattern match is redundant if RLIM_SAVED_MAX and RLIM_SAVED_CUR |
| 134 | + -- are both defined and are equal. This redundancy is only detected by GHC |
| 135 | + -- starting from version 9.5, so we use 'considerAccessible'. |
124 | 136 | #endif
|
125 | 137 | | otherwise = ResourceLimit (fromIntegral other)
|
126 | 138 |
|
|
0 commit comments