Remove some old cruft.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-09-20 11:24:18 +02:00
parent e4723e0bad
commit d71db2978e
4 changed files with 10 additions and 160 deletions

View File

@ -66,8 +66,7 @@ Prerequisites
Tools needed to build/modify the UPX sources
--------------------------------------------
- A C++ compiler supporting inner classes, templates, exceptions
and RTTI.
- A C++ compiler: gcc >= 3.3 or clang.
- GNU make 3.81 or better

View File

@ -36,25 +36,11 @@
// ACC
**************************************************************************/
#if (defined(_WIN32) || defined(_WIN64)) && defined(_MSC_VER)
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
#ifndef _CRT_NONSTDC_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS 1
#endif
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include "miniacc.h"
#if !(ACC_CC_CLANG || ACC_CC_GNUC)
# error "only clang and gcc are officially supported"
#endif
#include "miniacc.h"
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
# undef HAVE_UTIME_H /* this pulls in <windows.h> */
#endif
// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages)
#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(_WIN32)
# undef HAVE_CHMOD
@ -64,80 +50,6 @@
#endif
// pragmas
#if (ACC_CC_BORLANDC)
# if (__BORLANDC__ < 0x0500)
# error "need Borland C++ 5.0 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 produce 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
# endif
# if (__BORLANDC__ >= 0x0530 && __BORLANDC__ < 0x0560)
# pragma warn -osh // 8055: Possible overflow in shift operation
# endif
# if (__BORLANDC__ >= 0x0560)
# pragma warn -use // 8080: 'x' is declared but never used
# endif
#elif (ACC_CC_DMC)
# if (__DMC__ < 0x829)
# error "need Digital Mars C++ 8.29 or newer"
# endif
#elif (ACC_CC_INTELC)
# if (__INTEL_COMPILER < 450)
# error "need Intel C++ 4.5 or newer"
# endif
# if (ACC_OS_WIN32 || ACC_OS_WIN64)
# elif defined(__linux__)
# pragma warning(error: 424) // #424: extra ";" ignored
//# pragma warning(disable: 128) // #128: loop is not reachable from preceding code
//# pragma warning(disable: 181) // #181: argument is incompatible with corresponding format string conversion
# pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier
# pragma warning(disable: 810) // #810: conversion from "A" to "B" may lose significant bits
# pragma warning(disable: 981) // #981: operands are evaluated in unspecified order
# pragma warning(disable: 1418) // #1418: external function definition with no prior declaration
//# pragma warning(disable: 1419) // #1419: external declaration in primary source file
# else
# error "untested platform"
# endif
#elif (ACC_CC_MSC)
# if (_MSC_VER < 1100)
# error "need Visual C++ 5.0 or newer"
# endif
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
# pragma warning(error: 4138) // Wx: '*/' found outside of comment
# 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: 4710) // W4: 'function': function not inlined
# if (_MSC_VER >= 1300)
# pragma warning(disable: 4625) // W4: 'class' : copy constructor could not be generated because a base class copy constructor is inaccessible
# pragma warning(disable: 4626) // W4: 'class' : assignment operator could not be generated because a base class assignment operator is inaccessible
# pragma warning(disable: 4711) // W4: 'function' selected for automatic inline expansion
# pragma warning(disable: 4820) // W4: 'struct' : 'x' bytes padding added after member 'member'
# endif
# if (_MSC_VER >= 1400)
# pragma warning(disable: 4996) // W1: 'function': was declared deprecated
# endif
#elif (ACC_CC_SUNPROC)
//# pragma error_messages(off,"badargtype2w") // FIXME
#elif (ACC_CC_WATCOMC)
# if (__WATCOMC__ < 1280)
# error "need Open Watcom C++ 1.8 or newer" // because earlier versions do not support nested classes
# endif
# if defined(__cplusplus)
# pragma warning 367 9 // w3: conditional expression in if statement is always true
# pragma warning 368 9 // w3: conditional expression in if statement is always false
# pragma warning 389 9 // w3: integral value may be truncated
# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality)
# endif
#endif
#define ACC_WANT_ACC_INCD_H 1
#define ACC_WANT_ACC_INCE_H 1
#define ACC_WANT_ACC_LIB_H 1
@ -184,12 +96,6 @@ typedef acc_uintptr_t upx_uintptr_t;
#undef linux
#undef small
#undef tos
#if (ACC_CC_DMC)
# undef tell
#endif
#if !(ACC_CC_PGI)
# undef unix
#endif
#if defined(__DJGPP__)
# undef sopen
# undef __unix__
@ -375,35 +281,17 @@ typedef acc_uintptr_t upx_uintptr_t;
#define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0])))
#if 0
#define ALIGN_DOWN(a,b) (((a) / (b)) * (b))
#define ALIGN_UP(a,b) ALIGN_DOWN((a) + ((b) - 1), b)
#define ALIGN_GAP(a,b) (ALIGN_UP(a,b) - (a))
#elif 1
template <class T>
inline T ALIGN_DOWN(const T& a, const T& b) { T r; r = (a / b) * b; return r; }
template <class T>
inline T ALIGN_UP (const T& a, const T& b) { T r; r = ((a + b - 1) / b) * b; return r; }
template <class T>
inline T ALIGN_GAP (const T& a, const T& b) { T r; r = ALIGN_UP(a, b) - a; return r; }
#else
inline unsigned ALIGN_DOWN(unsigned a, unsigned b) { return (a / b) * b; }
inline unsigned ALIGN_UP (unsigned a, unsigned b) { return ((a + b - 1) / b) * b; }
inline unsigned ALIGN_GAP (unsigned a, unsigned b) { return ALIGN_UP(a, b) - a; }
#endif
#if 0
#define UPX_MAX(a,b) ((a) >= (b) ? (a) : (b))
#define UPX_MIN(a,b) ((a) <= (b) ? (a) : (b))
#elif 1
template <class T>
inline const T& UPX_MAX(const T& a, const T& b) { if (a < b) return b; return a; }
template <class T>
inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b; }
#else
inline unsigned UPX_MAX(unsigned a, unsigned b) { return a < b ? b : a; }
inline unsigned UPX_MIN(unsigned a, unsigned b) { return a < b ? a : b; }
#endif
// An Array allocates memory on the heap, but automatically
@ -415,7 +303,7 @@ inline unsigned UPX_MIN(unsigned a, unsigned b) { return a < b ? a : b; }
#define ByteArray(var, size) Array(unsigned char, var, size)
struct noncopyable
class noncopyable
{
protected:
inline noncopyable() {}
@ -567,13 +455,7 @@ private:
**************************************************************************/
struct upx_callback_t;
#define upx_callback_p upx_callback_t *
#if 0
typedef void* (__acc_cdecl *upx_alloc_func_t)
(upx_callback_p self, unsigned items, unsigned size);
typedef void (__acc_cdecl *upx_free_func_t)
(upx_callback_p self, void* ptr);
#endif
typedef upx_callback_t *upx_callback_p;
typedef void (__acc_cdecl *upx_progress_func_t)
(upx_callback_p, unsigned, unsigned);
@ -609,15 +491,6 @@ struct OptVar
assertValue();
return *this;
}
#if 0
#error
// there is too much implicit magic in this copy operator;
// better introduce an explicit "oassign" function.
OptVar& operator= (const OptVar& other) {
if (other.is_set) { v = other.v; is_set += 1; }
assertValue(); return *this;
}
#endif
void reset() { v = default_value; is_set = 0; }
operator T () const { return v; }
@ -631,15 +504,9 @@ struct OptVar
template <class T> inline void oassign(T& self, const T& other) {
if (other.is_set) { self.v = other.v; self.is_set += 1; }
}
#if 0
template <class V, class T> inline void oassign(V& v, const T& other) {
if (other.is_set) { v = other.v; }
}
#else
template <class T> inline void oassign(unsigned& v, const T& other) {
if (other.is_set) { v = other.v; }
}
#endif
struct lzma_compress_config_t
@ -770,7 +637,7 @@ typedef ElfLinker Linker;
// main.cpp
extern const char *progname;
bool set_ec(int ec);
bool set_exit_code(int ec);
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void e_exit(int ec) __attribute__((__noreturn__));
#else

