Resource: Fix warning in case of no RLIM_SAVED_{CUR,MAX}
authorBen Gamari <ben@smart-cactus.org>
Wed, 1 Aug 2018 18:45:57 +0000 (14:45 -0400)
committerHerbert Valerio Riedel <hvr@gnu.org>
Wed, 1 Aug 2018 18:55:47 +0000 (20:55 +0200)
This previously failed to build with a warning on FreeBSD 11.2

System/Posix/Resource.hsc

index 309d394..0511a0c 100644 (file)
@@ -111,12 +111,18 @@ unpackRLimit other
 
 packRLimit :: ResourceLimit -> Bool -> CRLim
 packRLimit ResourceLimitInfinity _     = (#const RLIM_INFINITY)
-#ifdef RLIM_SAVED_CUR
+#if defined(RLIM_SAVED_CUR)
 packRLimit ResourceLimitUnknown  True  = (#const RLIM_SAVED_CUR)
 #endif
-#ifdef RLIM_SAVED_MAX
+#if defined(RLIM_SAVED_MAX)
 packRLimit ResourceLimitUnknown  False = (#const RLIM_SAVED_MAX)
 #endif
+#if ! defined(RLIM_SAVED_MAX) && !defined(RLIM_SAVED_CUR)
+packRLimit ResourceLimitUnknown  _     =
+    error
+      $ "System.Posix.Resource.packRLimit: " ++
+        "ResourceLimitUnknown but RLIM_SAVED_MAX/RLIM_SAVED_CUR not defined by platform"
+#endif
 packRLimit (ResourceLimit other) _     = fromIntegral other