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 --- includes/compiler/CParser.h | 2 +- includes/compiler/ObjGenMachO.h | 55 ++++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 24 deletions(-) (limited to 'includes/compiler') diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h index 65d046a..6b95561 100644 --- a/includes/compiler/CParser.h +++ b/includes/compiler/CParser.h @@ -342,7 +342,7 @@ extern SInt32 CParser_GetUniqueID(void); extern void CParser_PrintUniqueID(char *buf); extern void CParser_SetUniqueID(SInt32 id); 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_AppendUniqueNameFile(char *prefix); extern Boolean IsTempName(HashNameNode *name); diff --git a/includes/compiler/ObjGenMachO.h b/includes/compiler/ObjGenMachO.h index edc4944..4088a7f 100644 --- a/includes/compiler/ObjGenMachO.h +++ b/includes/compiler/ObjGenMachO.h @@ -2,7 +2,14 @@ #define COMPILER_OBJGENMACHO_H #include "compiler/common.h" + +#ifdef CW_TARGET_MACH #include "compiler/MachO.h" +typedef MachOSection *SectionHandle; +#define ObjGen_SourceRef ObjGen_Line +#else +typedef Section SectionHandle; +#endif typedef enum MWReloc { MW_RELOC_0 = 0, @@ -16,11 +23,31 @@ typedef enum MWReloc { MW_RELOC_9 = 9 } MWReloc; -extern Boolean declare_readonly; -extern SInt32 symdeclend; extern SInt32 symdecloffset; -// this conflicts with other files -//extern SInt32 nexttypeid; +extern SInt32 symdeclend; + +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 SInt32 last_base_offset[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_GetHashNodeRelocID(Object *object, MachOSection *section, SInt32 value); -extern void ObjGen_Setup(void); extern void ObjGen_DeclareFloatConst(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 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_DeclareCode(Object *object); extern MachOSection *ObjGen_DeclareMachSection(/* unknown args */); 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 UInt32 ObjGen_GetSectSize(MachOSection *section); 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 void CodeGen_GenDynLinkStub(MachOSection *a, MachOSection *b, SInt32 relocID); 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_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 SInt32 ObjGen_OutputStab(SymbolData *symbol, SInt32 strIdx); extern void ObjGen_SetSectName(/* unknown args */); extern void ObjGen_DeclareInitFunction(Object *funcobj); extern Boolean ObjGen_IsExported(Object *object); +#endif #endif -- cgit v1.2.3