diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index 1b24c7429..581b0b64e 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -146,7 +146,27 @@ pub fn add( .target = target, .optimize = optimize, }); - c.defineCMacro("ZIG_TARGET", @tagName(target.result.os.tag)); + inline for (@typeInfo(std.Target.Os.Tag).@"enum".fields) |field| { + c.defineCMacro( + b.fmt( + "ZIG_TARGET_{s}", + .{try std.ascii.allocUpperString(b.allocator, field.name)}, + ), + b.fmt("{d}", .{field.value}), + ); + } + c.defineCMacro( + "ZIG_TARGET", + b.fmt( + "ZIG_TARGET_{s}", + .{ + try std.ascii.allocUpperString( + b.allocator, + @tagName(target.result.os.tag), + ), + }, + ), + ); switch (target.result.os.tag) { .macos => { const libc = try std.zig.LibCInstallation.findNative(.{ diff --git a/src/pty.c b/src/pty.c index f4f25ad5e..4708d0b4e 100644 --- a/src/pty.c +++ b/src/pty.c @@ -1,11 +1,11 @@ -#if ZIG_TARGET == freebsd +#if ZIG_TARGET == ZIG_TARGET_FREEBSD #include // ioctl and constants #include // openpty #include // ptsname_r #include // tcgetpgrp #endif -#if ZIG_TARGET == linux +#if ZIG_TARGET == ZIG_TARGET_LINUX #define _GNU_SOURCE // ptsname_r #include // openpty #include // ptsname_r @@ -13,7 +13,7 @@ #include // tcgetpgrp, setsid #endif -#if ZIG_TARGET == macos +#if ZIG_TARGET == ZIG_TARGET_MACOS #include // ioctl and constants #include // ioctl and constants for TIOCPTYGNAME #include