From c448d15a8f683651af6da23790886625618d25a0 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Thu, 24 Apr 2003 02:47:54 +0000 Subject: [PATCH] New ACC version. committer: mfx 1051152474 +0000 --- src/acc/acc.h | 9 ++- src/acc/acc_arch.h | 3 + src/acc/acc_auto.h | 62 +++++++++++++++-- src/acc/acc_cc.h | 12 ++-- src/acc/acc_defs.h | 20 +++--- src/acc/acc_inci.h | 5 +- src/acc/acc_init.h | 38 ++++++++--- src/acc/acc_lib.ch | 162 +++++++++++++++++++++++++++++++++++++-------- src/acc/acc_lib.h | 56 +++++++++++++--- src/acc/acc_mm.h | 56 ++++++++++++---- src/acc/acc_os.h | 4 +- src/acc/acc_type.h | 8 +-- 12 files changed, 352 insertions(+), 83 deletions(-) diff --git a/src/acc/acc.h b/src/acc/acc.h index c00661be..2c158533 100644 --- a/src/acc/acc.h +++ b/src/acc/acc.h @@ -23,13 +23,20 @@ */ -#define ACC_VERSION 20030417L +#define ACC_VERSION 20030423L #if !defined(ACC_CONFIG_INCLUDE) # define ACC_CONFIG_INCLUDE(file) file #endif +#if defined(__CYGWIN32__) && !defined(__CYGWIN__) +# define __CYGWIN__ __CYGWIN32__ +#endif +#if defined(__ICL) && !defined(__INTEL_COMPILER) +# define __INTEL_COMPILER __ICL +#endif + /* disable pedantic warnings */ #if defined(__INTEL_COMPILER) && defined(__linux__) # pragma warning(disable: 193) /* #193: zero used for undefined preprocessing identifier */ diff --git a/src/acc/acc_arch.h b/src/acc/acc_arch.h index 1b236063..8d967b3a 100644 --- a/src/acc/acc_arch.h +++ b/src/acc/acc_arch.h @@ -37,6 +37,9 @@ #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) # define ACC_ARCH_IA32 1 # define ACC_INFO_ARCH "ia32" +#elif (ACC_CC_ZORTECHC && defined(__I86__)) +# define ACC_ARCH_IA32 1 +# define ACC_INFO_ARCH "ia32" #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define ACC_ARCH_IA64 1 # define ACC_INFO_ARCH "ia64" diff --git a/src/acc/acc_auto.h b/src/acc/acc_auto.h index 45cfef86..2c34ed0d 100644 --- a/src/acc/acc_auto.h +++ b/src/acc/acc_auto.h @@ -111,7 +111,7 @@ #define HAVE_IO_H 1 #define HAVE_SHARE_H 1 -#if (ACC_CC_AZTEC_C) +#if (ACC_CC_AZTECC) # undef HAVE_CONIO_H # undef HAVE_DIRECT_H # undef HAVE_DIRENT_H @@ -126,7 +126,9 @@ # undef HAVE_UNISTD_H # undef HAVE_SYS_TIME_H #elif (ACC_CC_DMC) +# undef HAVE_DIRENT_H /* not working */ # undef HAVE_UNISTD_H /* not working */ +# define HAVE_SYS_DIRENT_H 1 #elif defined(__DJGPP__) #elif (ACC_CC_INTELC || ACC_CC_MSC) # undef HAVE_DIRENT_H @@ -141,7 +143,7 @@ #elif defined(__MINGW32__) # undef HAVE_UTIME_H # define HAVE_SYS_UTIME_H 1 -#elif (ACC_CC_PACIFIC) +#elif (ACC_CC_PACIFICC) # undef HAVE_DIRECT_H # undef HAVE_DIRENT_H # undef HAVE_FCNTL_H @@ -154,9 +156,19 @@ # undef HAVE_SYS_STAT_H # undef HAVE_SYS_TIME_H # undef HAVE_SYS_TYPES_H +#elif (ACC_CC_SYMANTECC) +# undef HAVE_DIRENT_H /* opendir() not implemented in libc */ +# undef HAVE_UNISTD_H /* not working */ +# if (__SC__ < 0x700) +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# endif #elif (ACC_CC_TURBOC) # undef HAVE_UNISTD_H # undef HAVE_SYS_TIME_H +# if (__TURBOC__ < 0x0200) +# undef HAVE_SYS_TYPES_H +# endif # if (__TURBOC__ < 0x0400) # undef HAVE_DIRECT_H # undef HAVE_DIRENT_H @@ -172,6 +184,12 @@ # if (__WATCOMC__ < 900) # undef HAVE_UNISTD_H # endif +#elif (ACC_CC_ZORTECHC) +# undef HAVE_DIRENT_H +# undef HAVE_MEMORY_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H #endif #endif /* DOS, OS/2 & Windows */ @@ -256,15 +274,17 @@ #undef HAVE_LSTAT #undef HAVE_UMASK -#if (ACC_CC_AZTEC_C) +#if (ACC_CC_AZTECC) # undef HAVE_DIFFTIME /* difftime() is in the math library */ # undef HAVE_FSTAT # undef HAVE_STRDUP /* missing in 5.2a */ # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF #elif (ACC_CC_BORLANDC) -# if (__BORLANDC__ < 0x0500) +# if (ACC_OS_DOS16 || ACC_OS_WIN16) # undef HAVE_DIFFTIME /* difftime() is in the math library */ +# endif +# if (__BORLANDC__ < 0x0550) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF # endif @@ -274,13 +294,21 @@ #elif defined(__DJGPP__) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF -#elif (ACC_CC_INTELC || ACC_CC_MSC) +#elif (ACC_CC_INTELC) # define snprintf _snprintf # define vsnprintf _vsnprintf #elif (ACC_CC_LCC) # define utime _utime +#elif (ACC_CC_MSC) +# if (_MSC_VER >= 700) +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# else +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif #elif defined(__MINGW32__) -#elif (ACC_CC_PACIFIC) +#elif (ACC_CC_PACIFICC) # undef HAVE_ACCESS # undef HAVE_ALLOCA # undef HAVE_CHMOD @@ -290,6 +318,20 @@ # undef HAVE_STRFTIME # undef HAVE_UTIME # undef HAVE_VSNPRINTF +#elif (ACC_CC_SYMANTECC) +# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) +# undef HAVE_ALLOCA +# endif +# if (__SC__ < 0x700) +# undef HAVE_DIFFTIME /* difftime() is broken */ +# endif +# if (__SC__ >= 0x610) +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# else +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# endif #elif (ACC_CC_TURBOC) # undef HAVE_ALLOCA # undef HAVE_SNPRINTF @@ -308,6 +350,13 @@ # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF # endif +#elif (ACC_CC_ZORTECHC) +# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) +# undef HAVE_ALLOCA +# endif +# undef HAVE_DIFFTIME /* difftime() is broken */ +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF #endif #endif /* DOS, OS/2 & Windows */ @@ -365,6 +414,7 @@ # define SIZEOF___INT64 8 # define SIZEOF_UNSIGNED___INT64 8 #elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0550)) + /* info: unsigned __int64 is broken in 0x0520 */ # define SIZEOF___INT64 8 # define SIZEOF_UNSIGNED___INT64 8 #elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && __WATCOMC__ >= 1100)) diff --git a/src/acc/acc_cc.h b/src/acc/acc_cc.h index ec0abddf..0afa91d6 100644 --- a/src/acc/acc_cc.h +++ b/src/acc/acc_cc.h @@ -32,7 +32,7 @@ # define ACC_INFO_CC "gcc" # define ACC_INFO_CCVER __VERSION__ #elif defined(__AZTEC_C__) -# define ACC_CC_AZTEC_C 1 +# define ACC_CC_AZTECC 1 # define ACC_INFO_CC "Aztec C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__AZTEC_C__) #elif defined(__BORLANDC__) @@ -64,7 +64,7 @@ # define ACC_INFO_CC "Metrowerks C" # define ACC_INFO_CCVER "unknown" #elif defined(__PACIFIC__) -# define ACC_CC_PACIFIC 1 +# define ACC_CC_PACIFICC 1 # define ACC_INFO_CC "Pacific C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__PACIFIC__) #elif defined(__PUREC__) @@ -72,7 +72,7 @@ # define ACC_INFO_CC "Pure C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__PUREC__) #elif defined(__SC__) -# define ACC_CC_SYMANTEC 1 +# define ACC_CC_SYMANTECC 1 # define ACC_INFO_CC "Symantec C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) @@ -94,7 +94,11 @@ #elif defined(__ZTC__) # define ACC_CC_ZORTECHC 1 # define ACC_INFO_CC "Zortech C" -# define ACC_INFO_CCVER ACC_MACRO_EXPAND(__ZTC__) +# if (__ZTC__ == 0x310) +# define ACC_INFO_CCVER "0x310" +# else +# define ACC_INFO_CCVER ACC_MACRO_EXPAND(__ZTC__) +# endif #else # define ACC_CC_UNKNOWN 1 # define ACC_INFO_CC "unknown" diff --git a/src/acc/acc_defs.h b/src/acc/acc_defs.h index 0f1c20ad..6a5fc6db 100644 --- a/src/acc/acc_defs.h +++ b/src/acc/acc_defs.h @@ -25,7 +25,7 @@ #endif #if !defined(ACC_COMPILE_TIME_ASSERT) -# if (ACC_CC_DMC || ACC_CC_PACIFIC) +# if (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC) # define ACC_COMPILE_TIME_ASSERT(expr) \ switch (0) { case 1: case !(expr): break; } # else @@ -39,9 +39,13 @@ // macros ************************************************************************/ +/* workaround for preprocessor bugs in some compilers */ +#define ACC_0xffffL 65535ul +#define ACC_0xffffffffL 4294967295ul + #if !defined(__ACC_UINT_MAX) -# define __ACC_INT_MAX(b) ((1l << ((b)-1)) - 1) -# define __ACC_UINT_MAX(b) ((((1ul << ((b)-1)) - 1) << 1) + 1) +# define __ACC_INT_MAX(b) ((((1l << ((b)-2)) - 1l) * 2l) + 1l) +# define __ACC_UINT_MAX(b) ((((1ul << ((b)-1)) - 1ul) * 2ul) + 1ul) #endif @@ -50,9 +54,9 @@ ************************************************************************/ #if !defined(__ACC_SHORT_BIT) -# if (USHRT_MAX == 0xffffL) +# if (USHRT_MAX == ACC_0xffffL) # define __ACC_SHORT_BIT 16 -# elif (USHRT_MAX == __ACC_UINT_MAX(32)) +# elif (USHRT_MAX == ACC_0xffffffffL) # define __ACC_SHORT_BIT 32 # elif (USHRT_MAX == __ACC_UINT_MAX(64)) # define __ACC_SHORT_BIT 64 @@ -64,9 +68,9 @@ #endif #if !defined(__ACC_INT_BIT) -# if (UINT_MAX == 0xffffL) +# if (UINT_MAX == ACC_0xffffL) # define __ACC_INT_BIT 16 -# elif (UINT_MAX == __ACC_UINT_MAX(32)) +# elif (UINT_MAX == ACC_0xffffffffL) # define __ACC_INT_BIT 32 # elif (UINT_MAX == __ACC_UINT_MAX(64)) # define __ACC_INT_BIT 64 @@ -78,7 +82,7 @@ #endif #if !defined(__ACC_LONG_BIT) -# if (ULONG_MAX == __ACC_UINT_MAX(32)) +# if (ULONG_MAX == ACC_0xffffffffL) # define __ACC_LONG_BIT 32 # elif (ULONG_MAX == __ACC_UINT_MAX(64)) # define __ACC_LONG_BIT 64 diff --git a/src/acc/acc_inci.h b/src/acc/acc_inci.h index ce749915..7a5e9c1d 100644 --- a/src/acc/acc_inci.h +++ b/src/acc/acc_inci.h @@ -28,12 +28,15 @@ # define ACC_H_WINDOWS_H 1 #elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16) # if (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# include # include # elif defined(__DJGPP__) # include -# elif (ACC_CC_PACIFIC) +# elif (ACC_CC_PACIFICC) # include # include +# elif (ACC_CC_WATCOMC) +# include # endif #endif diff --git a/src/acc/acc_init.h b/src/acc/acc_init.h index 9f4b37e6..e4490de7 100644 --- a/src/acc/acc_init.h +++ b/src/acc/acc_init.h @@ -17,7 +17,11 @@ // try to detect specific compilers ************************************************************************/ -#if defined(__VERSION) && (UINT_MAX == 0xffffL) && defined(MB_LEN_MAX) +#if defined(__ZTC__) && defined(__I86__) && (UINT_MAX == 0xffffL) +# if !defined(__DOS__) && !defined(__OS2__) +# define __DOS__ 1 +# endif +#elif defined(__VERSION) && (UINT_MAX == 0xffffL) && defined(MB_LEN_MAX) # if (__VERSION == 520) && (MB_LEN_MAX == 1) # if !defined(__AZTEC_C__) # define __AZTEC_C__ __VERSION @@ -33,16 +37,11 @@ // fix incorrect and missing stuff ************************************************************************/ -#if defined(__CYGWIN32__) && !defined(__CYGWIN__) -# define __CYGWIN__ __CYGWIN32__ -#endif - - /* Microsoft C does not correctly define ptrdiff_t for * the 16-bit huge memory model. */ #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == 0xffffL) -# if (_MSC_VER <= 800) +# if (_MSC_VER < 900) # define ptrdiff_t long # define _PTRDIFF_T_DEFINED # endif @@ -57,6 +56,21 @@ # if !defined(__near) # define __near near # endif +#elif defined(_MSC_VER) && defined(MSDOS) +# if(_MSC_VER < 700) +# if !defined(__cdecl) +# define __cdecl _cdecl +# endif +# if !defined(__far) +# define __far _far +# endif +# if !defined(__huge) +# define __huge _huge +# endif +# if !defined(__near) +# define __near _near +# endif +# endif #elif defined(__TURBOC__) && defined(__MSDOS__) # if(__TURBOC__ < 0x0410) # if !defined(__cdecl) @@ -75,7 +89,15 @@ #endif -#if defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__)) +#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0200) +# define ACC_BROKEN_SIZEOF 1 +# if (__TURBOC < 0x0150) +# define ACC_BROKEN_INTEGRAL_PROMOTION 1 +# endif +#elif defined(MSDOS) && defined(_MSC_VER) && (_MSC_VER < 700) +# define ACC_BROKEN_INTEGRAL_PROMOTION 1 +# define ACC_BROKEN_SIZEOF 1 +#elif defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__)) # define ACC_BROKEN_SIZEOF 1 #endif diff --git a/src/acc/acc_lib.ch b/src/acc/acc_lib.ch index e07bf99e..81c2a76d 100644 --- a/src/acc/acc_lib.ch +++ b/src/acc/acc_lib.ch @@ -15,14 +15,109 @@ #if !defined(ACC_VERSION) -#include "acc.h" +# if defined ACC_CONFIG_INCLUDE +# include ACC_CONFIG_INCLUDE("acc.h") +# else +# include "acc.h" +# endif #endif #ifndef __ACC_INCE_H_INCLUDED -#include ACC_CONFIG_INCLUDE("acc_ince.h") +# include ACC_CONFIG_INCLUDE("acc_ince.h") #endif #ifndef __ACC_INCI_H_INCLUDED -#include ACC_CONFIG_INCLUDE("acc_inci.h") +# include ACC_CONFIG_INCLUDE("acc_inci.h") #endif +#ifndef __ACC_LIB_H_INCLUDED +# include ACC_CONFIG_INCLUDE("acc_lib.h") +#endif + + +/*********************************************************************** +// huge pointer layer +************************************************************************/ + +ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_alloc_p ap, acc_hsize_t items, size_t size) +{ + acc_hvoid_p p = 0; +#if (SIZEOF_SIZE_T > SIZEOF_LONG) + size_t s = (size_t) items * size; +#else + unsigned long s = (unsigned long) items * size; +#endif + + if (!ap) + return p; + ap->ptr = p; +#if 0 + ap->items = items; + ap->size = size; + ap->flags = 0; +#endif + if (items <= 0 || size <= 0 || s < items || s < size) + return p; + +#if defined(__palmos__) + p = MemPtrNew(s); +#elif !defined(ACC_HAVE_MM_HUGE_PTR) + if (s < (size_t) -1) + p = malloc((size_t) s); +#else +#if (ACC_CC_MSC && _MSC_VER >= 700) + if (size < (size_t) -1) + p = _halloc(items, (size_t) size); +#elif (ACC_CC_MSC || ACC_CC_WATCOMC) + if (size < (size_t) -1) + p = halloc(items, (size_t) size); +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + if (size < (size_t) -1) + p = _halloc(items, (size_t) size); +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + p = farmalloc(s); +#elif defined(ACC_CC_AZTECC) + p = lmalloc(s); +#else + if (s < (size_t) -1) + p = malloc((size_t) s); +#endif +#endif + + ap->ptr = p; + return p; +} + + +ACC_LIBFUNC(int, acc_hfree) (acc_alloc_p ap) +{ + acc_hvoid_p p; + int r = 0; + + if (!ap || !ap->ptr) + return r; + p = ap->ptr; + ap->ptr = 0; + +#if defined(__palmos__) + r = MemPtrFree(p); +#elif !defined(ACC_HAVE_MM_HUGE_PTR) + free(p); +#else +#if (ACC_CC_MSC && _MSC_VER >= 700) + _hfree(p); +#elif (ACC_CC_MSC || ACC_CC_WATCOMC) + hfree(p); +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + _hfree(p); +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + farfree((void __far *) p); +#elif defined(ACC_CC_AZTECC) + lfree(p); +#else + free(p); +#endif +#endif + + return r; +} /************************************************************************* @@ -31,20 +126,27 @@ #if (HAVE_DIRENT_H) -int acc_opendir(ACC_DIR* dirp, const char* name) +ACC_LIBFUNC(int, acc_opendir) (ACC_DIR* dirp, const char* name) { - dirp->dirp = (ACC_DIR*) opendir(name); + dirp->dirp = opendir(name); return dirp->dirp ? 0 : -1; } -int acc_closedir(ACC_DIR* dirp) +ACC_LIBFUNC(int, acc_closedir) (ACC_DIR* dirp) { - return closedir((DIR*) dirp->dirp); + int r = -1; + if (!dirp->dirp) + return r; + r = closedir((DIR*) dirp->dirp); + dirp->dirp = 0; + return r; } -int acc_readdir(ACC_DIR* dirp, struct acc_dirent* d) +ACC_LIBFUNC(int, acc_readdir) (ACC_DIR* dirp, struct acc_dirent* d) { - const struct dirent *dp; + const struct dirent* dp; + if (!dirp->dirp) + return -1; dp = readdir((DIR*) dirp->dirp); if (!dp || !dp->d_name[0]) return -1; @@ -56,21 +158,26 @@ int acc_readdir(ACC_DIR* dirp, struct acc_dirent* d) #else -int acc_opendir(ACC_DIR* dirp, const char* name) +ACC_LIBFUNC(int, acc_opendir) (ACC_DIR* dirp, const char* name) { - ACC_UNUSED(dirp); ACC_UNUSED(name); + dirp->dirp = 0; + ACC_UNUSED(name); return -1; } -int acc_closedir(ACC_DIR* dirp) +ACC_LIBFUNC(int, acc_closedir) (ACC_DIR* dirp) { - ACC_UNUSED(dirp); + if (!dirp->dirp) + return -1; + dirp->dirp = 0; return -1; } -int acc_readdir(ACC_DIR* dirp, struct acc_dirent* d) +ACC_LIBFUNC(int, acc_readdir) (ACC_DIR* dirp, struct acc_dirent* d) { - ACC_UNUSED(dirp); ACC_UNUSED(d); + if (!dirp->dirp) + return -1; + d->d_name[0] = 0; return -1; } @@ -91,7 +198,7 @@ int acc_readdir(ACC_DIR* dirp, struct acc_dirent* d) // wrap misc **************************************************************************/ -long acc_get_osfhandle(int fd) +ACC_LIBFUNC(long, acc_get_osfhandle) (int fd) { if (fd < 0) return -1; @@ -108,7 +215,7 @@ long acc_get_osfhandle(int fd) } -int acc_set_binmode(int fd, int binary) +ACC_LIBFUNC(int, acc_set_binmode) (int fd, int binary) { #if (ACC_OS_TOS && defined(__MINT__)) int old_binary; @@ -123,7 +230,7 @@ int acc_set_binmode(int fd, int binary) #elif (ACC_OS_TOS) ACC_UNUSED(fd); ACC_UNUSED(binary); return -1; -#elif (ACC_OS_DOS16 && (ACC_CC_AZTEC_C || ACC_CC_PACIFIC)) +#elif (ACC_OS_DOS16 && (ACC_CC_AZTECC || ACC_CC_PACIFICC)) ACC_UNUSED(fd); ACC_UNUSED(binary); return -1; #elif defined(__DJGPP__) @@ -138,17 +245,19 @@ int acc_set_binmode(int fd, int binary) __djgpp_set_ctrl_c(!(old_flags & 1)); if (r == -1) return -1; - return r & O_BINARY ? 1 : 0; + return (r & O_TEXT) ? 0 : 1; #elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN || ACC_OS_EMX) int r; +#if !defined(ACC_CC_ZORTECHC) ACC_COMPILE_TIME_ASSERT(O_BINARY > 0) +#endif ACC_COMPILE_TIME_ASSERT(O_TEXT > 0) if (fd < 0) return -1; r = setmode(fd, binary ? O_BINARY : O_TEXT); if (r == -1) return -1; - return r & O_BINARY ? 1 : 0; + return (r & O_TEXT) ? 0 : 1; #else if (fd < 0) return -1; @@ -158,7 +267,7 @@ int acc_set_binmode(int fd, int binary) } -int acc_isatty(int fd) +ACC_LIBFUNC(int, acc_isatty) (int fd) { if (fd < 0) return 0; @@ -177,29 +286,28 @@ int acc_isatty(int fd) } } #endif - return isatty(fd); + return (isatty(fd)) ? 1 : 0; } -int acc_mkdir(const char* name, unsigned mode) +ACC_LIBFUNC(int, acc_mkdir) (const char* name, unsigned mode) { - ACC_UNUSED(mode); #if (ACC_OS_POSIX || ACC_OS_CYGWIN || ACC_OS_EMX) return mkdir(name, mode); #elif defined(__DJGPP__) || defined(__MINT__) return mkdir(name, mode); #elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) + ACC_UNUSED(mode); return Dcreate(name); -#elif (ACC_OS_DOS16 && ACC_CC_PACIFIC) - return mkdir((char*)name); #else + ACC_UNUSED(mode); return mkdir(name); #endif } #if 0 -int acc_response(int* argc, char*** argv) +ACC_LIBFUNC(int, acc_response) (int* argc, char*** argv) { } #endif diff --git a/src/acc/acc_lib.h b/src/acc/acc_lib.h index 0014b44a..7bf61f86 100644 --- a/src/acc/acc_lib.h +++ b/src/acc/acc_lib.h @@ -17,20 +17,56 @@ #define __ACC_LIB_H_INCLUDED +#if !defined(ACC_LIBFUNC) +# define ACC_LIBFUNC(a,b) a b +#endif + + +/************************************************************************* +// huge pointer layer +**************************************************************************/ + +#if (ACC_HAVE_MM_HUGE_PTR) +# define __acc_huge __huge +# define acc_hsize_t unsigned long +#else +# define __acc_huge +# define acc_hsize_t size_t +#endif +#define acc_hvoid_p void __acc_huge * +#define acc_hbyte_p unsigned char __acc_huge * + +typedef struct +{ + acc_hvoid_p ptr; +} +acc_alloc_t; +#define acc_alloc_p acc_alloc_t __acc_huge * + +/* malloc */ +ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_alloc_p ap, acc_hsize_t items, size_t size); +ACC_LIBFUNC(int, acc_hfree) (acc_alloc_p ap); + +/* stdlib */ + +/* stdio */ + + + /************************************************************************* // wrap **************************************************************************/ -struct ACC_DIR { void* dirp; }; /* opaque type */ +struct ACC_DIR { acc_hvoid_p dirp; }; /* opaque type */ typedef struct ACC_DIR ACC_DIR; struct acc_dirent { char d_name[255+1]; }; -int acc_opendir(ACC_DIR* dirp, const char* name); -int acc_readdir(ACC_DIR* dirp, struct acc_dirent* d); -int acc_closedir(ACC_DIR* dirp); +ACC_LIBFUNC(int, acc_opendir) (ACC_DIR* dirp, const char* name); +ACC_LIBFUNC(int, acc_readdir) (ACC_DIR* dirp, struct acc_dirent* d); +ACC_LIBFUNC(int, acc_closedir) (ACC_DIR* dirp); /************************************************************************* @@ -52,17 +88,17 @@ int acc_closedir(ACC_DIR* dirp); // wrap misc **************************************************************************/ -#if defined(__MINGW32__) +#if defined(__CYGWIN__) || defined(__MINGW32__) # define acc_alloca(x) __builtin_alloca((x)) #elif (HAVE_ALLOCA) # define acc_alloca(x) alloca((x)) #endif -long acc_get_osfhandle(int fd); -int acc_isatty(int fd); -int acc_mkdir(const char* name, unsigned mode); -int acc_response(int* argc, char*** argv); -int acc_set_binmode(int fd, int binary); +ACC_LIBFUNC(long, acc_get_osfhandle) (int fd); +ACC_LIBFUNC(int, acc_isatty) (int fd); +ACC_LIBFUNC(int, acc_mkdir) (const char* name, unsigned mode); +ACC_LIBFUNC(int, acc_response) (int* argc, char*** argv); +ACC_LIBFUNC(int, acc_set_binmode) (int fd, int binary); #endif /* already included */ diff --git a/src/acc/acc_mm.h b/src/acc/acc_mm.h index 75390f21..0f34f1ce 100644 --- a/src/acc/acc_mm.h +++ b/src/acc/acc_mm.h @@ -42,7 +42,7 @@ # define ACC_MM_COMPACT 1 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) # define ACC_MM_LARGE 1 -#elif (ACC_CC_AZTEC_C) +#elif (ACC_CC_AZTECC) # if defined(_LARGE_CODE) && defined(_LARGE_DATA) # define ACC_MM_LARGE 1 # elif defined(_LARGE_CODE) @@ -52,24 +52,56 @@ # else # define ACC_MM_SMALL 1 # endif +#elif (ACC_CC_ZORTECHC && defined(__VCM__)) +# define ACC_MM_LARGE 1 #else # error "unknown memory model" #endif -#if (ACC_CC_AZTEC_C || ACC_CC_PACIFIC) -#elif (ACC_CC_DMC) -# define ACC_HAVE_MM_HUGE_PTR 1 -#elif (ACC_CC_TURBOC && __TURBOC__ < 0x0295) -# define ACC_HAVE_MM_HUGE_PTR 1 -#elif (ACC_CC_WATCOMC && __WATCOMC__ >= 1200) - /* __huge pointers seem completely broken in OpenWatcom 1.0 */ -#else -# define ACC_HAVE_MM_HUGE_PTR 1 /* working __huge pointers */ -# define ACC_HAVE_MM_HUGE_ARRAY 1 /* char __huge x[256*1024L] works */ -#endif +/* ACC_HAVE_MM_HUGE_PTR ... working __huge pointers + * ACC_HAVE_MM_HUGE_ARRAY ... char __huge x[256*1024L] works */ +#define ACC_HAVE_MM_HUGE_PTR 1 +#define ACC_HAVE_MM_HUGE_ARRAY 1 + #if (ACC_MM_TINY) # undef ACC_HAVE_MM_HUGE_ARRAY +# if (ACC_CC_MSC && _MSC_VER < 700) +# undef ACC_HAVE_MM_HUGE_PTR +# endif +#endif + +#if (ACC_CC_AZTECC || ACC_CC_PACIFICC || ACC_CC_ZORTECHC) +# undef ACC_HAVE_MM_HUGE_PTR +# undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC) +# undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_TURBOC && __TURBOC__ < 0x0295) +# undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_WATCOMC && __WATCOMC__ >= 1200) + /* __huge pointers seem completely broken in OpenWatcom 1.0 */ +# undef ACC_HAVE_MM_HUGE_PTR +# undef ACC_HAVE_MM_HUGE_ARRAY +#endif + +#if (ACC_HAVE_MM_HUGE_PTR) +# if (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0400) + extern unsigned short __near _AHSHIFT; +# define ACC_MM_AHSHIFT ((unsigned) &_AHSHIFT) +# elif (ACC_CC_DMC || ACC_CC_MSC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + extern unsigned short __near _AHSHIFT; +# define ACC_MM_AHSHIFT ((unsigned) &_AHSHIFT) +# elif (ACC_CC_TURBOC && __TURBOC__ >= 0x0295) + extern unsigned short __near _AHSHIFT; +# define ACC_MM_AHSHIFT ((unsigned) &_AHSHIFT) +# elif (ACC_CC_TURBOC && ACC_OS_DOS16) +# define ACC_MM_AHSHIFT 12 +# elif (ACC_CC_WATCOMC) + extern unsigned char _HShift; +# define ACC_MM_AHSHIFT ((unsigned) _HShift) +# else +# error "implement ACC_MM_AHSHIFT" +# endif #endif diff --git a/src/acc/acc_os.h b/src/acc/acc_os.h index c9c465fb..5dcbefc1 100644 --- a/src/acc/acc_os.h +++ b/src/acc/acc_os.h @@ -65,10 +65,10 @@ # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) -# if (UINT_MAX == 0xffffffffL) +# if (UINT_MAX == 0xffffffffUL) # define ACC_OS_DOS32 1 # define ACC_INFO_OS "dos32" -# elif (UINT_MAX == 0xffffL) +# elif (UINT_MAX == 0xffffUL) # define ACC_OS_DOS16 1 # define ACC_INFO_OS "dos16" # else diff --git a/src/acc/acc_type.h b/src/acc/acc_type.h index 6305a870..05aca18a 100644 --- a/src/acc/acc_type.h +++ b/src/acc/acc_type.h @@ -17,7 +17,7 @@ // ************************************************************************/ -#if (ACC_CC_GNUC >= 0x020800l) /* 2.8.0 */ +#if (ACC_CC_GNUC >= 0x020800ul) /* 2.8.0 */ # define __acc_gnuc_extension__ __extension__ #else # define __acc_gnuc_extension__ @@ -39,10 +39,10 @@ __acc_gnuc_extension__ typedef unsigned __int64 acc_uint64_t; #if !defined(ACC_UINT32_C) -# if defined(__PACIFIC__) && defined(DOS) - /* workaround Pacific C */ +# if (ACC_OS_DOS16 && ACC_CC_PACIFICC) + /* workaround for Pacific C */ # define ACC_UINT32_C(c) c -# elif (UINT_MAX < __ACC_UINT_MAX(32)) +# elif (UINT_MAX < ACC_0xffffffffL) # define ACC_UINT32_C(c) c ## UL # else # define ACC_UINT32_C(c) c ## U