Functions
fn cast(comptime DestType: type, target: anytype) DestType
Given a type and value, cast the value to the type as c would.
fn promoteIntLiteral(comptime SuffixType: type, comptime number: comptime_int, comptime base: CIntLiteralBase) PromoteIntLiteralReturnType(SuffixType, number, base)
Promote the type of an integer literal until it fits as C would.
fn shuffleVectorIndex(comptime this_index: c_int, comptime source_vector_len: usize) i32
Convert from clang __builtin_shufflevector index to Zig @shuffle index clang re…
Convert from clang __builtin_shufflevector index to Zig @shuffle index clang requires __builtin_shufflevector index arguments to be integer constants. negative values for
this_index
indicate “don’t care” so we arbitrarily choose 0 clang enforces thatthis_index
is less than the total number of vector elements See https://ziglang.org/documentation/master/#shuffle See https://clang.llvm.org/docs/LanguageExtensions.html#langext-builtin-shufflevectorfn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator)
C
%
operator for signed integers C standard states: “If the quotient a/b is r…C
%
operator for signed integers C standard states: “If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a” The quotient is not representable if denominator is zero, or if numerator is the minimum integer for the type and denominator is -1. C has undefined behavior for those two cases; this function has safety checked undefined behavior