mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix Odin bug with "none" procedure calling conventions in the runtime
This commit is contained in:
@@ -2,31 +2,31 @@ package runtime
|
|||||||
|
|
||||||
import "core:os"
|
import "core:os"
|
||||||
|
|
||||||
bswap_16 :: proc "pure" (x: u16) -> u16 {
|
bswap_16 :: proc "none" (x: u16) -> u16 {
|
||||||
return x>>8 | x<<8;
|
return x>>8 | x<<8;
|
||||||
}
|
}
|
||||||
|
|
||||||
bswap_32 :: proc "pure" (x: u32) -> u32 {
|
bswap_32 :: proc "none" (x: u32) -> u32 {
|
||||||
return x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24;
|
return x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24;
|
||||||
}
|
}
|
||||||
|
|
||||||
bswap_64 :: proc "pure" (x: u64) -> u64 {
|
bswap_64 :: proc "none" (x: u64) -> u64 {
|
||||||
return u64(bswap_32(u32(x))) | u64(bswap_32(u32(x>>32)));
|
return u64(bswap_32(u32(x))) | u64(bswap_32(u32(x>>32)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bswap_128 :: proc "pure" (x: u128) -> u128 {
|
bswap_128 :: proc "none" (x: u128) -> u128 {
|
||||||
return u128(bswap_64(u64(x))) | u128(bswap_64(u64(x>>64)));
|
return u128(bswap_64(u64(x))) | u128(bswap_64(u64(x>>64)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bswap_f32 :: proc "pure" (f: f32) -> f32 {
|
bswap_f32 :: proc "none" (f: f32) -> f32 {
|
||||||
x := transmute(u32)f;
|
x := transmute(u32)f;
|
||||||
z := x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24;
|
z := x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24;
|
||||||
return transmute(f32)z;
|
return transmute(f32)z;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bswap_f64 :: proc "pure" (f: f64) -> f64 {
|
bswap_f64 :: proc "none" (f: f64) -> f64 {
|
||||||
x := transmute(u64)f;
|
x := transmute(u64)f;
|
||||||
z := u64(bswap_32(u32(x))) | u64(bswap_32(u32(x>>32)));
|
z := u64(bswap_32(u32(x))) | u64(bswap_32(u32(x>>32)));
|
||||||
return transmute(f64)z;
|
return transmute(f64)z;
|
||||||
|
|||||||
+9
-7
@@ -1197,13 +1197,15 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
|
|||||||
ctx->curr_proc_sig = type;
|
ctx->curr_proc_sig = type;
|
||||||
ctx->curr_proc_calling_convention = type->Proc.calling_convention;
|
ctx->curr_proc_calling_convention = type->Proc.calling_convention;
|
||||||
|
|
||||||
switch (type->Proc.calling_convention) {
|
if (ctx->pkg->name != "runtime") {
|
||||||
case ProcCC_None:
|
switch (type->Proc.calling_convention) {
|
||||||
error(body, "Procedures with the calling convention \"none\" are not allowed a body");
|
case ProcCC_None:
|
||||||
break;
|
error(body, "Procedures with the calling convention \"none\" are not allowed a body");
|
||||||
case ProcCC_PureNone:
|
break;
|
||||||
error(body, "Procedures with the calling convention \"pure_none\" are not allowed a body");
|
case ProcCC_PureNone:
|
||||||
break;
|
error(body, "Procedures with the calling convention \"pure_none\" are not allowed a body");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_node(bs, BlockStmt, body);
|
ast_node(bs, BlockStmt, body);
|
||||||
|
|||||||
Reference in New Issue
Block a user