From d1431cc06597b38d876a518e7769f04dcd2c0f32 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 13 Dec 2022 10:55:41 +0000 Subject: base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 --- libraries/base/System/Posix/Internals.hs | 11 +++++++++++ libraries/base/configure.ac | 1 + 2 files changed, 12 insertions(+) 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 ]) -- cgit v1.2.1