mirror of
https://github.com/ziglang/zig.git
synced 2025-12-07 06:43:07 +00:00
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.
* stage2: fix cleanup bug when creating Module
* flatten lib/std/special/* to lib/*
- this was motivated by making main_pkg_is_inside_std false for
compiler_rt & friends.
* rename "mini libc" to "universal libc"
36 lines
794 B
Zig
36 lines
794 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
|
|
// neg - negate (the number)
|
|
// - negXi2 for unoptimized little and big endian
|
|
|
|
// sfffffff = 2^31-1
|
|
// two's complement inverting bits and add 1 would result in -INT_MIN == 0
|
|
// => -INT_MIN = -2^31 forbidden
|
|
|
|
// * size optimized builds
|
|
// * machines that dont support carry operations
|
|
|
|
inline fn negXi2(comptime T: type, a: T) T {
|
|
@setRuntimeSafety(builtin.is_test);
|
|
return -a;
|
|
}
|
|
|
|
pub fn __negsi2(a: i32) callconv(.C) i32 {
|
|
return negXi2(i32, a);
|
|
}
|
|
|
|
pub fn __negdi2(a: i64) callconv(.C) i64 {
|
|
return negXi2(i64, a);
|
|
}
|
|
|
|
pub fn __negti2(a: i128) callconv(.C) i128 {
|
|
return negXi2(i128, a);
|
|
}
|
|
|
|
test {
|
|
_ = @import("negsi2_test.zig");
|
|
_ = @import("negdi2_test.zig");
|
|
_ = @import("negti2_test.zig");
|
|
}
|