mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-20 08:26:47 +00:00
Endian specific floating point types (e.g. f32be)
This commit is contained in:
@@ -57,7 +57,7 @@ Type_Info_Struct_Soa_Kind :: enum u8 {
|
||||
Type_Info_Named :: struct {name: string, base: ^Type_Info};
|
||||
Type_Info_Integer :: struct {signed: bool, endianness: Platform_Endianness};
|
||||
Type_Info_Rune :: struct {};
|
||||
Type_Info_Float :: struct {};
|
||||
Type_Info_Float :: struct {endianness: Platform_Endianness};
|
||||
Type_Info_Complex :: struct {};
|
||||
Type_Info_Quaternion :: struct {};
|
||||
Type_Info_String :: struct {is_cstring: bool};
|
||||
|
||||
@@ -18,6 +18,22 @@ bswap_128 :: proc "none" (x: u128) -> u128 {
|
||||
return u128(bswap_64(u64(x))) | u128(bswap_64(u64(x>>64)));
|
||||
}
|
||||
|
||||
|
||||
bswap_f32 :: proc "none" (f: f32) -> f32 {
|
||||
x := transmute(u32)f;
|
||||
z := x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24;
|
||||
return transmute(f32)z;
|
||||
|
||||
}
|
||||
|
||||
bswap_f64 :: proc "none" (f: f64) -> f64 {
|
||||
x := transmute(u64)f;
|
||||
z := u64(bswap_32(u32(x))) | u64(bswap_32(u32(x>>32)));
|
||||
return transmute(f64)z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ptr_offset :: inline proc "contextless" (ptr: $P/^$T, n: int) -> P {
|
||||
new := int(uintptr(ptr)) + size_of(T)*n;
|
||||
return P(uintptr(new));
|
||||
|
||||
Reference in New Issue
Block a user