1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Portability updates.

committer: mfx <mfx> 1054071025 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2003-05-27 21:30:25 +00:00
parent 757bdd1264
commit b2949259c5
13 changed files with 105 additions and 61 deletions

View File

@ -149,7 +149,7 @@ ifeq ($(DEBUG),0)
##LDFLAGS += -static
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
ifeq ($(arch),i386)
STUBIFY_EXE = perl $(srcdir)/stub/scripts/brandelf.pl $@
## STUBIFY_EXE = perl $(srcdir)/stub/scripts/brandelf.pl $@
endif
endif
CHMOD_EXE = chmod 755 $@
@ -158,7 +158,7 @@ endif # linux
###
### linux/i386 - Intel C++ 7.0
### linux/i386 - Intel C++ 7.x
###
ifeq ($(target),linux-intelc70)
@ -183,6 +183,30 @@ LDFLAGS += -Wl,-Map,$T.map
endif
###
### linux/i386 - Borland C++ 5.7 (Kylix 3)
###
ifeq ($(target),linux-bc57)
##DEPMODE := XXX_linux
CC = bc++ -q -3
CFLAGS = -w -w-aus -w-inl -w!
CFLAGS_OUTPUT = -o$@
LDFLAGS += -ls
LINK_EXE_OUTPUT = -e$@
ifeq ($(WITH_ZLIB),1)
LDLIBS += -lz
endif
ifeq ($(DEBUG),1)
CFLAGS += -Od -d
else
CFLAGS += -O2 -d
endif
# transform `-lxx -lyy' into `libxx.a libyy.a'
LDLIBS := $(shell echo "$(LDLIBS)" | perl -pe 's/-l(.*?)\b/lib\1.a/g')
endif
###
### Linux cross compilers
###
@ -297,14 +321,14 @@ endif
###
### win32 - Borland C++ 5.5.1
### win32 - Borland C++
###
ifeq ($(target),bc)
o = .obj
a = .lib
e = .exe
CC = bcc32 -q -3
CC = bcc32 -q -6
CFLAGS = -w -w-aus -w-inl -g1
CFLAGS_OUTPUT = -o$@
LDFLAGS = -ls
@ -326,7 +350,7 @@ endif # bc
###
### win32 - Digital Mars C++ 8.33
### win32 - Digital Mars C++
###
ifeq ($(target),dm)
@ -356,7 +380,7 @@ endif # dm
###
### win32 - Intel C++ 7.0
### win32 - Intel C++
###
ifeq ($(target),ic)
@ -390,7 +414,7 @@ endif # ic
###
### win32 - Visual C++ 6
### win32 - Visual C++
###
ifeq ($(target),vc)
@ -524,17 +548,6 @@ distclean: clean
maintainer-clean: distclean
untabify:
mfxtu -d4 -t *.ch *.cpp *.h
mfxtu -d8 -t stub/[ln]*.asm stub/*.ash stub/*.[cs]
tags TAGS:
ctags *.ch *.cpp *.h
ID:
mkid *.ch *.cpp *.h
# /***********************************************************************
# // rules
# ************************************************************************/
@ -545,11 +558,6 @@ ID:
%$o : %.cpp
$(strip $(CXX_COMPILE))
ifneq ($(strip $(OBJECTS2)),)
$(OBJECTS2): %$o : %.cpp
$(strip $(CXX_COMPILE))
endif
%.res : %.rc
rc -l 0x409 -fo$@ $<

View File

@ -339,18 +339,18 @@ inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; }
**************************************************************************/
// for use with qsort()
int be16_compare(const void *e1, const void *e2);
int be24_compare(const void *e1, const void *e2);
int be32_compare(const void *e1, const void *e2);
int le16_compare(const void *e1, const void *e2);
int le24_compare(const void *e1, const void *e2);
int le32_compare(const void *e1, const void *e2);
int be16_compare_signed(const void *e1, const void *e2);
int be24_compare_signed(const void *e1, const void *e2);
int be32_compare_signed(const void *e1, const void *e2);
int le16_compare_signed(const void *e1, const void *e2);
int le24_compare_signed(const void *e1, const void *e2);
int le32_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL be16_compare(const void *e1, const void *e2);
int __UPX_CDECL be24_compare(const void *e1, const void *e2);
int __UPX_CDECL be32_compare(const void *e1, const void *e2);
int __UPX_CDECL le16_compare(const void *e1, const void *e2);
int __UPX_CDECL le24_compare(const void *e1, const void *e2);
int __UPX_CDECL le32_compare(const void *e1, const void *e2);
int __UPX_CDECL be16_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL be24_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL be32_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL le16_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL le24_compare_signed(const void *e1, const void *e2);
int __UPX_CDECL le32_compare_signed(const void *e1, const void *e2);
// just for testing...

