Final round of portab fixes - UPX should now compile on any halfway

modern C++ compiler.

committer: mfx <mfx> 1058789145 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2003-07-21 12:05:45 +00:00
parent bbbea34d74
commit 4e64cdac15
9 changed files with 112 additions and 55 deletions

View File

@ -145,7 +145,8 @@ DEFS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lmcheck
##CFLAGS_WERROR = -Werror
ifeq ($(DEBUG),0)
ifeq ($(DEBUG),1)
else
##LDFLAGS += -static
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
ifeq ($(arch),i386)
@ -190,7 +191,7 @@ endif
ifeq ($(target),linux-bc57)
##DEPMODE := XXX_linux
CC = bc++ -q -3
CFLAGS = -w -w-aus -w-inl '-w!'
CFLAGS = -w '-w!'
CFLAGS_OUTPUT = -o$@
LDFLAGS += -ls
LINK_EXE_OUTPUT = -e$@
@ -314,7 +315,7 @@ ifeq ($(target),rsxnt)
include $(srcdir)/Makedefs.gcc
e = .exe
CXX = gcc
CFLAGS_O = -O0
CFLAGS_O = -O2
CCARCH += -Zwin32 -Zsys -mno-probe
LDFLAGS = -s
STUBEDIT_EXE = pestack -s1024 -c1024 $@
@ -330,8 +331,8 @@ o = .obj
a = .lib
e = .exe
CC = bcc32 -3
INCLUDES += -I$(srcdir)/acc
CFLAGS = -w -w-aus -w-inl -g1
INCLUDES += -I$(srcdir)/acc -I$(srcdir)/filter
CFLAGS = -w -w-inl -g1
CFLAGS_OUTPUT = -o$@
LDFLAGS = -ls
LINK_EXE_OUTPUT = -e$@
@ -418,11 +419,41 @@ else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
endif
RESOURCES = upx.res
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # ic
###
### win32 - Symantec C++
###
ifeq ($(target),sc)
o = .obj
a = .lib
e = .exe
CC = sc -mn
CFLAGS = -w- -wx
CXXFLAGS = $(CFLAGS) -EH -ER
CFLAGS_OUTPUT = -o$@
LDFLAGS = -L/map
LINK_EXE_OUTPUT = -o$@
LDLIBS = $(DOS_LDLIBS)
ifneq ($(strip $(DOS_LIBDIRS)),)
LIB := $(DOS_LIBDIRS);$(LIB)
endif
export LIB
ifeq ($(DEBUG),1)
CFLAGS += -o- -g -s
else
CFLAGS += -o
endif
endif # dm
###
### win32 - Visual C++
###
@ -460,7 +491,7 @@ else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
endif
RESOURCES = upx.res
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # vc

View File

@ -142,7 +142,7 @@ console_t console_init =
};
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...)
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
{
va_list args;
char buf[80*25];

View File

@ -40,7 +40,9 @@
# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER
#endif
#include "acc/acc.h"
#include "acc/acc_incd.h"
#include "acc/acc_ince.h"
#include "acc/acc_lib.h"
#if !defined(acc_int64l_t) || !defined(acc_uint64l_t)
# error "need a 64-bit integer type"
#endif
@ -55,11 +57,18 @@
# if (__BORLANDC__ < 0x0520)
# error "need Borland C++ 5.02 or newer"
# endif
# pragma warn -aus // 8004: 'x' is assigned a value that is never used
# pragma warn -inl // 8026+8027: Function not expanded inline
// Borland compilers typically generate a number of bogus warnings, and
// the actual diagnostics vary from version to version...
# if (__BORLANDC__ < 0x0530)
# pragma warn -csu // 8012: comparing signed and unsigned values
# pragma warn -csu // 8012: Comparing signed and unsigned values
# endif
# if (__BORLANDC__ >= 0x0530 && __BORLANDC__ < 0x0560)
# pragma warn -osh // 8055: Possible overflow in shift operation
# endif
# if (__BORLANDC__ >= 0x0560)
# pragma warn -use
# pragma warn -use // 8080: 'x' is declared but never used
# endif
#elif (ACC_CC_DMC)
# if (__DMC__ < 0x829)
@ -83,13 +92,11 @@
# if (_MSC_VER < 1100)
# error "need Visual C++ 5.0 or newer"
# endif
#if 0
# pragma warning(disable: 4096) // W2: '__cdecl' must be used with '...'
#endif
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B'
# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
# pragma warning(disable: 4514) // W4: 'function' : unreferenced inline function has been removed
# pragma warning(disable: 4514) // W4: 'function': unreferenced inline function has been removed
# pragma warning(disable: 4710) // W4: 'function': function not inlined
#elif (ACC_CC_WATCOMC)
# if (__WATCOMC__ < 1100)
@ -443,7 +450,7 @@ extern const char *progname;
void init_options(struct options_t *o);
bool set_ec(int ec);
#if defined(__GNUC__)
void e_exit(int ec) __attribute__((noreturn));
void e_exit(int ec) __attribute__((__noreturn__));
#else
void e_exit(int ec);
#endif
@ -455,26 +462,26 @@ void printClearLine(FILE *f = NULL);
void printErr(const char *iname, const Throwable *e);
void printUnhandledException(const char *iname, const std::exception *e);
#if defined(__GNUC__)
void __acc_cdecl printErr(const char *iname, const char *format, ...)
__attribute__((format(printf,2,3)));
void __acc_cdecl printWarn(const char *iname, const char *format, ...)
__attribute__((format(printf,2,3)));
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
__attribute__((__format__(printf,2,3)));
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
__attribute__((__format__(printf,2,3)));
#else
void __acc_cdecl printErr(const char *iname, const char *format, ...);
void __acc_cdecl printWarn(const char *iname, const char *format, ...);
void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
#endif
#if defined(__GNUC__)
void __acc_cdecl infoWarning(const char *format, ...)
__attribute__((format(printf,1,2)));
void __acc_cdecl infoHeader(const char *format, ...)
__attribute__((format(printf,1,2)));
void __acc_cdecl info(const char *format, ...)
__attribute__((format(printf,1,2)));
void __acc_cdecl_va infoWarning(const char *format, ...)
__attribute__((__format__(printf,1,2)));
void __acc_cdecl_va infoHeader(const char *format, ...)
__attribute__((__format__(printf,1,2)));
void __acc_cdecl_va info(const char *format, ...)
__attribute__((__format__(printf,1,2)));
#else
void __acc_cdecl infoWarning(const char *format, ...);
void __acc_cdecl infoHeader(const char *format, ...);
void __acc_cdecl info(const char *format, ...);
void __acc_cdecl_va infoWarning(const char *format, ...);
void __acc_cdecl_va infoHeader(const char *format, ...);
void __acc_cdecl_va info(const char *format, ...);
#endif
void infoHeader();
void infoWriting(const char *what, long size);

View File

@ -123,10 +123,10 @@ console_t;
#if defined(__GNUC__)
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...)
__attribute__((format(printf,2,3)));
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
__attribute__((__format__(printf,2,3)));
#else
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...);
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
#endif