View File

@ -158,7 +158,7 @@ static bool set_eec(int ec, int *eec)
return 0;
}
bool set_ec(int ec)
bool set_exit_code(int ec)
{
return set_eec(ec,&exit_code);
}
@ -166,7 +166,7 @@ bool set_ec(int ec)
void e_exit(int ec)
{
(void) set_ec(ec);
(void) set_exit_code(ec);
do_exit();
}
@ -469,7 +469,6 @@ done:
return r;
}
#if 1 && (ACC_CC_GNUC >= 0x030300)
template <class T, T default_value, T min_value, T max_value>
int getoptvar(OptVar<T,default_value,min_value,max_value> *var, const char *arg_fatal)
{
@ -479,17 +478,6 @@ int getoptvar(OptVar<T,default_value,min_value,max_value> *var, const char *arg_
*var = v;
return r;
}
#else
template <class T>
int getoptvar(T *var, const char *arg_fatal)
{
typename T::Type v = T::default_value_c;
int r = getoptvar(&v, T::min_value_c, T::max_value_c, arg_fatal);
if (r == 0)
*var = v;
return r;
}
#endif
static int do_option(int optc, const char *arg)
@ -1289,13 +1277,9 @@ static bool test(void)
COMPILE_TIME_ASSERT_ALIGNED1(test2_t)
COMPILE_TIME_ASSERT(sizeof(t2) == 7 + 21*sizeof(T))
#if defined(__acc_alignof)
#if (ACC_CC_CLANG && ACC_ARCH_AMD64)
// CBUG: clang-2.8 bug in 64-bit mode
#else
COMPILE_TIME_ASSERT(__acc_alignof(t1) == 1)
COMPILE_TIME_ASSERT(__acc_alignof(t2) == 1)
#endif
#endif
#if 1 && (ACC_CC_WATCOMC)
test1_t t11; COMPILE_TIME_ASSERT(sizeof(t11.a) <= sizeof(t11.b))
test2_t t22; COMPILE_TIME_ASSERT(sizeof(t22.a) <= sizeof(t22.b))

View File

@ -298,7 +298,7 @@ void do_files(int i, int argc, char *argv[])
unlink_ofile(oname);
if (opt->verbose >= 1 || (opt->verbose >= 0 && !e.isWarning()))
printErr(iname,&e);
set_ec(e.isWarning() ? EXIT_WARN : EXIT_ERROR);
set_exit_code(e.isWarning() ? EXIT_WARN : EXIT_ERROR);
} catch (const Error &e) {
unlink_ofile(oname);
printErr(iname,&e);