@@ -223,25 +223,31 @@ openat_ fdMay str how (OpenFileFlags appendFlag exclusiveFlag nocttyFlag
223
223
c_fd = maybe (# const AT_FDCWD ) (\ (Fd fd) -> fd) fdMay
224
224
all_flags = creat .|. flags .|. open_mode
225
225
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.
226
232
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 ) .|.
232
238
(if nofollowFlag then (# const O_NOFOLLOW ) else 0 ) .|.
233
239
(if cloexecFlag then (# const O_CLOEXEC ) else 0 ) .|.
234
240
(if directoryFlag then (# const O_DIRECTORY ) else 0 ) .|.
235
241
(if syncFlag then (# const O_SYNC ) else 0 )
236
242
237
243
(creat, mode_w) = case creatFlag of
238
244
Nothing -> (0 ,0 )
239
- Just x -> ((# const O_CREAT ), x)
245
+ Just x -> ((Base. o_CREAT ), x)
240
246
241
247
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 )
245
251
246
252
foreign import capi unsafe " HsUnix.h openat"
247
253
c_openat :: CInt -> CString -> CInt -> CMode -> IO CInt
@@ -315,8 +321,8 @@ data FdOption = AppendOnWrite -- ^O_APPEND
315
321
316
322
fdOption2Int :: FdOption -> CInt
317
323
fdOption2Int 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 )
320
326
fdOption2Int SynchronousWrites = (# const O_SYNC )
321
327
322
328
-- | May throw an exception if this is an invalid descriptor.
0 commit comments