committer: mfx <mfx> 1050612607 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2003-04-17 20:50:07 +00:00
parent 390cdbba2d
commit 5c7bca5b3e
20 changed files with 80 additions and 162 deletions

View File

@ -284,6 +284,17 @@ CXX = i586-mingw32msvc-g++
CCARCH += -march=i386 -mcpu=i686 CCARCH += -march=i386 -mcpu=i686
endif endif
# rsxnt (g++ 2.8.1)
ifeq ($(target),rsxnt)
include $(srcdir)/Makedefs.gcc
e = .exe
CXX = gcc
CFLAGS_O = -O0
CCARCH += -Zwin32 -Zsys -mno-probe
LDFLAGS = -s
STUBEDIT_EXE = pestack -s1024 -c1024 $@
endif
### ###
### win32 - Borland C++ 5.5.1 ### win32 - Borland C++ 5.5.1

View File

@ -7,6 +7,7 @@
# `make target=cygwin' # win32 - cygwin 1.3.x # `make target=cygwin' # win32 - cygwin 1.3.x
# `make target=mingw32' # win32 - mingw32 # `make target=mingw32' # win32 - mingw32
# `make target=no-cygwin' # win32 - mingw32 as included in cygwin 1.3.x # `make target=no-cygwin' # win32 - mingw32 as included in cygwin 1.3.x
# `make target=rsxnt' # win32 - rsxnt
# `make target=bc' # win32 - Borland C++ 5.5.1 # `make target=bc' # win32 - Borland C++ 5.5.1
# `make target=dm' # win32 - Digital Mars C++ 8.33 # `make target=dm' # win32 - Digital Mars C++ 8.33
# `make target=ic' # win32 - Intel C++ 7.0 # `make target=ic' # win32 - Intel C++ 7.0

View File

@ -354,13 +354,11 @@ int le32_compare_signed(const void *e1, const void *e2);
// just for testing... // just for testing...
#if 0 && defined(__GNUC_VERSION_HEX__) && (ACC_ARCH_IA32) #if (1 && ACC_ARCH_IA32 && ACC_CC_GNUC >= 0x030200)
# if (__GNUC_VERSION_HEX__ >= 0x030200)
typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1))); typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1)));
typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1))); typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1)));
# define LE16 LE16_unaligned # define LE16 LE16_unaligned
# define LE32 LE32_unaligned # define LE32 LE32_unaligned
# endif
#endif #endif

View File

@ -81,7 +81,7 @@ static int do_init(FILE *f)
if (opt->console == CON_NONE || opt->to_stdout) if (opt->console == CON_NONE || opt->to_stdout)
return con_mode; return con_mode;
try_init(&console_file,f); try_init(&console_file,f);
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO)) if (!acc_isatty(STDIN_FILENO) || !acc_isatty(STDOUT_FILENO) || !acc_isatty(STDERR_FILENO))
return con_mode; return con_mode;
#if defined(USE_ANSI) #if defined(USE_ANSI)

View File

@ -130,7 +130,7 @@ static int init(FILE *f, int o, int now)
if (!screen) if (!screen)
screen = do_construct(screen_djgpp2_construct(),fd); screen = do_construct(screen_djgpp2_construct(),fd);
#endif #endif
#if (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) #if defined(USE_SCREEN_WIN32)
if (!screen) if (!screen)
screen = do_construct(screen_win32_construct(),fd); screen = do_construct(screen_win32_construct(),fd);
#endif #endif

View File

