From 55f0d8b41cc0c633effe51554f1bc67793f62623 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 16 Sep 2023 11:02:19 -0700 Subject: [PATCH] std: correct getcontext for Android bionic libc I have updated Felix's ZigAndroidTemplate to work with the latest version of Zig and we are exploring adding Android support to Mach engine. `std.c.getcontext` is _referenced_ but not _used_, and Android's bionic libc does not implement `getcontext`. `std.os.linux.getcontext` also cannot be used with bionic libc, so it seems prudent to just disable this extern for now. This may not be the perfect long-term fix, but I have a golden rebuttal to that: before I was unable to compile Zig applications for Android, and now I can. image Signed-off-by: Stephen Gutekanst --- lib/std/c.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index 66875eadd0..bbfbc51633 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -408,7 +408,11 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; pub extern "c" fn if_nametoindex([*:0]const u8) c_int; -pub usingnamespace if (builtin.os.tag == .linux and builtin.target.isMusl()) struct { +pub usingnamespace if (builtin.target.isAndroid()) struct { + // android bionic libc does not implement getcontext, + // and std.os.linux.getcontext also cannot be built for + // bionic libc currently. +} else if (builtin.os.tag == .linux and builtin.target.isMusl()) struct { // musl does not implement getcontext pub const getcontext = std.os.linux.getcontext; } else struct {