From 4d670146b4054e11e90227f96a3a1c66410e8d0b Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Thu, 19 Jan 2023 13:00:09 +0000 Subject: more cross-platform work --- compiler_and_linker/unsorted/CMachine.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'compiler_and_linker/unsorted/CMachine.c') diff --git a/compiler_and_linker/unsorted/CMachine.c b/compiler_and_linker/unsorted/CMachine.c index c62faf5..eff2243 100644 --- a/compiler_and_linker/unsorted/CMachine.c +++ b/compiler_and_linker/unsorted/CMachine.c @@ -132,7 +132,7 @@ void CMach_Configure(void) { SInt32 CMach_GetQUALalign(UInt32 qual) { SInt32 result = 0; - SInt32 chk; + UInt32 chk; if ((chk = (qual & Q_ALIGNED_MASK))) { if (chk == Q_ALIGNED_1) @@ -183,10 +183,14 @@ SInt32 CMach_ArgumentAlignment(Type *type) { copts.structalignment = save_align_mode; copts.oldalignment = save_oldalignment; - if (type->type == TYPESTRUCT && !TYPE_STRUCT(type)->members && TYPE_STRUCT(type)->align > align) - align = TYPE_STRUCT(type)->align; - - return align; + if (type->type == TYPESTRUCT && !TYPE_STRUCT(type)->members) { + if (TYPE_STRUCT(type)->align > align) + return TYPE_STRUCT(type)->align; + else + return align; + } else { + return align; + } } // TODO: investigate if this returns SInt16 actually @@ -540,23 +544,23 @@ CInt64 CMach_CalcIntConvertFromFloat(Type *type, Float fval) { } void CMach_InitIntMem(Type *type, CInt64 val, void *mem) { - UInt32 lg; - UInt16 sh; - UInt8 ch; + SInt32 lg; + SInt16 sh; + SInt8 ch; switch (type->type) { case TYPEINT: switch (type->size) { case 1: - ch = (UInt8) CInt64_GetULong(&val); + ch = CInt64_GetULong(&val); memcpy(mem, &ch, 1); break; case 2: - sh = (UInt16) CTool_EndianConvertWord16(CInt64_GetULong(&val)); + sh = CTool_EndianConvertWord16(CInt64_GetULong(&val)); memcpy(mem, &sh, 2); break; case 4: - lg = (UInt32) CTool_EndianConvertWord32(CInt64_GetULong(&val)); + lg = CTool_EndianConvertWord32(CInt64_GetULong(&val)); memcpy(mem, &lg, 4); break; case 8: @@ -1299,7 +1303,7 @@ UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc) { return 0; case TYPECLASS: case TYPEMEMBERPOINTER: - return CMach_PassResultInHiddenArg(tfunc->functype) ? 1 : 0; + return CMach_PassResultInHiddenArg(tfunc->functype) != 0; default: return 0; } @@ -1315,7 +1319,7 @@ Boolean CMach_PassResultInHiddenArg(Type *type) { case TYPECLASS: return 1; case TYPEMEMBERPOINTER: - return (type->size == 4) ? 0 : 1; + return (type->size != 4); default: return 0; } -- cgit v1.2.3