View File

@ -94,7 +94,7 @@ static int exit_code = EXIT_OK;
**************************************************************************/
#if defined(__GNUC__)
static void do_exit(void) __attribute__((noreturn));
static void do_exit(void) __attribute__((__noreturn__));
#endif
static void do_exit(void)
{

View File

@ -130,7 +130,7 @@ void printErr(const char *iname, const Throwable *e)
}
void __acc_cdecl printErr(const char *iname, const char *format, ...)
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
{
va_list args;
char buf[1024];
@ -143,7 +143,7 @@ void __acc_cdecl printErr(const char *iname, const char *format, ...)
}
void __acc_cdecl printWarn(const char *iname, const char *format, ...)
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
{
va_list args;
char buf[1024];
@ -200,7 +200,7 @@ void infoHeader()
info_header = 0;
}
void __acc_cdecl infoHeader(const char *format, ...)
void __acc_cdecl_va infoHeader(const char *format, ...)
{
if (opt->info_mode <= 0)
return;
@ -214,7 +214,7 @@ void __acc_cdecl infoHeader(const char *format, ...)
}
void __acc_cdecl info(const char *format, ...)
void __acc_cdecl_va info(const char *format, ...)
{
if (opt->info_mode <= 0)
return;
@ -229,7 +229,7 @@ void __acc_cdecl info(const char *format, ...)
}
void __acc_cdecl infoWarning(const char *format, ...)
void __acc_cdecl_va infoWarning(const char *format, ...)
{
if (opt->info_mode <= 0)
{

View File

@ -801,7 +801,7 @@ int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_li
}
int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...)
int __acc_cdecl_va upx_snprintf(char *str, size_t count, const char *format,...)
{
va_list ap;
int ret;
@ -832,7 +832,7 @@ int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap)
}
int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...)
int __acc_cdecl_va upx_asprintf(char **ptr, const char *format, ...)
{
va_list ap;
int ret;

View File

@ -38,10 +38,10 @@ extern "C" {
//
**************************************************************************/
int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_list ap);
int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...);
int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap);
int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...);
int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_list ap);
int __acc_cdecl_va upx_snprintf(char *str, size_t count, const char *format,...);
int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap);
int __acc_cdecl_va upx_asprintf(char **ptr, const char *format, ...);
#if 1
# undef sprintf

View File

@ -41,7 +41,7 @@
// disable dynamic allocation of an object
**************************************************************************/
#if defined(new) || defined(delete) || defined(__EMX__)
#if defined(new) || defined(delete) || defined(__EMX__) || (ACC_CC_SYMANTECC)
// debug
# define DISABLE_NEW_DELETE private:
@ -89,7 +89,16 @@ private:
// exceptions & RTTI
**************************************************************************/
#if defined(__DMC__) && (__DMC__ < 0x834)
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
#include <stdcomp.h>
#undef RWSTD_MULTI_THREAD
#include <stdexcep.h>
#include <new.h>
#include <typeinfo.h>
namespace std { class bad_alloc { }; }
#elif (ACC_CC_DMC && (__DMC__ < 0x834))
#include <new.h>
#include <typeinfo.h>
@ -104,14 +113,21 @@ public:
};
}
#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x0530)
#elif (ACC_CC_SYMANTECC)
#include <stdcomp.h>
#undef RWSTD_MULTI_THREAD
#include <stdexcep.h>
#include <new.h>
#include <typeinfo.h>
namespace std { class bad_alloc { }; }
class exception
{
public:
exception() NOTHROW { }
virtual ~exception() NOTHROW { }
virtual const char* what() const NOTHROW { return "exception"; }
};
#define bool int
#define true 1
#define false 0
#else
@ -122,13 +138,16 @@ namespace std { class bad_alloc { }; }
#endif
#if defined(__BORLANDC__)
#if (ACC_CC_BORLANDC)
using namespace std;
#elif defined(__DMC__)
#elif (ACC_CC_DMC)
namespace std { class bad_alloc { }; }
#elif defined(__EMX__)
#define std
#elif defined(__WATCOMC__)
#elif (ACC_CC_SYMANTECC)
#define std
class bad_alloc { };
#elif (ACC_CC_WATCOMC)
#define std
class bad_alloc { };
#endif