summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/CMachine.c
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-19 13:00:09 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-19 13:00:09 +0000
commit4d670146b4054e11e90227f96a3a1c66410e8d0b (patch)
tree8dca31cf9ee497ee59e833f48dd76c81aaef3cf5 /compiler_and_linker/unsorted/CMachine.c
parent5d0bbb19cc133753cebda7099e46d4b2084336c6 (diff)
downloadMWCC-4d670146b4054e11e90227f96a3a1c66410e8d0b.tar.gz
MWCC-4d670146b4054e11e90227f96a3a1c66410e8d0b.zip
more cross-platform work
Diffstat (limited to 'compiler_and_linker/unsorted/CMachine.c')
-rw-r--r--compiler_and_linker/unsorted/CMachine.c30
1 files changed, 17 insertions, 13 deletions
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;
}