summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2022-12-13 10:55:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-17 08:07:15 -0500
commitd1431cc06597b38d876a518e7769f04dcd2c0f32 (patch)
tree0138bed5b757cf1a71d3e42d42d645efd56ff42a
parent8a81d9d933089b6ed72478342a0070d7c8f82ff8 (diff)
downloadhaskell-d1431cc06597b38d876a518e7769f04dcd2c0f32.tar.gz
base: add missing autoconf checks for waitpid/umask
These are not present in wasi-libc. Required for fixing #22589
-rw-r--r--libraries/base/System/Posix/Internals.hs11
-rw-r--r--libraries/base/configure.ac1
2 files changed, 12 insertions, 0 deletions
diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs
index 6918aa29a9..44065be7c4 100644
--- a/libraries/base/System/Posix/Internals.hs
+++ b/libraries/base/System/Posix/Internals.hs
@@ -682,8 +682,13 @@ foreign import capi unsafe "HsBase.h read"
foreign import capi safe "HsBase.h read"
c_safe_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
+#if defined(HAVE_UMASK)
foreign import ccall unsafe "HsBase.h umask"
c_umask :: CMode -> IO CMode
+#else
+c_umask :: CMode -> IO CMode
+c_umask _ = ioError (ioeSetLocation unsupportedOperation "umask")
+#endif
-- See Note: Windows types
foreign import capi unsafe "HsBase.h write"
@@ -785,8 +790,14 @@ foreign import capi unsafe "HsBase.h tcsetattr"
#endif
+#if defined(HAVE_GETPID)
foreign import ccall unsafe "HsBase.h waitpid"
c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
+#else
+c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
+c_waitpid _ _ _ = ioError (ioeSetLocation unsupportedOperation "waitpid")
+#endif
+
#endif
#if !defined(js_HOST_ARCH)
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index 6a7cdd719a..a1c68577aa 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -90,6 +90,7 @@ AC_CHECK_FUNCS([fork])
AC_CHECK_FUNCS([getpid])
AC_CHECK_FUNCS([mkfifo])
AC_CHECK_FUNCS([pipe])
+AC_CHECK_FUNCS([umask])
AC_CHECK_TYPE([struct rlimit],[AC_DEFINE([HAVE_STRUCT_RLIMIT],[1],[HAVE_STRUCT_RLIMIT])],[],[#include <sys/resource.h>])