tcc windows fixes

pull/2340/head
Alexander Medvednikov 2019-10-14 09:03:11 +03:00
parent a68222b55b
commit 2d127cb694
2 changed files with 17 additions and 5 deletions

View File

@ -28,11 +28,19 @@ pub fn ptr_str(ptr voidptr) string {
// compare floats using C epsilon // compare floats using C epsilon
// == // ==
pub fn (a f64) eq(b f64) bool { pub fn (a f64) eq(b f64) bool {
$if tinyc {
return a -b <= 0.01
} $else {
return C.fabs(a - b) <= C.DBL_EPSILON return C.fabs(a - b) <= C.DBL_EPSILON
}
} }
pub fn (a f32) eq(b f32) bool { pub fn (a f32) eq(b f32) bool {
$if tinyc {
return a -b <= 0.01
} $else {
return C.fabsf(a - b) <= C.FLT_EPSILON return C.fabsf(a - b) <= C.FLT_EPSILON
} }
}
pub fn (a f64) eqbit(b f64) bool { pub fn (a f64) eqbit(b f64) bool {
return C.DEFAULT_EQUAL(a, b) return C.DEFAULT_EQUAL(a, b)
} }

View File

@ -197,15 +197,19 @@ pub fn (s string) f64() f64 {
} }
pub fn (s string) u32() u32 { pub fn (s string) u32() u32 {
return C.strtoul(*char(s.str), 0, 0) $if tinyc {
return u32(s.int()) // TODO
} $else {
return C.strtoul(*char(s.str), 0, 0)
}
} }
pub fn (s string) u64() u64 { pub fn (s string) u64() u64 {
//$if tinyc { $if tinyc {
//return u64(s.int()) // TODO return u64(s.int()) // TODO
//} $else { } $else {
return C.strtoull(*char(s.str), 0, 0) return C.strtoull(*char(s.str), 0, 0)
//} }
//return C.atoll(s.str) // temporary fix for tcc on windows. //return C.atoll(s.str) // temporary fix for tcc on windows.
} }