View File

@ -88,7 +88,7 @@ static screen_t *do_construct(screen_t *s, int fd)
static screen_t *screen = NULL;
static void do_destroy(void)
static void __UPX_CDECL do_destroy(void)
{
if (screen)
{

View File

@ -41,6 +41,9 @@
#endif
#include "acc/acc.h"
#include "acc/acc_ince.h"
#if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
# error "something pulled in <windows.h>"
#endif
#if defined(__BORLANDC__)
@ -77,6 +80,7 @@
# endif
# define __UPX_CDECL __cdecl
# define SIGTYPEENTRY __cdecl
# pragma warning(disable: 4096) // __cdecl + '...'
# 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
@ -86,12 +90,15 @@
# if (__WATCOMC__ < 1100)
# error "need Watcom C++ 11.0c or newer"
# endif
# define __UPX_CDECL __cdecl
# if defined(__cplusplus)
# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality)
# endif
#endif
#if !defined(__UPX_CDECL)
# define __UPX_CDECL
#endif
/*************************************************************************
//

View File

@ -1034,7 +1034,7 @@ void upx_sanity_check(void)
COMPILE_TIME_ASSERT(sizeof(LE16) == 2);
COMPILE_TIME_ASSERT(sizeof(LE32) == 4);
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#if defined(__GNUC__) || (ACC_CC_INTELC >= 700)
COMPILE_TIME_ASSERT(__alignof__(BE16) == 1);
COMPILE_TIME_ASSERT(__alignof__(BE32) == 1);
COMPILE_TIME_ASSERT(__alignof__(LE16) == 1);
@ -1118,7 +1118,7 @@ void upx_sanity_check(void)
#if !defined(WITH_GUI)
int main(int argc, char *argv[])
int __UPX_CDECL main(int argc, char *argv[])
{
int i;
static char default_argv0[] = "upx";

View File

@ -116,8 +116,16 @@ void printErr(const char *iname, const Throwable *e)
if (l < sizeof(buf) && e->getMsg())
upx_snprintf(buf+l, sizeof(buf)-l, ": %s", e->getMsg());
l = strlen(buf);
if (l < sizeof(buf) && e->getErrno())
if (l < sizeof(buf) && e->getErrno()) {
upx_snprintf(buf+l, sizeof(buf)-l, ": %s", strerror(e->getErrno()));
#if 1
// some compilers (e.g. Borland C++) put a trailing '\n'
// into strerror() result
l = strlen(buf);
while (l-- > 0 && (buf[l] == '\n' || buf[l] == ' '))
buf[l] = 0;
#endif
}
pr_error(iname,buf,e->isWarning());
}

View File

@ -63,7 +63,7 @@ static const
#if defined(__BORLANDC__)
# undef strcpy
# define strcpy(a,b) std::strcpy((char *)(a),(const char *)(b))
# define strcpy(a,b) strcpy((char *)(a),(const char *)(b))
#endif

View File

@ -42,10 +42,12 @@
// direct screen access
**************************************************************************/
#if defined(_MSC_VER) && (_MSC_VER < 1200)
# pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union
#if (ACC_CC_MSC && _MSC_VER >= 1000 && _MSC_VER < 1200)
/* avoid -W4 warnings in <conio.h> */
# pragma warning(disable: 4032)
/* avoid -W4 warnings in <windows.h> */
# pragma warning(disable: 4201 4214 4514)
#endif
#if defined(__RSXNT__)
# define timeval win32_timeval /* struct timeval already in <sys/time.h> */
#endif

View File

@ -795,13 +795,13 @@ static int xdopr(char *buffer, size_t maxlen, const char *format, va_list args)
}
int upx_vsnprintf(char *str, size_t count, const char *format, va_list ap)
int __UPX_CDECL upx_vsnprintf(char *str, size_t count, const char *format, va_list ap)
{
return xdopr(str, count, format, ap);
}
int upx_snprintf(char *str, size_t count, const char *format,...)
int __UPX_CDECL upx_snprintf(char *str, size_t count, const char *format,...)
{
va_list ap;
int ret;
@ -813,7 +813,7 @@ int upx_snprintf(char *str, size_t count, const char *format,...)
}
int upx_vasprintf(char **ptr, const char *format, va_list ap)
int __UPX_CDECL upx_vasprintf(char **ptr, const char *format, va_list ap)
{
int ret;
@ -832,7 +832,7 @@ int upx_vasprintf(char **ptr, const char *format, va_list ap)
}
int upx_asprintf(char **ptr, const char *format, ...)
int __UPX_CDECL upx_asprintf(char **ptr, const char *format, ...)
{
va_list ap;
int ret;

View File

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

View File

@ -31,6 +31,17 @@
#include "stdcxx.h"
#if 0
#undef _Nomemory
namespace std {
void __cdecl _Nomemory() {
static const bad_alloc ba;
throw ba;
}
}
#endif
#ifdef WANT_STL
#if defined(__GNUC__)

View File

@ -114,7 +114,9 @@ class bad_alloc { };
#endif
#if defined(__EMX__)
#if defined(__BORLANDC__)
using namespace std;
#elif defined(__EMX__)
#define std
#elif defined(__WATCOMC__)
#define std

View File

@ -29,6 +29,12 @@
#include "conf.h"
#include "util.h"
#if (ACC_CC_MSC && _MSC_VER >= 1000 && _MSC_VER < 1200)
/* avoid -W4 warnings in <conio.h> */
# pragma warning(disable: 4032)
/* avoid -W4 warnings in <windows.h> */
# pragma warning(disable: 4201 4214 4514)
#endif
#include "acc/acc_lib.ch"
@ -36,28 +42,28 @@
// qsort() util
**************************************************************************/
int be16_compare(const void *e1, const void *e2)
int __UPX_CDECL be16_compare(const void *e1, const void *e2)
{
const unsigned d1 = get_be16(e1);
const unsigned d2 = get_be16(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int be32_compare(const void *e1, const void *e2)
int __UPX_CDECL be32_compare(const void *e1, const void *e2)
{
const unsigned d1 = get_be32(e1);
const unsigned d2 = get_be32(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int le16_compare(const void *e1, const void *e2)
int __UPX_CDECL le16_compare(const void *e1, const void *e2)
{
const unsigned d1 = get_le16(e1);
const unsigned d2 = get_le16(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int le32_compare(const void *e1, const void *e2)
int __UPX_CDECL le32_compare(const void *e1, const void *e2)
{
const unsigned d1 = get_le32(e1);
const unsigned d2 = get_le32(e2);
@ -65,28 +71,28 @@ int le32_compare(const void *e1, const void *e2)
}
int be16_compare_signed(const void *e1, const void *e2)
int __UPX_CDECL be16_compare_signed(const void *e1, const void *e2)
{
const int d1 = get_be16_signed(e1);
const int d2 = get_be16_signed(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int be32_compare_signed(const void *e1, const void *e2)
int __UPX_CDECL be32_compare_signed(const void *e1, const void *e2)
{
const int d1 = get_be32_signed(e1);
const int d2 = get_be32_signed(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int le16_compare_signed(const void *e1, const void *e2)
int __UPX_CDECL le16_compare_signed(const void *e1, const void *e2)
{
const int d1 = get_le16_signed(e1);
const int d2 = get_le16_signed(e2);
return (d1 < d2) ? -1 : ((d1 > d2) ? 1 : 0);
}
int le32_compare_signed(const void *e1, const void *e2)
int __UPX_CDECL le32_compare_signed(const void *e1, const void *e2)
{
const int d1 = get_le32_signed(e1);
const int d2 = get_le32_signed(e2);