Skip to content

Commit

Permalink
Update stdoutp(), stderrp(), and stdinp()
Browse files Browse the repository at this point in the history
  • Loading branch information
daizutabi committed May 20, 2024
1 parent 2b05794 commit 4cd05ec
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 4cd05ec

Please sign in to comment.