From ace24ad68edc04217170ae9a1c09860254442ca7 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Thu, 8 Feb 2007 16:17:32 +0100 Subject: [PATCH] Minor portability fixes. --- src/p_mach.cpp | 8 ++++---- src/p_mach.h | 23 ++++++++++++++++++----- src/p_mach_enum.h | 2 +- src/p_vmlinx.cpp | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/p_mach.cpp b/src/p_mach.cpp index 5c2ea759..88e94d59 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -49,7 +49,7 @@ PackMachBase::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor, unsigned count, unsigned size) : super(f), my_cputype(cputype), my_thread_flavor(flavor), my_thread_state_word_count(count), my_thread_command_size(size), - n_segment(0), rawmseg(0), msegcmd(0) + n_segment(0), rawmseg(NULL), msegcmd(NULL) { MachClass::compileTimeAssertions(); bele = N_BELE_CTP::getRTP(); @@ -58,8 +58,8 @@ PackMachBase::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor, template PackMachBase::~PackMachBase() { - delete [] msegcmd; delete [] rawmseg; + delete [] msegcmd; } template @@ -652,7 +652,7 @@ void PackMachFat::pack(OutputFile *fo) unsigned length = 0; for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) { unsigned base = fo->unset_extent(); // actual length - base += ~(~0u<seek(base, SEEK_SET); fo->set_extent(base, ~0u); @@ -695,7 +695,7 @@ void PackMachFat::unpack(OutputFile *fo) unsigned length; for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) { unsigned base = fo->unset_extent(); // actual length - base += ~(~0u<seek(base, SEEK_SET); fo->set_extent(base, ~0u); diff --git a/src/p_mach.h b/src/p_mach.h index ad702d5d..3dff2415 100644 --- a/src/p_mach.h +++ b/src/p_mach.h @@ -32,9 +32,9 @@ struct Mach_fat_header { BE32 magic; - enum e8 { // note conflict with java bytecode PackLinuxI386 + enum { // note conflict with java bytecode PackLinuxI386 FAT_MAGIC = 0xcafebabe, - FAT_MAGIC_SWAB = 0xbebafeca, + FAT_MAGIC_SWAB = 0xbebafeca }; BE32 nfat_arch; // Number of Mach_fat_arch which follow. } @@ -241,7 +241,11 @@ struct MachClass_32 typedef typename TP::U32 U32; typedef typename TP::U64 U64; typedef N_Mach::MachITypes MachITypes; +#if (ACC_CC_BORLANDC) + typedef U32 Addr; +#else typedef typename MachITypes::Addr Addr; +#endif // Mach types typedef N_Mach::Mach_header Mach_header; @@ -252,6 +256,7 @@ struct MachClass_32 static void compileTimeAssertions() { BeLePolicy::compileTimeAssertions(); + COMPILE_TIME_ASSERT(sizeof(Addr) == 4) } }; @@ -270,6 +275,10 @@ struct MachClass_64 typedef N_Mach::Mach_header64 Mach_header; typedef N_Mach::Mach_segment_command Mach_segment_command; typedef N_Mach::Mach_section_command Mach_section_command; + + static void compileTimeAssertions() { + BeLePolicy::compileTimeAssertions(); + } }; } // namespace N_Mach @@ -515,12 +524,17 @@ protected: virtual void buildLoader(const Filter *ft); virtual Linker* newLinker() const; -protected: +#if (ACC_CC_BORLANDC) +public: +#endif enum { N_FAT_ARCH = 5 }; +protected: struct Fat_head { struct Mach_fat_header fat; struct Mach_fat_arch arch[N_FAT_ARCH]; - } fat_head; + } + __attribute_packed; + Fat_head fat_head; // UI handler UiPacker *uip; @@ -529,7 +543,6 @@ protected: Linker *linker; #define WANT_MACH_HEADER_ENUM #include "p_mach_enum.h" -#undef WANT_MACH_HEADER_ENUM }; #endif /* already included */ diff --git a/src/p_mach_enum.h b/src/p_mach_enum.h index 6180edea..63090657 100644 --- a/src/p_mach_enum.h +++ b/src/p_mach_enum.h @@ -98,7 +98,7 @@ enum { // thread flavor PPC_THREAD_STATE = 1, i386_THREAD_STATE = -1, - i386_NEW_THREAD_STATE = 1, + i386_NEW_THREAD_STATE = 1 }; #endif /*}*/ diff --git a/src/p_vmlinx.cpp b/src/p_vmlinx.cpp index 6c4d1c40..7470627d 100644 --- a/src/p_vmlinx.cpp +++ b/src/p_vmlinx.cpp @@ -66,9 +66,9 @@ PackVmlinuxBase::PackVmlinuxBase(InputFile *f, template PackVmlinuxBase::~PackVmlinuxBase() { - delete [] shstrtab; delete [] phdri; delete [] shdri; + delete [] shstrtab; } template