130130 ```
131131 """
132132 @inline function ftell (fp:: Ptr{FILE} )
133+ @assert Int=== Int64
133134 if fp == C_NULL
134135 Int64 (- 1 )
135136 else
196197 ```
197198 """
198199 @inline function fseek (fp:: Ptr{FILE} , offset:: Int64 , whence:: Int32 = SEEK_CUR)
200+ @assert Int=== Int64
199201 if fp == C_NULL || whence < 0 || whence > 2
200202 Int32 (- 1 )
201203 else
250252 """
251253@static if Sys. isbsd ()
252254 @inline function stdoutp ()
255+ @assert Int=== Int64
253256 Base. llvmcall (("""
254257 @__stdoutp = external global i8*
255258
265268 end
266269else
267270 @inline function stdoutp ()
271+ @assert Int=== Int64
268272 Base. llvmcall (("""
269273 @stdout = external global i8*
270274
301305 """
302306@static if Sys. isbsd ()
303307 @inline function stderrp ()
308+ @assert Int=== Int64
304309 Base. llvmcall (("""
305310 @__stderrp = external global i8*
306311
316321 end
317322else
318323 @inline function stderrp ()
324+ @assert Int=== Int64
319325 Base. llvmcall (("""
320326 @stderr = external global i8*
321327
348354 """
349355@static if Sys. isbsd ()
350356 @inline function stdinp ()
357+ @assert Int=== Int64
351358 Base. llvmcall (("""
352359 @__stdinp = external global i8*
353360
363370 end
364371else
365372 @inline function stdinp ()
373+ @assert Int=== Int64
366374 Base. llvmcall (("""
367375 @stdin = external global i8*
368376
410418 @inline function putchar (c:: UInt8 )
411419 Base. llvmcall (("""
412420 ; External declaration of the putchar function
413- declare i32 @putchar(i8 nocapture ) nounwind
421+ declare i32 @putchar(i8) nounwind
414422
415423 define i32 @main(i8 %c) #0 {
416424 entry:
@@ -423,22 +431,23 @@ end
423431 end
424432 @inline putchar (fp:: Ptr{FILE} , c:: Char ) = putchar (fp, UInt8 (c))
425433 @inline function putchar (fp:: Ptr{FILE} , c:: UInt8 )
434+ @assert Int=== Int64
426435 if fp == C_NULL
427436 Int32 (- 1 )
428437 else
429438 Base. llvmcall (("""
430439 ; External declaration of the fputc function
431- declare i32 @fputc(i8 , i8*) nounwind
440+ declare i32 @fputc(i32 , i8*) nounwind
432441
433- define i32 @main(i64 %jlfp, i8 %c) #0 {
442+ define i32 @main(i64 %jlfp, i32 %c) #0 {
434443 entry:
435444 %fp = inttoptr i64 %jlfp to i8*
436- %status = call i32 (i8 , i8*) @fputc(i8 %c, i8* %fp)
445+ %status = call i32 (i32 , i8*) @fputc(i32 %c, i8* %fp)
437446 ret i32 0
438447 }
439448
440449 attributes #0 = { alwaysinline nounwind ssp uwtable }
441- """ , " main" ), Int32, Tuple{Ptr{FILE}, UInt8 }, fp, c)
450+ """ , " main" ), Int32, Tuple{Ptr{FILE}, Int32 }, fp, c % Int32 )
442451 end
443452 end
444453
517526 ```
518527 """
519528 @inline function getc (fp:: Ptr{FILE} )
529+ @assert Int=== Int64
520530 if fp == C_NULL
521531 Int32 (- 1 )
522532 else
564574 @inline puts (s:: AbstractMallocdMemory ) = puts (pointer (s))
565575 @inline puts (s) = GC. @preserve s puts (pointer (s))
566576 @inline function puts (s:: Ptr{UInt8} )
577+ @assert Int=== Int64
567578 Base. llvmcall (("""
568579 ; External declaration of the puts function
569580 declare i32 @puts(i8* nocapture) nounwind
582593 @inline puts (fp:: Ptr{FILE} , s:: AbstractMallocdMemory ) = puts (fp, pointer (s))
583594 @inline puts (fp:: Ptr{FILE} , s) = GC. @preserve s puts (fp, pointer (s))
584595 @inline function puts (fp:: Ptr{FILE} , s:: Ptr{UInt8} )
596+ @assert Int=== Int64
585597 if fp == C_NULL
586598 Int32 (- 1 )
587599 else
630642 ```
631643 """
632644 @inline function gets! (s:: MallocString , fp:: Ptr{FILE} , n:: Integer = length (s))
645+ @assert Int=== Int64
633646 Base. llvmcall (("""
634647 ; External declaration of the gets function
635648 declare i8* @fgets(i8*, i32, i8*)
740753 @inline fread! (buffer:: AbstractMallocdMemory , fp:: Ptr{FILE} , size, n) = (fread! (Ptr {UInt8} (pointer (buffer)), fp, size, n); buffer)
741754 @inline fread! (buffer, fp:: Ptr{FILE} , size, n) = (GC. @preserve buffer fread! (Ptr {UInt8} (pointer (buffer)), fp, size, n); buffer)
742755 @inline function fread! (bp:: Ptr{UInt8} , fp:: Ptr{FILE} , size:: Int64 , n:: Int64 )
756+ @assert Int=== Int64
743757 Base. llvmcall (("""
744758 ; External declaration of the fread function
745759 declare i64 @fread(i8*, i64, i64, i8*)
806820 @inline fwrite (fp:: Ptr{FILE} , data:: AbstractMallocdMemory , size:: Int64 , n:: Int64 ) = fwrite (fp, Ptr {UInt8} (pointer (data)), size, n)
807821 @inline fwrite (fp:: Ptr{FILE} , data, size:: Int64 , n:: Int64 ) = GC. @preserve data fwrite (fp, Ptr {UInt8} (pointer (data)), size, n)
808822 @inline function fwrite (fp:: Ptr{FILE} , dp:: Ptr{UInt8} , size:: Int64 , n:: Int64 )
823+ @assert Int=== Int64
809824 Base. llvmcall (("""
810825 ; External declaration of the fwrite function
811826 declare i64 @fwrite(i8*, i64, i64, i8*)
@@ -909,21 +924,23 @@ end
909924 @inline printf (fp:: Ptr{FILE} , s:: MallocString ) = printf (fp, pointer (s))
910925 @inline printf (fp:: Ptr{FILE} , s) = GC. @preserve s printf (fp, pointer (s))
911926 @inline function printf (s:: Ptr{UInt8} )
927+ @assert Int=== Int64
912928 Base. llvmcall (("""
913929 ; External declaration of the printf function
914- declare i32 @printf(i8* noalias nocapture)
930+ declare i32 @printf(i8* noalias nocapture, ... )
915931
916932 define i32 @main(i64 %jls) #0 {
917933 entry:
918934 %str = inttoptr i64 %jls to i8*
919- %status = call i32 (i8*) @printf(i8* %str)
935+ %status = call i32 (i8*, ... ) @printf(i8* %str)
920936 ret i32 %status
921937 }
922938
923939 attributes #0 = { alwaysinline nounwind ssp uwtable }
924940 """ , " main" ), Int32, Tuple{Ptr{UInt8}}, s)
925941 end
926942 @inline function printf (fp:: Ptr{FILE} , s:: Ptr{UInt8} )
943+ @assert Int=== Int64
927944 Base. llvmcall (("""
928945 ; External declaration of the fprintf function
929946 declare i32 @fprintf(i8* noalias nocapture, i8*)
959976 @inline printf (fp:: Ptr{FILE} , fmt:: MallocString , s:: MallocString ) = printf (fp:: Ptr{FILE} , pointer (fmt), pointer (s))
960977 @inline printf (fp:: Ptr{FILE} , fmt, s) = GC. @preserve fmt s printf (fp:: Ptr{FILE} , pointer (fmt), pointer (s))
961978 @inline function printf (fmt:: Ptr{UInt8} , s:: Ptr{UInt8} )
979+ @assert Int=== Int64
962980 Base. llvmcall (("""
963981 ; External declaration of the printf function
964982 declare i32 @printf(i8* noalias nocapture, ...)
975993 """ , " main" ), Int32, Tuple{Ptr{UInt8}, Ptr{UInt8}}, fmt, s)
976994 end
977995 @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , s:: Ptr{UInt8} )
996+ @assert Int=== Int64
978997 Base. llvmcall (("""
979998 ; External declaration of the fprintf function
980999 declare i32 @fprintf(i8* noalias nocapture, i8*, i8*)
@@ -1000,6 +1019,7 @@ end
10001019
10011020 # Floating point numbers
10021021 @inline function printf (fmt:: Ptr{UInt8} , n:: Float64 )
1022+ @assert Int=== Int64
10031023 Base. llvmcall (("""
10041024 ; External declaration of the printf function
10051025 declare i32 @printf(i8* noalias nocapture, ...)
@@ -1015,6 +1035,7 @@ end
10151035 """ , " main" ), Int32, Tuple{Ptr{UInt8}, Float64}, fmt, n)
10161036 end
10171037 @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: Float64 )
1038+ @assert Int=== Int64
10181039 Base. llvmcall (("""
10191040 ; External declaration of the printf function
10201041 declare i32 @fprintf(i8* noalias nocapture, i8*, double)
@@ -1037,6 +1058,7 @@ end
10371058
10381059 # Integers
10391060 @inline function printf (fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int64, UInt64, Ptr}
1061+ @assert Int=== Int64
10401062 Base. llvmcall (("""
10411063 ; External declaration of the printf function
10421064 declare i32 @printf(i8* noalias nocapture, ...)
@@ -1052,6 +1074,7 @@ end
10521074 """ , " main" ), Int32, Tuple{Ptr{UInt8}, T}, fmt, n)
10531075 end
10541076 @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int64, UInt64, Ptr}
1077+ @assert Int=== Int64
10551078 Base. llvmcall (("""
10561079 ; External declaration of the printf function
10571080 declare i32 @fprintf(i8* noalias nocapture, i8*, i64)
@@ -1069,6 +1092,7 @@ end
10691092 end
10701093
10711094 @inline function printf (fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int32, UInt32}
1095+ @assert Int=== Int64
10721096 Base. llvmcall (("""
10731097 ; External declaration of the printf function
10741098 declare i32 @printf(i8* noalias nocapture, ...)
@@ -1084,6 +1108,7 @@ end
10841108 """ , " main" ), Int32, Tuple{Ptr{UInt8}, T}, fmt, n)
10851109 end
10861110 @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int32, UInt32}
1111+ @assert Int=== Int64
10871112 Base. llvmcall (("""
10881113 ; External declaration of the printf function
10891114 declare i32 @fprintf(i8* noalias nocapture, i8*, i32)
@@ -1100,39 +1125,11 @@ end
11001125 """ , " main" ), Int32, Tuple{Ptr{FILE}, Ptr{UInt8}, T}, fp, fmt, n)
11011126 end
11021127
1103- @inline function printf (fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int16, UInt16}
1104- Base. llvmcall (("""
1105- ; External declaration of the printf function
1106- declare i32 @printf(i8* noalias nocapture, ...)
1107-
1108- define i32 @main(i64 %jlf, i16 %n) #0 {
1109- entry:
1110- %fmt = inttoptr i64 %jlf to i8*
1111- %status = call i32 (i8*, ...) @printf(i8* %fmt, i16 %n)
1112- ret i32 0
1113- }
1114-
1115- attributes #0 = { alwaysinline nounwind ssp uwtable }
1116- """ , " main" ), Int32, Tuple{Ptr{UInt8}, T}, fmt, n)
1117- end
1118- @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int16, UInt16}
1119- Base. llvmcall (("""
1120- ; External declaration of the printf function
1121- declare i32 @fprintf(i8* noalias nocapture, i8*, i16)
1122-
1123- define i32 @main(i64 %jlfp, i64 %jlf, i16 %n) #0 {
1124- entry:
1125- %fp = inttoptr i64 %jlfp to i8*
1126- %fmt = inttoptr i64 %jlf to i8*
1127- %status = call i32 (i8*, i8*, i16) @fprintf(i8* %fp, i8* %fmt, i16 %n)
1128- ret i32 %status
1129- }
1130-
1131- attributes #0 = { alwaysinline nounwind ssp uwtable }
1132- """ , " main" ), Int32, Tuple{Ptr{FILE}, Ptr{UInt8}, T}, fp, fmt, n)
1133- end
1128+ @inline printf (fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int16, UInt16} = printf (fmt, n % Int32)
1129+ @inline printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int16, UInt16} = printf (fp, fmt, n % Int32)
11341130
11351131 @inline function printf (fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int8, UInt8}
1132+ @assert Int=== Int64
11361133 Base. llvmcall (("""
11371134 ; External declaration of the printf function
11381135 declare i32 @printf(i8* noalias nocapture, ...)
@@ -1148,6 +1145,7 @@ end
11481145 """ , " main" ), Int32, Tuple{Ptr{UInt8}, T}, fmt, n)
11491146 end
11501147 @inline function printf (fp:: Ptr{FILE} , fmt:: Ptr{UInt8} , n:: T ) where T <: Union{Int8, UInt8}
1148+ @assert Int=== Int64
11511149 Base. llvmcall (("""
11521150 ; External declaration of the printf function
11531151 declare i32 @fprintf(i8* noalias nocapture, i8*, i8)
0 commit comments