authorgravatar for fncontroloption@noreply.codeberg.orgFnControlOption <fncontroloption@noreply.codeberg.org> 2022-03-19 10:08:17-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-03-19 19:08:17+02:00
logd62b1c932e5c5ff9cd3e14b4f3f8c078a0fb43f9
treed6c6c3a95daca833c455ae687c3f3e2b8bfc5e4d
parentad5770eba40e0cc425c7a1eab4d37c6f9788d670
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

translate-c: add missing builtins used by CRuby


2 files changed, 22 insertions(+), 0 deletions(-)

CMakeLists.txt+1
......@@ -573,6 +573,7 @@ set(ZIG_STAGE2_SOURCES
573573 "${CMAKE_SOURCE_DIR}/lib/std/zig.zig"
574574 "${CMAKE_SOURCE_DIR}/lib/std/zig/Ast.zig"
575575 "${CMAKE_SOURCE_DIR}/lib/std/zig/CrossTarget.zig"
576 "${CMAKE_SOURCE_DIR}/lib/std/zig/c_builtins.zig"
576577 "${CMAKE_SOURCE_DIR}/lib/std/zig/parse.zig"
577578 "${CMAKE_SOURCE_DIR}/lib/std/zig/render.zig"
578579 "${CMAKE_SOURCE_DIR}/lib/std/zig/string_literal.zig"
lib/std/zig/c_builtins.zig+21
......@@ -228,6 +228,27 @@ pub inline fn __builtin_isinf_sign(x: anytype) c_int {
228228 return if (std.math.isPositiveInf(x)) 1 else -1;
229229}
230230
231pub inline fn __has_builtin(func: anytype) c_int {
232 _ = func;
233 return @boolToInt(true);
234}
235
236pub inline fn __builtin_assume(cond: bool) void {
237 if (!cond) unreachable;
238}
239
240pub inline fn __builtin_unreachable() noreturn {
241 unreachable;
242}
243
244pub inline fn __builtin_constant_p(expr: anytype) c_int {
245 _ = expr;
246 return @boolToInt(false);
247}
248pub fn __builtin_mul_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) c_int {
249 return @boolToInt(@mulWithOverflow(@TypeOf(a, b), a, b, result));
250}
251
231252// __builtin_alloca_with_align is not currently implemented.
232253// It is used in a run-translated-c test and a test-translate-c test to ensure that non-implemented
233254// builtins are correctly demoted. If you implement __builtin_alloca_with_align, please update the