@ -36,14 +36,11 @@
// ACC // ACC
**************************************************************************/ **************************************************************************/
#if 0 && defined(__EMX__)
# include <sys/emx.h>
#endif
#if 0 && defined(UPX_CONFIG_HEADER) #if 0 && defined(UPX_CONFIG_HEADER)
# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER # define ACC_CONFIG_HEADER UPX_CONFIG_HEADER
#endif #endif
#include "acc/acc.h" #include "acc/acc.h"
#include "acc/acc_ince.h"
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@ -102,18 +99,15 @@
// upx_int64l is int_least64_t in <stdint.h> terminology // upx_int64l is int_least64_t in <stdint.h> terminology
#if !defined(upx_int64l) #if !defined(upx_int64l)
# if defined(HAVE_STDINT_H) # if (SIZEOF_LONG >= 8)
# define upx_int64l int_least64_t
# define upx_uint64l uint_least64_t
# elif (ULONG_MAX > 0xffffffffL)
# define upx_int64l long int # define upx_int64l long int
# define upx_uint64l unsigned long int # define upx_uint64l unsigned long int
# elif defined(__GNUC__) || defined(__DMC__) # elif (SIZEOF_LONG_LONG >= 8)
# define upx_int64l long long int # define upx_int64l acc_llong_t
# define upx_uint64l unsigned long long int # define upx_uint64l acc_ullong_t
# elif defined(__BORLANDC__) || defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__WATCOMC__) # elif (SIZEOF___INT64 >= 8)
# define upx_int64l __int64 # define upx_int64l acc_int64_t
# define upx_uint64l unsigned __int64 # define upx_uint64l acc_uint64_t
# else # else
# error "need a 64-bit integer type" # error "need a 64-bit integer type"
# endif # endif
@ -130,6 +124,10 @@
#undef small #undef small
#undef tos #undef tos
#undef unix #undef unix
#if defined(__DJGPP__)
#undef __unix__
#undef __unix
#endif
#if !defined(WITH_UCL) #if !defined(WITH_UCL)
@ -174,46 +172,6 @@
// system includes // system includes
**************************************************************************/ **************************************************************************/
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#if defined(HAVE_ERRNO_H)
# include <errno.h>
#endif
#if defined(HAVE_FCNTL_H)
# include <fcntl.h>
#endif
#if defined(HAVE_IO_H)
# include <io.h>
#endif
#if defined(HAVE_DOS_H)
# include <dos.h>
#endif
#if defined(HAVE_MALLOC_H)
# include <malloc.h>
#endif
#if defined(HAVE_ALLOCA_H)
# include <alloca.h>
#endif
#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
#if defined(TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
#else
# include <time.h>
#endif
#if defined(HAVE_UTIME_H)
# include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
# include <sys/utime.h>
#endif
#if defined(HAVE_SHARE_H)
# include <share.h>
#endif
// malloc debuggers // malloc debuggers
#if defined(WITH_VALGRIND) #if defined(WITH_VALGRIND)
# include <valgrind.h> # include <valgrind.h>
@ -254,18 +212,6 @@
// portab // portab
**************************************************************************/ **************************************************************************/
#if defined(__GNUC__) && !defined(__GNUC_VERSION_HEX__)
# if !defined(__GNUC_MINOR__)
# error
# endif
# if !defined(__GNUC_PATCHLEVEL__)
# define __GNUC_PATCHLEVEL__ 0
# endif
# define __GNUC_VERSION_HEX__ \
(__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
#endif
#if !defined(PATH_MAX) #if !defined(PATH_MAX)
# define PATH_MAX 512 # define PATH_MAX 512
#elif (PATH_MAX < 512) #elif (PATH_MAX < 512)
@ -406,13 +352,6 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
// file io // file io
**************************************************************************/ **************************************************************************/
#if defined(HAVE_SETMODE)
# if !defined(O_BINARY)
# error "setmode without O_BINARY"
# endif
# define USE_SETMODE 1
#endif
#if !defined(O_BINARY) #if !defined(O_BINARY)
# define O_BINARY 0 # define O_BINARY 0
#endif #endif
@ -420,10 +359,8 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
#if defined(__DMC__) #if defined(__DMC__)
# undef tell # undef tell
#endif #endif
#if defined(__DJGPP__) #if defined(__DJGPP__)
# undef sopen # undef sopen
# undef USE_SETMODE
#endif #endif
#ifndef OPTIONS_VAR #ifndef OPTIONS_VAR

View File

@ -34,8 +34,9 @@
#undef USE_CONSOLE #undef USE_CONSOLE
#undef USE_ANSI #undef USE_ANSI
#undef USE_SCREEN #undef USE_SCREEN
#undef USE_SCREEN_VCSA
#undef USE_SCREEN_CURSES #undef USE_SCREEN_CURSES
#undef USE_SCREEN_VCSA
#undef USE_SCREEN_WIN32
#undef USE_FRAMES #undef USE_FRAMES
#if defined(WITH_GUI) && !defined(NO_CONSOLE) #if defined(WITH_GUI) && !defined(NO_CONSOLE)
@ -57,9 +58,12 @@
#if 1 && defined(__DJGPP__) #if 1 && defined(__DJGPP__)
# define USE_SCREEN # define USE_SCREEN
#endif #elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
#if 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
# define USE_SCREEN # define USE_SCREEN
# define USE_SCREEN_WIN32
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
# define USE_SCREEN
# define USE_SCREEN_WIN32
#endif #endif

View File

@ -46,7 +46,7 @@ void File::chmod(const char *name, int mode)
void File::rename(const char *old_, const char *new_) void File::rename(const char *old_, const char *new_)
{ {
#if 1 && defined(__DJGPP__) #if defined(__DJGPP__)
if (::_rename(old_,new_) != 0) if (::_rename(old_,new_) != 0)
#else #else
if (::rename(old_,new_) != 0) if (::rename(old_,new_) != 0)
@ -135,7 +135,7 @@ int FileBase::read(void *buf, int len)
return 0; return 0;
for (;;) for (;;)
{ {
#if 1 && defined(__DJGPP__) #if defined(__DJGPP__)
l = ::_read(_fd, buf, len); l = ::_read(_fd, buf, len);
#else #else
l = ::read(_fd, buf, len); l = ::read(_fd, buf, len);
@ -172,7 +172,7 @@ void FileBase::write(const void *buf, int len)
return; return;
for (;;) for (;;)
{ {
#if 1 && defined(__DJGPP__) #if defined(__DJGPP__)
l = ::_write(_fd,buf,len); l = ::_write(_fd,buf,len);
#else #else
l = ::write(_fd,buf,len); l = ::write(_fd,buf,len);
@ -337,29 +337,16 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
bool OutputFile::openStdout(int flags, bool force) bool OutputFile::openStdout(int flags, bool force)
{ {
close(); close();
if (!force) int fd = STDOUT_FILENO;
{ if (!force && acc_isatty(fd))
if (!isafile(STDOUT_FILENO)) return false;
return false;
}
_fd = STDOUT_FILENO;
_name = "<stdout>"; _name = "<stdout>";
_flags = flags; _flags = flags;
_shflags = -1; _shflags = -1;
_mode = 0; _mode = 0;
if (flags != 0) if (flags && acc_set_binmode(fd, 1) == -1)
{ throwIOException(_name, errno);
assert(flags == O_BINARY); _fd = fd;
#if defined(__MINT__)
__set_binmode(stdout, 1);
#elif defined(HAVE_SETMODE) && defined(USE_SETMODE)
if (setmode(_fd, O_BINARY) == -1)
throwIOException(_name,errno);
#if defined(__DJGPP__)
__djgpp_set_ctrl_c(1);
#endif
#endif
}
return true; return true;
} }

View File

@ -326,8 +326,8 @@ void show_version(int x)
FILE *f = stdout; FILE *f = stdout;
UNUSED(x); UNUSED(x);
#if 0 && defined(__GNUC__) #if (0 && ACC_CC_GNUC)
fprintf(f,"upx %s (gcc 0x%lx)\n", UPX_VERSION_STRING, __GNUC_VERSION_HEX__); fprintf(f,"upx %s (gcc 0x%06lx)\n", UPX_VERSION_STRING, ACC_CC_GNUC);
#else #else
fprintf(f,"upx %s\n", UPX_VERSION_STRING); fprintf(f,"upx %s\n", UPX_VERSION_STRING);
#endif #endif

View File

@ -56,7 +56,9 @@ void init_options(struct options_t *o)
o->overlay = -1; o->overlay = -1;
o->console = CON_FILE; o->console = CON_FILE;
#if (ACC_OS_CYGWIN || ACC_OS_DOS32 || ACC_OS_WIN32 || ACC_OS_WIN64) #if defined(__DJGPP__)
o->console = CON_INIT;
#elif defined(USE_SCREEN_WIN32)
o->console = CON_INIT; o->console = CON_INIT;
#elif 1 && defined(__linux__) #elif 1 && defined(__linux__)
o->console = CON_INIT; o->console = CON_INIT;
@ -278,7 +280,7 @@ static void set_term(FILE *f)
if (f) if (f)
con_term = f; con_term = f;
else else
con_term = isafile(STDIN_FILENO) ? stderr : stdout; con_term = acc_isatty(STDIN_FILENO) ? stderr : stdout;
} }

View File

@ -88,7 +88,7 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
// This hack is needed, otherwise error messages may get lost // This hack is needed, otherwise error messages may get lost
// when the cursor is not yet at the bottom of the screen. // when the cursor is not yet at the bottom of the screen.
// At least I can use some colors then... // At least I can use some colors then...
bool c = isatty(STDERR_FILENO) ? 1 : 0; bool c = acc_isatty(STDERR_FILENO) ? 1 : 0;
int fg = con_fg(stderr,FG_BRTRED); int fg = con_fg(stderr,FG_BRTRED);
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname); upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname);

View File

@ -437,8 +437,8 @@ void PackExe::pack(OutputFile *fo)
// set oh.min & oh.max // set oh.min & oh.max
ic = ih.min*16 + ih_imagesize; ic = ih.min*16 + ih_imagesize;
if (ic < oh.ss*16 + oh.sp) if (ic < oh.ss*16u + oh.sp)
ic = oh.ss*16 + oh.sp; ic = oh.ss*16u + oh.sp;
oh.min = (ic - (packedsize + lsize)) / 16; oh.min = (ic - (packedsize + lsize)) / 16;
ic = oh.min + (ih.max - ih.min); ic = oh.min + (ih.max - ih.min);
oh.max = ic < 0xffff && ih.max != 0xffff ? ic : 0xffff; oh.max = ic < 0xffff && ih.max != 0xffff ? ic : 0xffff;

View File

@ -309,7 +309,7 @@ static int init(screen_t *this, int fd)
this->data->sb_base = 0; this->data->sb_base = 0;
this->data->sb_sp = 0; this->data->sb_sp = 0;
#endif #endif
if (fd < 0 || !isatty(fd)) if (fd < 0 || !acc_isatty(fd))
return -1; return -1;
if (getPage(this) != 0) if (getPage(this) != 0)
return -1; return -1;

View File

@ -316,7 +316,7 @@ static int init(screen_t *this, int fd)
this->data->sb_base = 0; this->data->sb_base = 0;
this->data->sb_sp = 0; this->data->sb_sp = 0;
#endif #endif
if (fd < 0 || !isatty(fd)) if (fd < 0 || !acc_isatty(fd))
return -1; return -1;
if (fstat(fd,&st) != 0) if (fstat(fd,&st) != 0)
return -1; return -1;

View File

@ -28,7 +28,7 @@
#include "conf.h" #include "conf.h"
#if defined(USE_SCREEN) && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) #if defined(USE_SCREEN_WIN32)
#include "screen.h" #include "screen.h"
@ -46,6 +46,9 @@
# pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union # pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union
#endif #endif
#if defined(__RSXNT__)
# define timeval win32_timeval /* struct timeval already in <sys/time.h> */
#endif
#include <windows.h> #include <windows.h>
#if defined(HAVE_CONIO_H) #if defined(HAVE_CONIO_H)
# include <conio.h> # include <conio.h>
@ -289,7 +292,7 @@ static int init(screen_t *this, int fd)
this->data->hi = INVALID_HANDLE_VALUE; this->data->hi = INVALID_HANDLE_VALUE;
this->data->ho = INVALID_HANDLE_VALUE; this->data->ho = INVALID_HANDLE_VALUE;
this->data->mode = -1; this->data->mode = -1;
if (fd < 0 || !isatty(fd)) if (fd < 0 || !acc_isatty(fd))
return -1; return -1;
hi = GetStdHandle(STD_INPUT_HANDLE); hi = GetStdHandle(STD_INPUT_HANDLE);
@ -443,15 +446,16 @@ static int getScrollCounter(const screen_t *this)
static int s_kbhit(screen_t *this) static int s_kbhit(screen_t *this)
{ {
#if defined(HAVE_CONIO_H)
UNUSED(this); UNUSED(this);
# if defined(__BORLANDC__) || defined(__WATCOMC__) #if defined(HAVE_CONIO_H)
# if defined(__RSXNT__)
return 0;
# elif defined(__BORLANDC__) || defined(__WATCOMC__)
return kbhit(); return kbhit();
# else # else
return _kbhit(); return _kbhit();
# endif # endif
#else #else
UNUSED(this);
return 0; return 0;
#endif #endif
} }

View File

@ -41,7 +41,7 @@
// disable dynamic allocation of an object // disable dynamic allocation of an object
**************************************************************************/ **************************************************************************/
#if defined(new) || defined(delete) #if defined(new) || defined(delete) || defined(__EMX__)
// debug // debug
# define DISABLE_NEW_DELETE private: # define DISABLE_NEW_DELETE private:
@ -102,36 +102,26 @@ public:
virtual ~exception() NOTHROW { } virtual ~exception() NOTHROW { }
virtual const char* what() const NOTHROW { return "exception"; } virtual const char* what() const NOTHROW { return "exception"; }
}; };
class bad_alloc : public exception
{
public:
bad_alloc() NOTHROW { }
virtual ~bad_alloc() NOTHROW { }
virtual const char* what() const NOTHROW { return "bad_alloc"; }
};
};
#elif defined(__WATCOMC__)
#define std
#include <exception>
//#include <stdexcept>
#include <new>
#include <typeinfo>
class bad_alloc { }; class bad_alloc { };
};
#else #else
#include <exception> #include <exception>
//#include <stdexcept>
#include <new> #include <new>
#include <typeinfo> #include <typeinfo>
#endif #endif
#if defined(__EMX__)
#define std
#elif defined(__WATCOMC__)
#define std
class bad_alloc { };
#endif
/************************************************************************* /*************************************************************************
// STL // STL
**************************************************************************/ **************************************************************************/

