Source
pub const pthread_mutex_t = switch (native_os) {
.linux => extern struct {
data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len,
const data_len = switch (native_abi) {
.musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24,
.gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) {
.aarch64 => 48,
.x86_64 => if (native_abi == .gnux32) 32 else 40,
.mips64, .powerpc64, .powerpc64le, .sparc64 => 40,
else => if (@sizeOf(usize) == 8) 40 else 24,
},
.android, .androideabi => if (@sizeOf(usize) == 8) 40 else 4,
else => @compileError("unsupported ABI"),
};
},
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
sig: c_long = 0x32AAABA7,
data: [data_len]u8 = [_]u8{0} ** data_len,
const data_len = if (@sizeOf(usize) == 8) 56 else 40;
},
.freebsd, .dragonfly, .openbsd => extern struct {
inner: ?*anyopaque = null,
},
.hermit => extern struct {
ptr: usize = maxInt(usize),
},
.netbsd => extern struct {
magic: u32 = 0x33330003,
errorcheck: padded_pthread_spin_t = 0,
ceiling: padded_pthread_spin_t = 0,
owner: usize = 0,
waiters: ?*u8 = null,
recursed: u32 = 0,
spare2: ?*anyopaque = null,
},
.haiku => extern struct {
flags: u32 = 0,
lock: i32 = 0,
unused: i32 = -42,
owner: i32 = -1,
owner_count: i32 = 0,
},
.solaris, .illumos => extern struct {
flag1: u16 = 0,
flag2: u8 = 0,
ceiling: u8 = 0,
type: u16 = 0,
magic: u16 = 0x4d58,
lock: u64 = 0,
data: u64 = 0,
},
.fuchsia => extern struct {
data: [40]u8 align(@alignOf(usize)) = [_]u8{0} ** 40,
},
.emscripten => extern struct {
data: [24]u8 align(4) = [_]u8{0} ** 24,
},
// https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L68-L73
.serenity => extern struct {
lock: u32 = 0,
owner: pthread_t = 0,
level: c_int = 0,
type: c_int = 0,
},
else => void,
}