@@ -223,25 +223,31 @@ openat_ fdMay str how (OpenFileFlags appendFlag exclusiveFlag nocttyFlag
223223 c_fd = maybe (# const AT_FDCWD ) (\ (Fd fd) -> fd) fdMay
224224 all_flags = creat .|. flags .|. open_mode
225225
226+ -- We have to use Base.o_* instead of raw #const O_*
227+ -- due of the fact target platforms at stage1 could have
228+ -- them overridden.
229+ -- For example GHC JS Backend provides its own constants
230+ -- which should be used at the target of cross compilation
231+ -- into Node.JS environment.
226232 flags =
227- (if appendFlag then (# const O_APPEND ) else 0 ) .|.
228- (if exclusiveFlag then (# const O_EXCL ) else 0 ) .|.
229- (if nocttyFlag then (# const O_NOCTTY ) else 0 ) .|.
230- (if nonBlockFlag then (# const O_NONBLOCK ) else 0 ) .|.
231- (if truncateFlag then (# const O_TRUNC ) else 0 ) .|.
233+ (if appendFlag then (Base. o_APPEND) else 0 ) .|.
234+ (if exclusiveFlag then (Base. o_EXCL) else 0 ) .|.
235+ (if nocttyFlag then (Base. o_NOCTTY) else 0 ) .|.
236+ (if nonBlockFlag then (Base. o_NONBLOCK) else 0 ) .|.
237+ (if truncateFlag then (Base. o_TRUNC) else 0 ) .|.
232238 (if nofollowFlag then (# const O_NOFOLLOW ) else 0 ) .|.
233239 (if cloexecFlag then (# const O_CLOEXEC ) else 0 ) .|.
234240 (if directoryFlag then (# const O_DIRECTORY ) else 0 ) .|.
235241 (if syncFlag then (# const O_SYNC ) else 0 )
236242
237243 (creat, mode_w) = case creatFlag of
238244 Nothing -> (0 ,0 )
239- Just x -> ((# const O_CREAT ), x)
245+ Just x -> ((Base. o_CREAT ), x)
240246
241247 open_mode = case how of
242- ReadOnly -> (# const O_RDONLY )
243- WriteOnly -> (# const O_WRONLY )
244- ReadWrite -> (# const O_RDWR )
248+ ReadOnly -> (Base. o_RDONLY )
249+ WriteOnly -> (Base. o_WRONLY )
250+ ReadWrite -> (Base. o_RDWR )
245251
246252foreign import capi unsafe " HsUnix.h openat"
247253 c_openat :: CInt -> CString -> CInt -> CMode -> IO CInt
@@ -315,8 +321,8 @@ data FdOption = AppendOnWrite -- ^O_APPEND
315321
316322fdOption2Int :: FdOption -> CInt
317323fdOption2Int CloseOnExec = (# const FD_CLOEXEC )
318- fdOption2Int AppendOnWrite = (# const O_APPEND )
319- fdOption2Int NonBlockingRead = (# const O_NONBLOCK )
324+ fdOption2Int AppendOnWrite = (Base. o_APPEND )
325+ fdOption2Int NonBlockingRead = (Base. o_NONBLOCK )
320326fdOption2Int SynchronousWrites = (# const O_SYNC )
321327
322328-- | May throw an exception if this is an invalid descriptor.
0 commit comments