mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
std.Target: Add a function for determining char signedess
Copied from arocc c1955a4742/src/target.zig (L7)
This commit is contained in:
parent
a72d634b73
commit
657fe55711
@ -1910,6 +1910,30 @@ pub const Target = struct {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default signedness of `char` for the native C compiler for this target
|
||||
/// Note that char signedness is implementation-defined and many compilers provide
|
||||
/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
|
||||
pub fn charSignedness(target: Target) std.builtin.Signedness {
|
||||
switch (target.cpu.arch) {
|
||||
.aarch64,
|
||||
.aarch64_32,
|
||||
.aarch64_be,
|
||||
.arm,
|
||||
.armeb,
|
||||
.thumb,
|
||||
.thumbeb,
|
||||
=> return if (target.os.tag.isDarwin() or target.os.tag == .windows) .signed else .unsigned,
|
||||
.powerpc, .powerpc64 => return if (target.os.tag.isDarwin()) .signed else .unsigned,
|
||||
.powerpc64le,
|
||||
.s390x,
|
||||
.xcore,
|
||||
.arc,
|
||||
.msp430,
|
||||
=> return .unsigned,
|
||||
else => return .signed,
|
||||
}
|
||||
}
|
||||
|
||||
pub const CType = enum {
|
||||
char,
|
||||
short,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user