View File

@ -109,7 +109,9 @@ static char progress_filler[] = ".*[]";
static void init_global_constants(void) static void init_global_constants(void)
{ {
#ifdef __MSDOS__ #if 0 && (ACC_OS_DOS16 || ACC_OS_DOS32)
// FIXME: should test codepage here
static bool done = false; static bool done = false;
if (done) if (done)
return; return;
@ -193,7 +195,7 @@ UiPacker::UiPacker(const Packer *p_) :
if (opt->verbose < 0) if (opt->verbose < 0)
s->mode = M_QUIET; s->mode = M_QUIET;
else if (opt->verbose == 0 || !isatty(STDOUT_FILENO)) else if (opt->verbose == 0 || !acc_isatty(STDOUT_FILENO))
s->mode = M_INFO; s->mode = M_INFO;
else if (opt->verbose == 1 || opt->no_progress) else if (opt->verbose == 1 || opt->no_progress)
s->mode = M_MSG; s->mode = M_MSG;

View File

@ -29,6 +29,8 @@
#include "conf.h" #include "conf.h"
#include "util.h" #include "util.h"
#include "acc/acc_lib.ch"
/************************************************************************* /*************************************************************************
// qsort() util // qsort() util
@ -516,25 +518,6 @@ bool makebakname(char *ofilename, size_t size,
} }
/* test if fd is connected to a file or a pipe */
bool isafile(int fd)
{
if (isatty(fd))
return 0;
#if defined(HAVE_FSTAT)
{
struct stat st;
if (fstat(fd, &st) != 0)
return 0;
/* fprintf(stderr,"fstat(%d): %o\n", fd, st.st_mode); */
if (S_ISDIR(st.st_mode))
return 0;
}
#endif
return 1;
}
/************************************************************************* /*************************************************************************
// return compression ratio, where 100% == 1000*1000 == 1e6 // return compression ratio, where 100% == 1000*1000 == 1e6
**************************************************************************/ **************************************************************************/

View File

@ -44,7 +44,6 @@ bool maketempname(char *ofilename, size_t size,
const char *ifilename, const char *ext, bool force=true); const char *ifilename, const char *ext, bool force=true);
bool makebakname(char *ofilename, size_t size, bool makebakname(char *ofilename, size_t size,
const char *ifilename, bool force=true); const char *ifilename, bool force=true);
bool isafile(int fd);
unsigned get_ratio(unsigned u_len, unsigned c_len); unsigned get_ratio(unsigned u_len, unsigned c_len);
bool set_method_name(char *buf, size_t size, int method, int level); bool set_method_name(char *buf, size_t size, int method, int level);

View File

@ -105,7 +105,7 @@ void do_one_file(const char *iname, char *oname)
{ {
if (opt->to_stdout) if (opt->to_stdout)
{ {
if (!fo.openStdout(O_BINARY, opt->force ? true : false)) if (!fo.openStdout(1, opt->force ? true : false))
throwIOException("data not written to a terminal; Use `-f' to force."); throwIOException("data not written to a terminal; Use `-f' to force.");
} }
else else