From 4cd05ecc3100ce3dabbafb8a99394af14e692562 Mon Sep 17 00:00:00 2001 From: Daizu Date: Mon, 20 May 2024 18:59:54 +0900 Subject: [PATCH] Update `stdoutp()`, `stderrp()`, and `stdinp()` --- src/llvmio.jl | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/llvmio.jl b/src/llvmio.jl index dd48162..dfb45a8 100644 --- a/src/llvmio.jl +++ b/src/llvmio.jl @@ -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 @@ -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 @@ -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