authorgravatar for leclercq.thibault@yahoo.frTibboddiT <leclercq.thibault@yahoo.fr> 2025-08-08 03:26:00+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-08-08 01:26:00+00:00
log2cf15bee0325321e9da496580b55310d4ba1053f
tree779ab45acc9c03071bc03cc4d1b77ea92447c97f
parent242102f9d113fff321559c8645e79a29f0bdf70d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Fix some libc version checks for Bionic


2 files changed, 6 insertions(+), 6 deletions(-)

lib/std/fs/File.zig+1-1
...@@ -1940,7 +1940,7 @@ pub const Writer = struct {...@@ -1940,7 +1940,7 @@ pub const Writer = struct {
19401940
1941 const copy_file_range = switch (native_os) {1941 const copy_file_range = switch (native_os) {
1942 .freebsd => std.os.freebsd.copy_file_range,1942 .freebsd => std.os.freebsd.copy_file_range,
1943 .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else {},1943 .linux => if (std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else {},
1944 else => {},1944 else => {},
1945 };1945 };
1946 if (@TypeOf(copy_file_range) != void) cfr: {1946 if (@TypeOf(copy_file_range) != void) cfr: {
lib/std/posix.zig+5-5
...@@ -375,7 +375,7 @@ pub inline fn fchmodat(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32)...@@ -375,7 +375,7 @@ pub inline fn fchmodat(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32)
375 // No special handling for linux is needed if we can use the libc fallback375 // No special handling for linux is needed if we can use the libc fallback
376 // or `flags` is empty. Glibc only added the fallback in 2.32.376 // or `flags` is empty. Glibc only added the fallback in 2.32.
377 const skip_fchmodat_fallback = native_os != .linux or377 const skip_fchmodat_fallback = native_os != .linux or
378 std.c.versionCheck(.{ .major = 2, .minor = 32, .patch = 0 }) or378 (!builtin.abi.isAndroid() and std.c.versionCheck(.{ .major = 2, .minor = 32, .patch = 0 })) or
379 flags == 0;379 flags == 0;
380380
381 // This function is marked inline so that when flags is comptime-known,381 // This function is marked inline so that when flags is comptime-known,
...@@ -628,7 +628,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {...@@ -628,7 +628,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
628 if (@TypeOf(system.getrandom) != void) {628 if (@TypeOf(system.getrandom) != void) {
629 var buf = buffer;629 var buf = buffer;
630 const use_c = native_os != .linux or630 const use_c = native_os != .linux or
631 std.c.versionCheck(std.SemanticVersion{ .major = 2, .minor = 25, .patch = 0 });631 std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 28, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 25, .patch = 0 });
632632
633 while (buf.len != 0) {633 while (buf.len != 0) {
634 const num_read: usize, const err = if (use_c) res: {634 const num_read: usize, const err = if (use_c) res: {
...@@ -6390,7 +6390,7 @@ pub const CopyFileRangeError = error{...@@ -6390,7 +6390,7 @@ pub const CopyFileRangeError = error{
6390/// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`.6390/// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`.
6391pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize {6391pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize {
6392 if (builtin.os.tag == .freebsd or6392 if (builtin.os.tag == .freebsd or
6393 (comptime builtin.os.tag == .linux and std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })))6393 (comptime builtin.os.tag == .linux and std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 34, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 })))
6394 {6394 {
6395 var off_in_copy: i64 = @bitCast(off_in);6395 var off_in_copy: i64 = @bitCast(off_in);
6396 var off_out_copy: i64 = @bitCast(off_out);6396 var off_out_copy: i64 = @bitCast(off_out);
...@@ -6699,8 +6699,8 @@ pub const MemFdCreateError = error{...@@ -6699,8 +6699,8 @@ pub const MemFdCreateError = error{
6699pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {6699pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {
6700 switch (native_os) {6700 switch (native_os) {
6701 .linux => {6701 .linux => {
6702 // memfd_create is available only in glibc versions starting with 2.27.6702 // memfd_create is available only in glibc versions starting with 2.27 and bionic versions starting with 30.
6703 const use_c = std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 });6703 const use_c = std.c.versionCheck(if (builtin.abi.isAndroid()) .{ .major = 30, .minor = 0, .patch = 0 } else .{ .major = 2, .minor = 27, .patch = 0 });
6704 const sys = if (use_c) std.c else linux;6704 const sys = if (use_c) std.c else linux;
6705 const rc = sys.memfd_create(name, flags);6705 const rc = sys.memfd_create(name, flags);
6706 switch (errno(rc)) {6706 switch (errno(rc)) {