Skip to content

Commit

Permalink
Merge pull request #58 from daizutabi/fix-stdio-win
Browse files Browse the repository at this point in the history
Update `stdoutp()`, `stderrp()`, and `stdinp()` for Windows
  • Loading branch information
brenhinkeller committed May 20, 2024
2 parents 2b05794 + 4cd05ec commit 9fe2744
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/llvmio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
elseif Sys.iswindows()
@inline function stdoutp()
@assert Int===Int64
Base.llvmcall(("""
declare i8* @__acrt_iob_func(i32 noundef)
define i64 @main() #0 {
entry:
%ptr = call i8* @__acrt_iob_func(i32 noundef 1)
%jlfp = ptrtoint i8* %ptr to i64
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
Expand Down Expand Up @@ -316,6 +332,22 @@ end
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
elseif Sys.iswindows()
@inline function stderrp()
@assert Int===Int64
Base.llvmcall(("""
declare i8* @__acrt_iob_func(i32 noundef)
define i64 @main() #0 {
entry:
%ptr = call i8* @__acrt_iob_func(i32 noundef 2)
%jlfp = ptrtoint i8* %ptr to i64
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
Expand Down Expand Up @@ -365,6 +397,22 @@ end
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
elseif Sys.iswindows()
@inline function stdinp()
@assert Int===Int64
Base.llvmcall(("""
declare i8* @__acrt_iob_func(i32 noundef)
define i64 @main() #0 {
entry:
%ptr = call i8* @__acrt_iob_func(i32 noundef 0)
%jlfp = ptrtoint i8* %ptr to i64
ret i64 %jlfp
}
attributes #0 = { alwaysinline nounwind ssp uwtable }
""", "main"), Ptr{FILE}, Tuple{})
end
Expand Down

0 comments on commit 9fe2744

Please sign in to comment.