Skip to content

Commit

Permalink
Update src/KernelAbstractions.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Byrne <[email protected]>
  • Loading branch information
charleskawczynski and simonbyrne authored Dec 22, 2020
1 parent ca79220 commit fe34241
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/KernelAbstractions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,16 @@ macro print(items...)
end
end

@generated function promote_c_argument(arg)
# > When a function with a variable-length argument list is called, the variable
# > arguments are passed using C's old ``default argument promotions.'' These say that
# > types char and short int are automatically promoted to int, and type float is
# > automatically promoted to double. Therefore, varargs functions will never receive
# > arguments of type char, short int, or float.

if arg == Cchar || arg == Cshort
return :(Cint(arg))
elseif arg == Cfloat
return :(Cdouble(arg))
else
return :(arg)
end
end
# When a function with a variable-length argument list is called, the variable
# arguments are passed using C's old ``default argument promotions.'' These say that
# types char and short int are automatically promoted to int, and type float is
# automatically promoted to double. Therefore, varargs functions will never receive
# arguments of type char, short int, or float.

promote_c_argument(arg) = arg
promote_c_argument(arg::Cfloat) = Cdouble(arg)
promote_c_argument(arg::Cchar) = Cint(arg)
promote_c_argument(arg::Cshort) = Cint(arg)

"""
@printf(fmt::String, args...)
Expand Down

0 comments on commit fe34241

Please sign in to comment.