mirror of https://git.wuffs.org/MWCC
more cross-platform work
This commit is contained in:
parent
5d0bbb19cc
commit
4d670146b4
|
@ -7,7 +7,8 @@ include_directories(.)
|
||||||
include_directories(includes)
|
include_directories(includes)
|
||||||
include_directories(sdk_hdrs)
|
include_directories(sdk_hdrs)
|
||||||
|
|
||||||
# add_compile_definitions(CW_PATCH_DEBUG)
|
# add_compile_definitions(CW_ENABLE_IRO_DEBUG)
|
||||||
|
add_compile_definitions(CW_ENABLE_PCODE_DEBUG CW_TARGET_MACH CW_CLT)
|
||||||
|
|
||||||
add_executable(mwcc
|
add_executable(mwcc
|
||||||
command_line/CmdLine/Src/Clients/CLStaticMain.c
|
command_line/CmdLine/Src/Clients/CLStaticMain.c
|
||||||
|
|
|
@ -6,7 +6,7 @@ void License_Initialize(void) {
|
||||||
void License_Terminate(void) {
|
void License_Terminate(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SInt32 License_Checkout(void) {
|
SInt32 License_Checkout(const char *featureName, const char *licenseVersion, Boolean flag, char *errorBuf) {
|
||||||
return 0xD0AD0A;
|
return 0xD0AD0A;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1182,12 +1182,12 @@ CWResult UCBSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Han
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CWResult UCBCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr) {
|
CWResult UCBCheckoutLicense(CWPluginContext context, const char *featureName, const char *licenseVersion, SInt32 flags, void *reserved, SInt32 *cookie) {
|
||||||
if (optsCmdLine.verbose > 3)
|
if (optsCmdLine.verbose > 3)
|
||||||
CLPrint("Callback: %s\n", "UCBCheckoutLicense");
|
CLPrint("Callback: %s\n", "UCBCheckoutLicense");
|
||||||
|
|
||||||
if (cookiePtr)
|
if (cookie)
|
||||||
*cookiePtr = 0xD0A;
|
*cookie = 0xD0A;
|
||||||
|
|
||||||
return cwErrInvalidCallback;
|
return cwErrInvalidCallback;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,13 @@ static void get_extension(ConstStringPtr src, char *dst) {
|
||||||
|
|
||||||
if (ep >= 2) {
|
if (ep >= 2) {
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; (x + ep) <= src[0]; x++)
|
for (x = 0; (x + ep) <= src[0]; x++) {
|
||||||
|
#ifdef CW_CLT
|
||||||
dst[x] = src[x + ep];
|
dst[x] = src[x + ep];
|
||||||
|
#else
|
||||||
|
dst[x] = tolower(src[x + ep]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
dst[x] = 0;
|
dst[x] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +76,7 @@ static int setup_param_block(CWPluginContext context) {
|
||||||
cparams.targetOS = tinfo.targetOS;
|
cparams.targetOS = tinfo.targetOS;
|
||||||
cparams.targetCPU = tinfo.targetCPU;
|
cparams.targetCPU = tinfo.targetCPU;
|
||||||
cparams.idetargetname = target_name;
|
cparams.idetargetname = target_name;
|
||||||
return CWGetTargetName(context, target_name, sizeof(target_name)) == cwNoErr;
|
return CWGetTargetName(context, cparams.idetargetname, sizeof(target_name)) == cwNoErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static short store_compile_results(void) {
|
static short store_compile_results(void) {
|
||||||
|
@ -231,7 +236,8 @@ CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context) {
|
||||||
CodeGen_InitBackEndOptions();
|
CodeGen_InitBackEndOptions();
|
||||||
CodeGen_UpdateOptimizerOptions();
|
CodeGen_UpdateOptimizerOptions();
|
||||||
CodeGen_UpdateBackEndOptions();
|
CodeGen_UpdateBackEndOptions();
|
||||||
if (C_Compiler(&cparams))
|
result = C_Compiler(&cparams);
|
||||||
|
if (result != noErr)
|
||||||
result = store_compile_results();
|
result = store_compile_results();
|
||||||
else
|
else
|
||||||
result = cwErrRequestFailed;
|
result = cwErrRequestFailed;
|
||||||
|
|
|
@ -132,7 +132,7 @@ void CMach_Configure(void) {
|
||||||
|
|
||||||
SInt32 CMach_GetQUALalign(UInt32 qual) {
|
SInt32 CMach_GetQUALalign(UInt32 qual) {
|
||||||
SInt32 result = 0;
|
SInt32 result = 0;
|
||||||
SInt32 chk;
|
UInt32 chk;
|
||||||
|
|
||||||
if ((chk = (qual & Q_ALIGNED_MASK))) {
|
if ((chk = (qual & Q_ALIGNED_MASK))) {
|
||||||
if (chk == Q_ALIGNED_1)
|
if (chk == Q_ALIGNED_1)
|
||||||
|
@ -183,10 +183,14 @@ SInt32 CMach_ArgumentAlignment(Type *type) {
|
||||||
copts.structalignment = save_align_mode;
|
copts.structalignment = save_align_mode;
|
||||||
copts.oldalignment = save_oldalignment;
|
copts.oldalignment = save_oldalignment;
|
||||||
|
|
||||||
if (type->type == TYPESTRUCT && !TYPE_STRUCT(type)->members && TYPE_STRUCT(type)->align > align)
|
if (type->type == TYPESTRUCT && !TYPE_STRUCT(type)->members) {
|
||||||
align = TYPE_STRUCT(type)->align;
|
if (TYPE_STRUCT(type)->align > align)
|
||||||
|
return TYPE_STRUCT(type)->align;
|
||||||
return align;
|
else
|
||||||
|
return align;
|
||||||
|
} else {
|
||||||
|
return align;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: investigate if this returns SInt16 actually
|
// 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) {
|
void CMach_InitIntMem(Type *type, CInt64 val, void *mem) {
|
||||||
UInt32 lg;
|
SInt32 lg;
|
||||||
UInt16 sh;
|
SInt16 sh;
|
||||||
UInt8 ch;
|
SInt8 ch;
|
||||||
|
|
||||||
switch (type->type) {
|
switch (type->type) {
|
||||||
case TYPEINT:
|
case TYPEINT:
|
||||||
switch (type->size) {
|
switch (type->size) {
|
||||||
case 1:
|
case 1:
|
||||||
ch = (UInt8) CInt64_GetULong(&val);
|
ch = CInt64_GetULong(&val);
|
||||||
memcpy(mem, &ch, 1);
|
memcpy(mem, &ch, 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sh = (UInt16) CTool_EndianConvertWord16(CInt64_GetULong(&val));
|
sh = CTool_EndianConvertWord16(CInt64_GetULong(&val));
|
||||||
memcpy(mem, &sh, 2);
|
memcpy(mem, &sh, 2);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
lg = (UInt32) CTool_EndianConvertWord32(CInt64_GetULong(&val));
|
lg = CTool_EndianConvertWord32(CInt64_GetULong(&val));
|
||||||
memcpy(mem, &lg, 4);
|
memcpy(mem, &lg, 4);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -1299,7 +1303,7 @@ UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc) {
|
||||||
return 0;
|
return 0;
|
||||||
case TYPECLASS:
|
case TYPECLASS:
|
||||||
case TYPEMEMBERPOINTER:
|
case TYPEMEMBERPOINTER:
|
||||||
return CMach_PassResultInHiddenArg(tfunc->functype) ? 1 : 0;
|
return CMach_PassResultInHiddenArg(tfunc->functype) != 0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1315,7 +1319,7 @@ Boolean CMach_PassResultInHiddenArg(Type *type) {
|
||||||
case TYPECLASS:
|
case TYPECLASS:
|
||||||
return 1;
|
return 1;
|
||||||
case TYPEMEMBERPOINTER:
|
case TYPEMEMBERPOINTER:
|
||||||
return (type->size == 4) ? 0 : 1;
|
return (type->size != 4);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,9 +519,8 @@ void CParser_PrintUniqueID(char *buf) {
|
||||||
ptr = mybuf;
|
ptr = mybuf;
|
||||||
id = CParser_GetUniqueID();
|
id = CParser_GetUniqueID();
|
||||||
while (id) {
|
while (id) {
|
||||||
*ptr = '0' + (id - ((id / 10) * 10));
|
*(ptr++) = '0' + (id - ((id / 10) * 10));
|
||||||
id = id / 10;
|
id = id / 10;
|
||||||
ptr++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ptr > mybuf)
|
while (ptr > mybuf)
|
||||||
|
@ -541,7 +540,7 @@ HashNameNode *CParser_GetUniqueName(void) {
|
||||||
return GetHashNameNodeExport(buf);
|
return GetHashNameNodeExport(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashNameNode *CParser_NameConcat(char *a, char *b) {
|
HashNameNode *CParser_NameConcat(const char *a, const char *b) {
|
||||||
char mybuf[256];
|
char mybuf[256];
|
||||||
char *buf;
|
char *buf;
|
||||||
char *dst;
|
char *dst;
|
||||||
|
@ -658,18 +657,18 @@ static void CParser_SetCFMFlags(Object *object, DeclInfo *declinfo) {
|
||||||
|
|
||||||
if (object->datatype == DDATA) {
|
if (object->datatype == DDATA) {
|
||||||
if (copts.cfm_export)
|
if (copts.cfm_export)
|
||||||
object->flags |= OBJECT_FLAGS_40;
|
object->flags = object->flags | OBJECT_FLAGS_40;
|
||||||
if (copts.cfm_internal)
|
if (copts.cfm_internal)
|
||||||
object->flags |= OBJECT_FLAGS_10;
|
object->flags = object->flags | OBJECT_FLAGS_10;
|
||||||
} else if (copts.cfm_internal) {
|
} else if (copts.cfm_internal) {
|
||||||
object->flags |= OBJECT_FLAGS_10;
|
object->flags = object->flags | OBJECT_FLAGS_10;
|
||||||
} else {
|
} else {
|
||||||
if (copts.cfm_import)
|
if (copts.cfm_import)
|
||||||
object->flags |= OBJECT_FLAGS_20;
|
object->flags = object->flags | OBJECT_FLAGS_20;
|
||||||
if (copts.cfm_export)
|
if (copts.cfm_export)
|
||||||
object->flags |= OBJECT_FLAGS_40;
|
object->flags = object->flags | OBJECT_FLAGS_40;
|
||||||
if (copts.cfm_lib_export)
|
if (copts.cfm_lib_export)
|
||||||
object->flags |= OBJECT_FLAGS_20 | OBJECT_FLAGS_40;
|
object->flags = object->flags | OBJECT_FLAGS_20 | OBJECT_FLAGS_40;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1686,7 +1685,7 @@ Boolean CParser_IsConst(Type *type, UInt32 qual) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return qual & Q_CONST;
|
return (qual & Q_CONST) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean CParser_IsVolatile(Type *type, UInt32 qual) {
|
Boolean CParser_IsVolatile(Type *type, UInt32 qual) {
|
||||||
|
@ -1702,7 +1701,7 @@ Boolean CParser_IsVolatile(Type *type, UInt32 qual) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (qual & Q_VOLATILE) ? 1 : 0;
|
return (qual & Q_VOLATILE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean is_const_object(Object *obj) {
|
Boolean is_const_object(Object *obj) {
|
||||||
|
@ -2105,15 +2104,15 @@ void CParser_ParseDeclSpec(DeclInfo *declinfo, Boolean flag) {
|
||||||
if (tk != TK_EXPORT)
|
if (tk != TK_EXPORT)
|
||||||
CError_Error(CErrorStr107);
|
CError_Error(CErrorStr107);
|
||||||
else
|
else
|
||||||
declinfo->exportflags |= EXPORT_FLAGS_EXPORT;
|
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_EXPORT;
|
||||||
} else if (!strcmp("internal", tkidentifier->name)) {
|
} else if (!strcmp("internal", tkidentifier->name)) {
|
||||||
declinfo->exportflags |= EXPORT_FLAGS_INTERNAL;
|
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_INTERNAL;
|
||||||
} else if (!strcmp("import", tkidentifier->name) || !strcmp("dllimport", tkidentifier->name)) {
|
} else if (!strcmp("import", tkidentifier->name) || !strcmp("dllimport", tkidentifier->name)) {
|
||||||
declinfo->exportflags |= EXPORT_FLAGS_IMPORT;
|
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_IMPORT;
|
||||||
} else if (!strcmp("export", tkidentifier->name) || !strcmp("dllexport", tkidentifier->name)) {
|
} else if (!strcmp("export", tkidentifier->name) || !strcmp("dllexport", tkidentifier->name)) {
|
||||||
declinfo->exportflags |= EXPORT_FLAGS_EXPORT;
|
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_EXPORT;
|
||||||
} else if (!strcmp("lib_export", tkidentifier->name)) {
|
} else if (!strcmp("lib_export", tkidentifier->name)) {
|
||||||
declinfo->exportflags |= EXPORT_FLAGS_IMPORT | EXPORT_FLAGS_EXPORT;
|
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_IMPORT | EXPORT_FLAGS_EXPORT;
|
||||||
} else if (!strcmp("weak", tkidentifier->name)) {
|
} else if (!strcmp("weak", tkidentifier->name)) {
|
||||||
declinfo->qual |= Q_OVERLOAD;
|
declinfo->qual |= Q_OVERLOAD;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3157,7 +3156,7 @@ void CParser_NewCallBackAction(Object *obj, TypeClass *tclass) {
|
||||||
act->obj = obj;
|
act->obj = obj;
|
||||||
act->tclass = tclass;
|
act->tclass = tclass;
|
||||||
callbackactions = act;
|
callbackactions = act;
|
||||||
obj->flags |= OBJECT_FLAGS_8;
|
obj->flags = obj->flags | OBJECT_FLAGS_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParser_NewClassAction(TypeClass *tclass) {
|
void CParser_NewClassAction(TypeClass *tclass) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) {
|
||||||
|
|
||||||
CError_ASSERT(234, stIsSetup);
|
CError_ASSERT(234, stIsSetup);
|
||||||
|
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_IRO_DEBUG
|
||||||
if (copts.debuglisting)
|
if (copts.debuglisting)
|
||||||
IRO_Log = 1;
|
IRO_Log = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -295,7 +295,7 @@ void IRO_DumpBits(char *name, BitVector *bv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRO_DumpAfterPhase(char *str, Boolean flag) {
|
void IRO_DumpAfterPhase(char *str, Boolean flag) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_IRO_DEBUG
|
||||||
if (copts.debuglisting)
|
if (copts.debuglisting)
|
||||||
flag = 1;
|
flag = 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -445,7 +445,7 @@ void IRO_DumpExprs(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRO_SetupDump(void) {
|
void IRO_SetupDump(void) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_IRO_DEBUG
|
||||||
IRO_Log = 1;
|
IRO_Log = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#include "compiler/objects.h"
|
#include "compiler/objects.h"
|
||||||
#include "cos.h"
|
#include "cos.h"
|
||||||
|
|
||||||
|
#ifndef CW_TARGET_MACH
|
||||||
|
#error "Wrong configuration for ObjGenMachO"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#endif
|
#endif
|
||||||
|
@ -1290,7 +1294,7 @@ MachOSection *ObjGen_DeclareFunction(Object *object) {
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
MachOSection *ObjGen_DeclareCode(Object *object) {
|
MachOSection *ObjGen_DeclareCode(Object *object, SInt32 size) {
|
||||||
MachOSection *section;
|
MachOSection *section;
|
||||||
|
|
||||||
section = ObjGen_DeclareFunction(object);
|
section = ObjGen_DeclareFunction(object);
|
||||||
|
|
|
@ -26,7 +26,7 @@ void load_immediate(short reg, SInt32 value) {
|
||||||
if (copts.optimizationlevel > 1 && value)
|
if (copts.optimizationlevel > 1 && value)
|
||||||
tmpreg = used_virtual_registers[RegClass_GPR]++;
|
tmpreg = used_virtual_registers[RegClass_GPR]++;
|
||||||
emitpcode(PC_LIS, tmpreg2 = tmpreg, 0, (short) HIGH_PART(value));
|
emitpcode(PC_LIS, tmpreg2 = tmpreg, 0, (short) HIGH_PART(value));
|
||||||
if (value)
|
if (LOW_PART(value))
|
||||||
emitpcode(PC_ADDI, reg, tmpreg2, 0, LOW_PART(value));
|
emitpcode(PC_ADDI, reg, tmpreg2, 0, LOW_PART(value));
|
||||||
} else {
|
} else {
|
||||||
emitpcode(PC_LI, reg, value);
|
emitpcode(PC_LI, reg, value);
|
||||||
|
@ -263,7 +263,7 @@ void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut) {
|
||||||
emitpcode(PC_ADDI, opOut->regOffset, opB->regOffset, 0, LOW_PART(opA->immediate));
|
emitpcode(PC_ADDI, opOut->regOffset, opB->regOffset, 0, LOW_PART(opA->immediate));
|
||||||
} else {
|
} else {
|
||||||
emitpcode(PC_ADDIS, opOut->regOffset, opB->regOffset, 0, (short) HIGH_PART(opA->immediate));
|
emitpcode(PC_ADDIS, opOut->regOffset, opB->regOffset, 0, (short) HIGH_PART(opA->immediate));
|
||||||
if (opA->immediate != 0)
|
if (LOW_PART(opA->immediate))
|
||||||
emitpcode(PC_ADDI, opOut->regOffset, opOut->regOffset, 0, LOW_PART(opA->immediate));
|
emitpcode(PC_ADDI, opOut->regOffset, opOut->regOffset, 0, LOW_PART(opA->immediate));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -384,7 +384,7 @@ void Coerce_to_register(Operand *op, Type *type, short output_reg) {
|
||||||
if (copts.optimizationlevel > 1 && offset)
|
if (copts.optimizationlevel > 1 && offset)
|
||||||
tmp = used_virtual_registers[RegClass_GPR]++;
|
tmp = used_virtual_registers[RegClass_GPR]++;
|
||||||
emitpcode(PC_LIS, tmp, 0, (short) HIGH_PART(offset));
|
emitpcode(PC_LIS, tmp, 0, (short) HIGH_PART(offset));
|
||||||
if (offset)
|
if (LOW_PART(offset))
|
||||||
emitpcode(PC_ADDI, reg, tmp, 0, LOW_PART(offset));
|
emitpcode(PC_ADDI, reg, tmp, 0, LOW_PART(offset));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -533,7 +533,7 @@ void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short ou
|
||||||
if (copts.optimizationlevel > 1 && offset)
|
if (copts.optimizationlevel > 1 && offset)
|
||||||
tmp1 = used_virtual_registers[RegClass_GPR]++;
|
tmp1 = used_virtual_registers[RegClass_GPR]++;
|
||||||
emitpcode(PC_LIS, tmp1, 0, (short) HIGH_PART(offset));
|
emitpcode(PC_LIS, tmp1, 0, (short) HIGH_PART(offset));
|
||||||
if (offset)
|
if (LOW_PART(offset))
|
||||||
emitpcode(PC_ADDI, reg, tmp1, 0, LOW_PART(offset));
|
emitpcode(PC_ADDI, reg, tmp1, 0, LOW_PART(offset));
|
||||||
}
|
}
|
||||||
regHi = output_regHi ? output_regHi : used_virtual_registers[RegClass_GPR]++;
|
regHi = output_regHi ? output_regHi : used_virtual_registers[RegClass_GPR]++;
|
||||||
|
|
|
@ -1540,7 +1540,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) {
|
||||||
SInt32 codesize;
|
SInt32 codesize;
|
||||||
SInt32 tbsize;
|
SInt32 tbsize;
|
||||||
SInt32 offset;
|
SInt32 offset;
|
||||||
MachOSection *section;
|
SectionHandle section;
|
||||||
EntryPoint *ep;
|
EntryPoint *ep;
|
||||||
WeirdOperand wop;
|
WeirdOperand wop;
|
||||||
|
|
||||||
|
@ -1567,7 +1567,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) {
|
||||||
func->section = SECT_TEXT;
|
func->section = SECT_TEXT;
|
||||||
|
|
||||||
offset = tbsize;
|
offset = tbsize;
|
||||||
section = ObjGen_DeclareCode(func);
|
section = ObjGen_DeclareCode(func, codesize + tbsize);
|
||||||
gl = ObjGen_GetSectionGList(section);
|
gl = ObjGen_GetSectionGList(section);
|
||||||
|
|
||||||
codebase = gl->size;
|
codebase = gl->size;
|
||||||
|
|
|
@ -150,7 +150,7 @@ void pcinitlisting() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void pccleanuplisting(void) {
|
void pccleanuplisting(void) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_PCODE_DEBUG
|
||||||
// this code is not based on the original as we don't have it
|
// this code is not based on the original as we don't have it
|
||||||
if (pcfile) {
|
if (pcfile) {
|
||||||
fclose(pcfile);
|
fclose(pcfile);
|
||||||
|
@ -160,7 +160,7 @@ void pccleanuplisting(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void pclistblocks(char *name1, char *name2) {
|
void pclistblocks(char *name1, char *name2) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_PCODE_DEBUG
|
||||||
// this code is not based on the original as we don't have it
|
// this code is not based on the original as we don't have it
|
||||||
PCodeBlock *block;
|
PCodeBlock *block;
|
||||||
if (copts.debuglisting) {
|
if (copts.debuglisting) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ void SetupDumpIR(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupDumpIR(void) {
|
void CleanupDumpIR(void) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_PCODE_DEBUG
|
||||||
// this code is not based on the original as we don't have it
|
// this code is not based on the original as we don't have it
|
||||||
if (outfile) {
|
if (outfile) {
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
|
@ -78,7 +78,7 @@ void CleanupDumpIR(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpIR(Statement *statements, Object *func) {
|
void DumpIR(Statement *statements, Object *func) {
|
||||||
#ifdef CW_PATCH_DEBUG
|
#ifdef CW_ENABLE_PCODE_DEBUG
|
||||||
// this code is not based on the original as we don't have it
|
// this code is not based on the original as we don't have it
|
||||||
if (copts.debuglisting) {
|
if (copts.debuglisting) {
|
||||||
if (!outfile)
|
if (!outfile)
|
||||||
|
|
|
@ -773,7 +773,7 @@ extern void FreeIncludeFile(Handle text);
|
||||||
/* CLLicenses.c */
|
/* CLLicenses.c */
|
||||||
extern void License_Initialize(void);
|
extern void License_Initialize(void);
|
||||||
extern void License_Terminate(void);
|
extern void License_Terminate(void);
|
||||||
extern SInt32 License_Checkout(/* unknown args */);
|
extern SInt32 License_Checkout(const char *featureName, const char *licenseVersion, Boolean flag, char *errorBuf);
|
||||||
extern void License_Refresh(/* unknown args */);
|
extern void License_Refresh(/* unknown args */);
|
||||||
extern void License_Checkin(/* unknown args */);
|
extern void License_Checkin(/* unknown args */);
|
||||||
extern void License_AutoCheckin(void);
|
extern void License_AutoCheckin(void);
|
||||||
|
|
|
@ -19,13 +19,16 @@
|
||||||
#undef toupper
|
#undef toupper
|
||||||
#undef tolower
|
#undef tolower
|
||||||
|
|
||||||
|
#ifdef CW_CLT
|
||||||
// What the fuck is this haha
|
// What the fuck is this haha
|
||||||
// typedef char * va_list;
|
// typedef char * va_list;
|
||||||
#define va_start(a,b) (a = ((va_list) __builtin_next_arg(b)))
|
#define va_start(a,b) (a = ((va_list) __builtin_next_arg(b)))
|
||||||
#define va_arg(a,b) (*(b *) (void *) ((a = (char *) (((((unsigned long)(a)) + ((__alignof__ (b) == 16) ? 15 : 3)) & ~((__alignof__ (b) == 16) ? 15 : 3)) + ((sizeof (b) + 3) & ~3))) - ((sizeof (b) + 3) & ~3)))
|
#define va_arg(a,b) (*(b *) (void *) ((a = (char *) (((((unsigned long)(a)) + ((__alignof__ (b) == 16) ? 15 : 3)) & ~((__alignof__ (b) == 16) ? 15 : 3)) + ((sizeof (b) + 3) & ~3))) - ((sizeof (b) + 3) & ~3)))
|
||||||
#define va_end(a) ((void)0)
|
#define va_end(a) ((void)0)
|
||||||
|
|
||||||
#define alloca(x) __alloca(x)
|
#define alloca(x) __alloca(x)
|
||||||
|
#else
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CW_INLINE inline
|
#define CW_INLINE inline
|
||||||
|
|
||||||
|
@ -168,7 +171,11 @@ enum {
|
||||||
typedef struct FSSpec {
|
typedef struct FSSpec {
|
||||||
SInt16 vRefNum;
|
SInt16 vRefNum;
|
||||||
SInt32 parID;
|
SInt32 parID;
|
||||||
|
#ifdef CW_CLT
|
||||||
Str255 name;
|
Str255 name;
|
||||||
|
#else
|
||||||
|
Str63 name;
|
||||||
|
#endif
|
||||||
} FSSpec;
|
} FSSpec;
|
||||||
|
|
||||||
typedef struct FInfo {
|
typedef struct FInfo {
|
||||||
|
|
|
@ -342,7 +342,7 @@ extern SInt32 CParser_GetUniqueID(void);
|
||||||
extern void CParser_PrintUniqueID(char *buf);
|
extern void CParser_PrintUniqueID(char *buf);
|
||||||
extern void CParser_SetUniqueID(SInt32 id);
|
extern void CParser_SetUniqueID(SInt32 id);
|
||||||
extern HashNameNode *CParser_GetUniqueName(void);
|
extern HashNameNode *CParser_GetUniqueName(void);
|
||||||
extern HashNameNode *CParser_NameConcat(char *a, char *b);
|
extern HashNameNode *CParser_NameConcat(const char *a, const char *b);
|
||||||
extern HashNameNode *CParser_AppendUniqueName(char *prefix);
|
extern HashNameNode *CParser_AppendUniqueName(char *prefix);
|
||||||
extern HashNameNode *CParser_AppendUniqueNameFile(char *prefix);
|
extern HashNameNode *CParser_AppendUniqueNameFile(char *prefix);
|
||||||
extern Boolean IsTempName(HashNameNode *name);
|
extern Boolean IsTempName(HashNameNode *name);
|
||||||
|
|
|
@ -2,7 +2,14 @@
|
||||||
#define COMPILER_OBJGENMACHO_H
|
#define COMPILER_OBJGENMACHO_H
|
||||||
|
|
||||||
#include "compiler/common.h"
|
#include "compiler/common.h"
|
||||||
|
|
||||||
|
#ifdef CW_TARGET_MACH
|
||||||
#include "compiler/MachO.h"
|
#include "compiler/MachO.h"
|
||||||
|
typedef MachOSection *SectionHandle;
|
||||||
|
#define ObjGen_SourceRef ObjGen_Line
|
||||||
|
#else
|
||||||
|
typedef Section SectionHandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum MWReloc {
|
typedef enum MWReloc {
|
||||||
MW_RELOC_0 = 0,
|
MW_RELOC_0 = 0,
|
||||||
|
@ -16,11 +23,31 @@ typedef enum MWReloc {
|
||||||
MW_RELOC_9 = 9
|
MW_RELOC_9 = 9
|
||||||
} MWReloc;
|
} MWReloc;
|
||||||
|
|
||||||
extern Boolean declare_readonly;
|
|
||||||
extern SInt32 symdeclend;
|
|
||||||
extern SInt32 symdecloffset;
|
extern SInt32 symdecloffset;
|
||||||
// this conflicts with other files
|
extern SInt32 symdeclend;
|
||||||
//extern SInt32 nexttypeid;
|
|
||||||
|
extern void ObjGen_Setup(void);
|
||||||
|
extern void ObjGen_Finish(void);
|
||||||
|
extern void ObjGen_Cleanup(void);
|
||||||
|
extern void ObjGen_CodeCleanup(void);
|
||||||
|
extern void ObjGen_SetupSym(void);
|
||||||
|
extern void ObjGen_SymFunc(Object *function);
|
||||||
|
extern void ObjGen_SegmentName(void);
|
||||||
|
extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag);
|
||||||
|
extern void ObjGen_DeclareData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
|
||||||
|
extern void ObjGen_DeclareReadOnlyData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
|
||||||
|
extern void ObjGen_DeclareSwitchTable(Object *tableobj, Object *funcobj);
|
||||||
|
extern SectionHandle ObjGen_DeclareCode(Object *object, SInt32 size);
|
||||||
|
extern void ObjGen_DeclareEntry(Object *object, SInt32 offset);
|
||||||
|
extern void ObjGen_DeclareSymInfo(void);
|
||||||
|
extern void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data, SInt32 len, OLinkList *refs);
|
||||||
|
extern void ObjGen_DeclareTracebackTable(Object *tableobj, void *data, SInt32 size);
|
||||||
|
extern void ObjGen_RelocateObj(SectionHandle section, SInt32 offset, Object *object, MWReloc mwRelType);
|
||||||
|
extern void ObjGen_SourceRef(UInt32 line, UInt32 offset);
|
||||||
|
extern GList *ObjGen_GetSectionGList(SectionHandle section);
|
||||||
|
|
||||||
|
#ifdef CW_TARGET_MACH
|
||||||
|
extern Boolean declare_readonly;
|
||||||
extern GList symtypemodule;
|
extern GList symtypemodule;
|
||||||
extern SInt32 last_base_offset[N_SECTIONS];
|
extern SInt32 last_base_offset[N_SECTIONS];
|
||||||
extern MachOSection *Sections[N_SECTIONS];
|
extern MachOSection *Sections[N_SECTIONS];
|
||||||
|
@ -30,26 +57,13 @@ extern SInt32 pic_base_offset;
|
||||||
|
|
||||||
extern SInt32 ObjGen_MakeSectReloc(MachOSection *section);
|
extern SInt32 ObjGen_MakeSectReloc(MachOSection *section);
|
||||||
extern SInt32 ObjGen_GetHashNodeRelocID(Object *object, MachOSection *section, SInt32 value);
|
extern SInt32 ObjGen_GetHashNodeRelocID(Object *object, MachOSection *section, SInt32 value);
|
||||||
extern void ObjGen_Setup(void);
|
|
||||||
extern void ObjGen_DeclareFloatConst(Object *object);
|
extern void ObjGen_DeclareFloatConst(Object *object);
|
||||||
extern void ObjGen_DeclareVectorConst(Object *object);
|
extern void ObjGen_DeclareVectorConst(Object *object);
|
||||||
extern void ObjGen_Finish(void);
|
|
||||||
extern void ObjGen_Cleanup(void);
|
|
||||||
extern void ObjGen_SetupSym(void);
|
|
||||||
extern void ObjGen_DeclareData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
|
|
||||||
extern void ObjGen_DeclareReadOnlyData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
|
|
||||||
extern void ObjGen_SegmentName(void);
|
|
||||||
extern void ObjGen_SymFunc(Object *function);
|
|
||||||
extern void ObjGenMach_SymFuncEnd(Object *function, UInt32 offset);
|
extern void ObjGenMach_SymFuncEnd(Object *function, UInt32 offset);
|
||||||
extern void ObjGen_CodeSetup(void);
|
extern void ObjGen_CodeSetup(void);
|
||||||
extern void ObjGen_CodeCleanup(void);
|
|
||||||
extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag);
|
|
||||||
extern GList *ObjGen_GetSectionGList(MachOSection *section);
|
|
||||||
extern MachOSection *ObjGen_DeclareFunction(Object *object);
|
extern MachOSection *ObjGen_DeclareFunction(Object *object);
|
||||||
extern MachOSection *ObjGen_DeclareCode(Object *object);
|
|
||||||
extern MachOSection *ObjGen_DeclareMachSection(/* unknown args */);
|
extern MachOSection *ObjGen_DeclareMachSection(/* unknown args */);
|
||||||
extern void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType);
|
extern void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType);
|
||||||
extern void ObjGen_RelocateObj(MachOSection *section, SInt32 offset, Object *object, MWReloc mwRelType);
|
|
||||||
extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align);
|
extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align);
|
||||||
extern UInt32 ObjGen_GetSectSize(MachOSection *section);
|
extern UInt32 ObjGen_GetSectSize(MachOSection *section);
|
||||||
extern void ObjGen_GetExtName(SInt32 id, char *buf);
|
extern void ObjGen_GetExtName(SInt32 id, char *buf);
|
||||||
|
@ -59,17 +73,12 @@ extern Boolean ObjGen_IsExternalVar(SInt32 id);
|
||||||
extern SInt32 ObjGen_DeclareInit(UInt32 len, char *data, SInt32 align);
|
extern SInt32 ObjGen_DeclareInit(UInt32 len, char *data, SInt32 align);
|
||||||
extern void CodeGen_GenDynLinkStub(MachOSection *a, MachOSection *b, SInt32 relocID);
|
extern void CodeGen_GenDynLinkStub(MachOSection *a, MachOSection *b, SInt32 relocID);
|
||||||
extern void ObjGen_DeclarePICBase(Object *object, SInt32 offset);
|
extern void ObjGen_DeclarePICBase(Object *object, SInt32 offset);
|
||||||
extern void ObjGen_DeclareEntry(Object *object, SInt32 offset);
|
|
||||||
extern void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data, SInt32 len, OLinkList *refs);
|
|
||||||
extern void ObjGen_DeclareCodeLabel(Object *labelobj, SInt32 offset, Object *funcobj);
|
extern void ObjGen_DeclareCodeLabel(Object *labelobj, SInt32 offset, Object *funcobj);
|
||||||
extern void ObjGen_DeclareSwitchTable(Object *tableobj, Object *funcobj);
|
|
||||||
extern void ObjGen_DeclareTracebackTable(Object *tableobj, void *data, SInt32 size);
|
|
||||||
extern void ObjGen_DeclareSymInfo(void);
|
|
||||||
extern void ObjGen_Line(UInt32 line, UInt32 offset);
|
|
||||||
extern void ObjGen_OutputDebugInfo(Object *funcobj);
|
extern void ObjGen_OutputDebugInfo(Object *funcobj);
|
||||||
extern SInt32 ObjGen_OutputStab(SymbolData *symbol, SInt32 strIdx);
|
extern SInt32 ObjGen_OutputStab(SymbolData *symbol, SInt32 strIdx);
|
||||||
extern void ObjGen_SetSectName(/* unknown args */);
|
extern void ObjGen_SetSectName(/* unknown args */);
|
||||||
extern void ObjGen_DeclareInitFunction(Object *funcobj);
|
extern void ObjGen_DeclareInitFunction(Object *funcobj);
|
||||||
extern Boolean ObjGen_IsExported(Object *object);
|
extern Boolean ObjGen_IsExported(Object *object);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -270,7 +270,7 @@ extern CWResult UCBCacheAccessPathList(CWPluginContext context);
|
||||||
extern CWResult UCBSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle);
|
extern CWResult UCBSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle);
|
||||||
extern CWResult UCBSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
extern CWResult UCBSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
||||||
extern CWResult UCBSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
extern CWResult UCBSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
||||||
extern CWResult UCBCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr);
|
extern CWResult UCBCheckoutLicense(CWPluginContext context, const char *featureName, const char *licenseVersion, SInt32 flags, void *reserved, SInt32 *cookie);
|
||||||
extern CWResult UCBCheckinLicense(CWPluginContext context, SInt32 cookie);
|
extern CWResult UCBCheckinLicense(CWPluginContext context, SInt32 cookie);
|
||||||
extern CWResult UCBResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create);
|
extern CWResult UCBResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create);
|
||||||
extern CWResult UCBMacOSErrToCWResult(CWPluginContext context, OSErr err);
|
extern CWResult UCBMacOSErrToCWResult(CWPluginContext context, OSErr err);
|
||||||
|
|
17
notes
17
notes
|
@ -1,18 +1,13 @@
|
||||||
OS X:
|
OS X:
|
||||||
~/bin/mwccppc -c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off
|
~/bin/mwccppc -c -g -DCW_TARGET_MACH -DCW_CLT -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off
|
||||||
|
|
||||||
OS 9:
|
OS 9 wine setup (does not match):
|
||||||
export MWCIncludes="/Users/ash/src/mwcc/native_copy/msl_c_pro7/MSL_Common/Include;/Users/ash/src/mwcc/native_copy/msl_c_pro7/MSL_MacOS/Include"
|
export MWCIncludes="/Users/ash/src/mwcc/native_copy/msl_c_pro7/MSL_Common/Include;/Users/ash/src/mwcc/native_copy/msl_c_pro7/MSL_MacOS/Include"
|
||||||
wine ../reversing/v7_0_mwcppc.exe -g -opt l=4,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused,notinlined -wchar_t on -bool off -Cpp_exceptions off -maxwarnings 10
|
wine ../reversing/v7_0_mwcppc.exe -g -DCW_TARGET_MACH -opt l=4,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused,notinlined -wchar_t on -bool off -Cpp_exceptions off -maxwarnings 10
|
||||||
|
|
||||||
TODO:
|
OS 9 mpw-emu setup:
|
||||||
- locate COS stuff based off EPPC 8 debug info
|
export MWCIncludes=":msl_c_pro7:MSL_Common:Include,:msl_c_pro7:MSL_MacOS:Include"
|
||||||
- command_line/C++_Parser/Src/Library/OptimizerHelpers.c
|
mpw-emu mwcppc_v7 -g -DCW_TARGET_MACH -opt l=4,speed,nopeephole,noschedule -enum min -convertpaths -Iincludes -Isdk_hdrs -w all,nounused,notinlined -wchar_t on -bool off -Cpp_exceptions off -maxwarnings 10
|
||||||
- compiler_and_linker/CmdLine_Tools/Embedded_PPC/Tools_EPPC/Src/Options/Glue/TargetOptimizerHelpers-eppc.c
|
|
||||||
- compiler_and_linker/FrontEnd/Common/COSToolsMemory.h
|
|
||||||
- compiler_and_linker/FrontEnd/Common/COSToolsFileSpecs.h
|
|
||||||
- compiler_and_linker/FrontEnd/Common/COSToolsWin32.c
|
|
||||||
also worth checking ~/s/mwcc/reversing/ftp_backup/Metrowerks/CWPPC6/ext_65/Disk1/PPC_EABI_Tools-CLT/mwcceppc.exe strings
|
|
||||||
|
|
||||||
* - has issues
|
* - has issues
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue