makes raylib and stb_rect_pack free of libc

This commit is contained in:
Laytan Laats
2024-02-29 23:33:25 +01:00
parent 3263e54144
commit 6734a7096a
4 changed files with 35 additions and 12 deletions
+19 -3
View File
@@ -1,6 +1,5 @@
package raylib
import c "core:c/libc"
import "core:math"
import "core:math/linalg"
@@ -45,7 +44,7 @@ Wrap :: proc "c" (value: f32, min, max: f32) -> f32 {
// Check whether two given floats are almost equal
@(require_results)
FloatEquals :: proc "c" (x, y: f32) -> bool {
return abs(x - y) <= EPSILON*c.fmaxf(1.0, c.fmaxf(abs(x), abs(y)))
return abs(x - y) <= EPSILON*fmaxf(1.0, fmaxf(abs(x), abs(y)))
}
@@ -815,4 +814,21 @@ QuaternionEquals :: proc "c" (p, q: Quaternion) -> bool {
FloatEquals(p.y, q.y) &&
FloatEquals(p.z, q.z) &&
FloatEquals(p.w, q.w)
}
}
@(private, require_results)
fmaxf :: proc "contextless" (x, y: f32) -> f32 {
if math.is_nan(x) {
return y
}
if math.is_nan(y) {
return x
}
if math.signbit(x) != math.signbit(y) {
return y if math.signbit(x) else x
}
return y if x < y else x
}