diff --git a/src/acc/acc.h b/src/acc/acc.h index 1507fff0..bdd99616 100644 --- a/src/acc/acc.h +++ b/src/acc/acc.h @@ -26,7 +26,7 @@ #ifndef __ACC_H_INCLUDED #define __ACC_H_INCLUDED -#define ACC_VERSION 20030527L +#define ACC_VERSION 20030708L #if !defined(ACC_CONFIG_INCLUDE) # define ACC_CONFIG_INCLUDE(file) file @@ -39,6 +39,9 @@ #if defined(__ICL) && !defined(__INTEL_COMPILER) # define __INTEL_COMPILER __ICL #endif +#if defined(__IBMCPP__) && !defined(__IBMC__) +# define __IBMC__ __IBMCPP__ +#endif /* disable pedantic warnings */ #if defined(__INTEL_COMPILER) && defined(__linux__) diff --git a/src/acc/acc_arch.h b/src/acc/acc_arch.h index 8d967b3a..118518cf 100644 --- a/src/acc/acc_arch.h +++ b/src/acc/acc_arch.h @@ -34,7 +34,7 @@ #if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) # define ACC_ARCH_IA16 1 # define ACC_INFO_ARCH "ia16" -#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) +#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) # define ACC_ARCH_IA32 1 # define ACC_INFO_ARCH "ia32" #elif (ACC_CC_ZORTECHC && defined(__I86__)) diff --git a/src/acc/acc_auto.h b/src/acc/acc_auto.h index b8a45240..4dde1d7d 100644 --- a/src/acc/acc_auto.h +++ b/src/acc/acc_auto.h @@ -128,11 +128,22 @@ # if (ACC_OS_WIN32 || ACC_OS_WIN64) # undef HAVE_DIRENT_H /* pulls in ; use instead */ # endif +# if (__BORLANDC__ < 0x0400) +# undef HAVE_DIRENT_H +# undef HAVE_UTIME_H +# endif #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_IBMC && ACC_OS_OS2) +# undef HAVE_DOS_H +# undef HAVE_DIRENT_H +# undef HAVE_UNISTD_H +# undef HAVE_UTIME_H +# undef HAVE_SYS_TIME_H +# define HAVE_SYS_UTIME_H 1 #elif (ACC_CC_INTELC || ACC_CC_MSC) # undef HAVE_DIRENT_H # undef HAVE_UNISTD_H @@ -258,6 +269,9 @@ #if (ACC_OS_POSIX) +# if (ACC_CC_TINYC) +# undef HAVE_ALLOCA +# endif #elif (ACC_OS_CYGWIN) #elif (ACC_OS_EMX) # undef HAVE_CHOWN @@ -291,15 +305,21 @@ #undef HAVE_UMASK #if (ACC_CC_AZTECC) +# undef HAVE_ALLOCA # undef HAVE_DIFFTIME /* difftime() is in the math library */ # undef HAVE_FSTAT # undef HAVE_STRDUP /* missing in 5.2a */ # undef HAVE_SNPRINTF +# undef HAVE_UTIME /* struct utimbuf is missing */ # undef HAVE_VSNPRINTF #elif (ACC_CC_BORLANDC) # if (ACC_OS_DOS16 || ACC_OS_WIN16) # undef HAVE_DIFFTIME /* difftime() is in the math library */ # endif +# if (__BORLANDC__ < 0x0400) +# undef HAVE_ALLOCA +# undef HAVE_UTIME +# endif # if (__BORLANDC__ < 0x0550) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF @@ -310,18 +330,27 @@ #elif defined(__DJGPP__) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF +#elif (ACC_CC_IBMC && ACC_OS_OS2) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF #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 +# if (_MSC_VER < 600) +# undef HAVE_STRFTIME +# endif +# if (_MSC_VER < 700) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF +# else +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif +# if (_MSC_VER < 800 && ACC_OS_WIN16) +# undef HAVE_ALLOCA # endif #elif defined(__MINGW32__) #elif (ACC_CC_PACIFICC) @@ -339,17 +368,17 @@ # if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) # undef HAVE_ALLOCA # endif +# if (__SC__ < 0x600) +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# else +# define snprintf _snprintf +# define vsnprintf _vsnprintf +# endif # if (__SC__ < 0x700) # undef HAVE_DIFFTIME /* difftime() is broken */ # undef HAVE_UTIME /* struct utimbuf is missing */ # endif -# if (__SC__ >= 0x610) -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# else -# undef HAVE_SNPRINTF -# undef HAVE_VSNPRINTF -# endif #elif (ACC_CC_TOPSPEEDC) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF @@ -365,12 +394,12 @@ # undef HAVE_UTIME # endif #elif (ACC_CC_WATCOMC) -# if (__WATCOMC__ >= 1100) -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# else +# if (__WATCOMC__ < 1100) # undef HAVE_SNPRINTF # undef HAVE_VSNPRINTF +# else +# define snprintf _snprintf +# define vsnprintf _vsnprintf # endif #elif (ACC_CC_ZORTECHC) # if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)) @@ -433,6 +462,9 @@ #if (ACC_ARCH_IA32 && (ACC_CC_DMC || ACC_CC_GNUC)) # define SIZEOF_LONG_LONG 8 # define SIZEOF_UNSIGNED_LONG_LONG 8 +#elif (ACC_ARCH_IA32 && (ACC_CC_SYMANTECC && __SC__ >= 0x700)) +# define SIZEOF_LONG_LONG 8 +# define SIZEOF_UNSIGNED_LONG_LONG 8 #elif (ACC_ARCH_IA32 && (ACC_CC_INTELC || ACC_CC_MSC)) # define SIZEOF___INT64 8 # define SIZEOF_UNSIGNED___INT64 8 @@ -443,6 +475,9 @@ #elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && __WATCOMC__ >= 1100)) # define SIZEOF___INT64 8 # define SIZEOF_UNSIGNED___INT64 8 +#elif (ACC_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +# define SIZEOF___INT64 8 +# define SIZEOF_UNSIGNED___INT64 8 #elif (ACC_ARCH_M68K && (ACC_CC_GNUC)) # define SIZEOF_LONG_LONG 8 # define SIZEOF_UNSIGNED_LONG_LONG 8 diff --git a/src/acc/acc_cc.h b/src/acc/acc_cc.h index ff33832b..38988bd9 100644 --- a/src/acc/acc_cc.h +++ b/src/acc/acc_cc.h @@ -48,8 +48,8 @@ # define ACC_INFO_CC "DEC C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__DECC) #elif defined(__IBMC__) -# define ACC_CC_VISUALAGEC 1 -# define ACC_INFO_CC "VisualAge C" +# define ACC_CC_IBMC 1 +# define ACC_INFO_CC "IBM C" # define ACC_INFO_CCVER ACC_MACRO_EXPAND(__IBMC__) #elif defined(__INTEL_COMPILER) # define ACC_CC_INTELC 1 diff --git a/src/acc/acc_defs.h b/src/acc/acc_defs.h index 242f4dd4..c3db562e 100644 --- a/src/acc/acc_defs.h +++ b/src/acc/acc_defs.h @@ -28,6 +28,9 @@ # if (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC) # define ACC_COMPILE_TIME_ASSERT(expr) \ switch (0) { case 1: case !(expr): break; } +# elif (ACC_CC_AZTECC || ACC_CC_ZORTECHC) +# define ACC_COMPILE_TIME_ASSERT(expr) \ + { typedef int __acc_compile_time_assert_fail[1 - !(expr)]; } # else # define ACC_COMPILE_TIME_ASSERT(expr) \ { typedef int __acc_compile_time_assert_fail[1 - 2 * !(expr)]; } diff --git a/src/acc/acc_inci.h b/src/acc/acc_inci.h index 8e340425..f906a551 100644 --- a/src/acc/acc_inci.h +++ b/src/acc/acc_inci.h @@ -16,21 +16,30 @@ #ifndef __ACC_INCI_H_INCLUDED #define __ACC_INCI_H_INCLUDED -/* internal system includes */ + +/************************************************************************* +// internal system includes +**************************************************************************/ #if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) # include #elif (ACC_OS_WIN32 || ACC_OS_WIN64 || ACC_OS_CYGWIN || (ACC_OS_EMX && defined(__RSXNT__))) -# if 1 && !defined(WIN32_LEAN_AND_MEAN) -# define WIN32_LEAN_AND_MEAN 1 +# if (ACC_CC_WATCOMC && __WATCOMC__ < 1000) +# else +# if 1 && !defined(WIN32_LEAN_AND_MEAN) +# define WIN32_LEAN_AND_MEAN 1 +# endif +# include +# define ACC_H_WINDOWS_H 1 # endif -# include -# define ACC_H_WINDOWS_H 1 # if (ACC_CC_BORLANDC || ACC_CC_TURBOC) # include # endif #elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16) -# if (ACC_CC_BORLANDC || ACC_CC_TURBOC) +# if (ACC_CC_AZTECC) +# include +# include +# elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) # include # include # elif defined(__DJGPP__) @@ -42,8 +51,53 @@ # elif (ACC_CC_WATCOMC) # include # endif +#elif (ACC_OS_OS216) +# if 0 +# include +# else + unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short); + unsigned short __far __pascal DosFreeSeg(unsigned short); +# endif #endif + +/************************************************************************* +// +**************************************************************************/ + +#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16) +# if defined(FP_OFF) +# define ACC_FP_OFF FP_OFF +# elif defined(_FP_OFF) +# define ACC_FP_OFF _FP_OFF +# else +# define ACC_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +# endif +# if defined(FP_SEG) +# define ACC_FP_SEG FP_SEG +# elif defined(_FP_SEG) +# define ACC_FP_SEG _FP_SEG +# else +# define ACC_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +# endif +# if defined(MK_FP) +# define ACC_MK_FP MK_FP +# elif defined(_MK_FP) +# define ACC_MK_FP _MK_FP +# else +# define ACC_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +# endif +# if 0 +# undef ACC_FP_OFF +# undef ACC_FP_SEG +# undef ACC_MK_FP +# define ACC_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +# define ACC_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +# define ACC_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +# endif +#endif + + #endif /* already included */ diff --git a/src/acc/acc_init.h b/src/acc/acc_init.h index 69b734e9..91e5f638 100644 --- a/src/acc/acc_init.h +++ b/src/acc/acc_init.h @@ -19,17 +19,25 @@ ************************************************************************/ /* workaround for preprocessor bugs in some compilers */ +#if 0 #define ACC_0xffffL 65535ul #define ACC_0xffffffffL 4294967295ul +#else +#define ACC_0xffffL 0xfffful +#define ACC_0xffffffffL 0xfffffffful +#endif /* some things we cannot work around */ #if 0 -#if (32767 >= 4294967295ul) +#if (ACC_0xffffL == ACC_0xffffffffL) # error "your preprocessor is broken 1" #endif -#if (65535u >= 4294967295ul) +#if (32767 >= 4294967295ul) # error "your preprocessor is broken 2" #endif +#if (65535u >= 4294967295ul) +# error "your preprocessor is broken 3" +#endif #endif @@ -67,6 +75,7 @@ /* Fix old compiler versions. */ +#if (UINT_MAX == ACC_0xffffL) #if defined(__PACIFIC__) && defined(DOS) # if !defined(__far) # define __far far @@ -74,23 +83,11 @@ # 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 +#elif defined(__AZTEC_C__) && defined(__DOS__) +# if !defined(__huge) +# define __huge huge # endif -#elif defined(__TURBOC__) && defined(__MSDOS__) -# if(__TURBOC__ < 0x0410) +#elif defined(__TSC__) && defined(__OS2__) # if !defined(__cdecl) # define __cdecl cdecl # endif @@ -103,13 +100,68 @@ # if !defined(__near) # define __near near # endif +# if !defined(__pascal) +# define __pascal pascal +# endif +#elif defined(_MSC_VER) && defined(MSDOS) +# if (_MSC_VER < 600) +# 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 +# if !defined(__pascal) +# define __pascal pascal +# endif +# elif (_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 +# if !defined(__pascal) +# define __pascal _pascal +# endif # endif +#elif defined(__TURBOC__) && defined(__MSDOS__) +# if (__TURBOC__ < 0x0410) +# 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 +# if !defined(__pascal) +# define __pascal pascal +# endif +# endif +#endif #endif #if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0200) # define ACC_BROKEN_SIZEOF 1 -# if (__TURBOC < 0x0150) +# if (__TURBOC__ < 0x0150) # define ACC_BROKEN_INTEGRAL_PROMOTION 1 # endif #elif defined(MSDOS) && defined(_MSC_VER) && (_MSC_VER < 700) diff --git a/src/acc/acc_lib.ch b/src/acc/acc_lib.ch index 0bc3e8dd..2ea2c8ec 100644 --- a/src/acc/acc_lib.ch +++ b/src/acc/acc_lib.ch @@ -33,70 +33,50 @@ /*********************************************************************** -// huge pointer layer - alloc +// halloc ************************************************************************/ -ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_alloc_p ap, acc_hsize_t items, size_t size) +ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_hsize_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) + if (size <= 0) return p; -#if defined(__palmos__) - p = MemPtrNew(s); +#if 0 && defined(__palmos__) + p = MemPtrNew(size); #elif !defined(ACC_HAVE_MM_HUGE_PTR) - if (s < (size_t) -1) - p = malloc((size_t) s); + if (size < (size_t) -1) + p = malloc((size_t) size); #else #if (ACC_CC_MSC && _MSC_VER >= 700) - if (size < (size_t) -1) - p = _halloc(items, (size_t) size); + p = _halloc(size, 1); #elif (ACC_CC_MSC || ACC_CC_WATCOMC) - if (size < (size_t) -1) - p = halloc(items, (size_t) size); + p = halloc(size, 1); #elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) - if (size < (size_t) -1) - p = _halloc(items, (size_t) size); + p = farmalloc(size); #elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) - p = farmalloc(s); + p = farmalloc(size); #elif defined(ACC_CC_AZTECC) - p = lmalloc(s); + p = lmalloc(size); #else - if (s < (size_t) -1) - p = malloc((size_t) s); + if (size < (size_t) -1) + p = malloc((size_t) size); #endif #endif - ap->ptr = p; return p; } -ACC_LIBFUNC(int, acc_hfree) (acc_alloc_p ap) +ACC_LIBFUNC(int, acc_hfree) (acc_hvoid_p p) { - acc_hvoid_p p; int r = 0; - if (!ap || !ap->ptr) + if (!p) return r; - p = ap->ptr; - ap->ptr = 0; -#if defined(__palmos__) +#if 0 && defined(__palmos__) r = MemPtrFree(p); #elif !defined(ACC_HAVE_MM_HUGE_PTR) free(p); @@ -106,9 +86,9 @@ ACC_LIBFUNC(int, acc_hfree) (acc_alloc_p ap) #elif (ACC_CC_MSC || ACC_CC_WATCOMC) hfree(p); #elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) - _hfree(p); + farfree((void __far*) p); #elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) - farfree((void __far *) p); + farfree((void __far*) p); #elif defined(ACC_CC_AZTECC) lfree(p); #else @@ -120,6 +100,86 @@ ACC_LIBFUNC(int, acc_hfree) (acc_alloc_p ap) } +/*********************************************************************** +// dos_alloc +************************************************************************/ + +#if (ACC_OS_DOS16) +#if !defined(ACC_CC_AZTECC) + +ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size) +{ + void __far* p = 0; + union REGS ri, ro; + + if ((long)size <= 0) + return p; + size = (size + 15) >> 4; + if (size > 0xffffu) + return p; + ri.x.ax = 0x4800; + ri.x.bx = (unsigned short) size; + ro.x.cflag = 1; + int86(0x21, &ri, &ro); + if ((ro.x.cflag & 1) == 0) /* if carry flag not set */ + p = (void __far*) ACC_MK_FP(ro.x.ax, 0); + return p; +} + + +ACC_LIBFUNC(int, acc_dos_free) (void __far* p) +{ + union REGS ri, ro; + struct SREGS rs; + + if (!p) + return 0; + if (ACC_FP_OFF(p) != 0) + return -1; + segread(&rs); + ri.x.ax = 0x4900; + rs.es = ACC_FP_SEG(p); + ro.x.cflag = 1; + int86x(0x21, &ri, &ro, &rs); + if (ro.x.cflag & 1) /* if carry flag set */ + return -1; + return 0; +} + +#endif +#endif + + +#if (ACC_OS_OS216) + +ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size) +{ + void __far* p = 0; + unsigned short sel = 0; + unsigned long pmask = 0xffffu >> ACC_MM_AHSHIFT; /* 8191 */ + + if ((long)size <= 0) + return p; + size = (size + pmask) &~ pmask; /* align up to paragraph size */ + if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0) + p = (void __far*) ACC_MK_FP(sel, 0); + return p; +} + +ACC_LIBFUNC(int, acc_dos_free) (void __far* p) +{ + if (!p) + return 0; + if (ACC_FP_OFF(p) != 0) + return -1; + if (DosFreeSeg(ACC_FP_SEG(p)) != 0) + return -1; + return 0; +} + +#endif + + /*********************************************************************** // huge pointer layer - string.h ************************************************************************/ @@ -211,7 +271,7 @@ ACC_LIBFUNC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len) // huge pointer layer - stdio.h ************************************************************************/ -ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE *fp, acc_hvoid_p buf, acc_hsize_t size) +ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE* fp, acc_hvoid_p buf, acc_hsize_t size) { #if (ACC_HAVE_MM_HUGE_PTR) #if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) @@ -221,7 +281,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE *fp, acc_hvoid_p buf, acc_hsize_t siz while (l < size) { size_t n; - n = FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); if ((acc_hsize_t) n > size - l) n = (size_t) (size - l); n = fread((void __far*)b, 1, n, fp); @@ -240,7 +300,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE *fp, acc_hvoid_p buf, acc_hsize_t siz n = fread(tmp, 1, n, fp); if (n == 0) break; - acc_hmemcpy((acc_hbyte_p)buf + l, tmp, n); + acc_hmemcpy((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n); l += n; } return l; @@ -251,7 +311,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE *fp, acc_hvoid_p buf, acc_hsize_t siz } -ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE *fp, const acc_hvoid_p buf, acc_hsize_t size) +ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE* fp, const acc_hvoid_p buf, acc_hsize_t size) { #if (ACC_HAVE_MM_HUGE_PTR) #if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE) @@ -261,7 +321,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE *fp, const acc_hvoid_p buf, acc_hsiz while (l < size) { size_t n; - n = FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); if ((acc_hsize_t) n > size - l) n = (size_t) (size - l); n = fwrite((void __far*)b, 1, n, fp); @@ -277,7 +337,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE *fp, const acc_hvoid_p buf, acc_hsiz while (l < size) { size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l); - acc_hmemcpy(tmp, (const acc_hbyte_p)buf + l, n); + acc_hmemcpy(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n); n = fwrite(tmp, 1, n, fp); if (n == 0) break; @@ -292,7 +352,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE *fp, const acc_hvoid_p buf, acc_hsiz /*********************************************************************** -// huge pointer layer - stdio.h +// huge pointer layer - read/write ************************************************************************/ #if (ACC_HAVE_MM_HUGE_PTR) @@ -306,7 +366,7 @@ ACC_LIBFUNC(long, acc_hread) (int fd, acc_hvoid_p buf, long size) while (l < size) { unsigned n; - n = FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); if ((long) n > size - l) n = (unsigned) (size - l); n = read(fd, (void __far*)b, n); @@ -329,7 +389,7 @@ ACC_LIBFUNC(long, acc_hread) (int fd, acc_hvoid_p buf, long size) break; if (n < 0) return -1; - acc_hmemcpy((acc_hbyte_p)buf + l, tmp, n); + acc_hmemcpy((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n); l += n; } return l; @@ -346,7 +406,7 @@ ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size) while (l < size) { unsigned n; - n = FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); + n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n); if ((long) n > size - l) n = (unsigned) (size - l); n = write(fd, (void __far*)b, n); @@ -364,7 +424,7 @@ ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size) while (l < size) { int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l); - acc_hmemcpy(tmp, (const acc_hbyte_p)buf + l, n); + acc_hmemcpy(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n); n = write(fd, tmp, n); if (n == 0) break; @@ -383,112 +443,230 @@ ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size) // wrap **************************************************************************/ -#if (ACC_OS_WIN32 || ACC_OS_WIN64) +#if !defined(ACCLIB_USE_OPENDIR) +#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) -ACC_LIBFUNC(int, acc_findfirst) (struct acc_find_t* f, const char* path) +static int acc_opendir_init(struct acc_dir_t* f, const char* path, char* buf, size_t bufsize) { - WIN32_FIND_DATAA d; - HANDLE h; -#if 1 - /* transform to backslashes, and add a '\*' to the directory name */ - char* p = f->f_name; - p[0] = 0; - if (!path[0] || strlen(path) >= sizeof(f->f_name) - 2) + size_t l; + char* p; + f->f_name[0] = 0; + buf[0] = 0; + l = strlen(path); + if (l == 0 || l >= bufsize - 4) return -1; - strcpy(p, path); - for ( ; *p; p++) - if (*p == '/') - *p = '\\'; - if (p[-1] != '\\') - *p++ = '\\'; - *p++ = '*'; - *p = '\0'; - h = FindFirstFileA(f->f_name, &d); -#else - h = FindFirstFileA(path, &d); + strcpy(buf, path); + p = buf + l; + if (p[-1] == ':' || p[-1] == '\\' || p[-1] == '/') + strcpy(p, "*.*"); + else + strcpy(p, "\\*.*"); + return 0; +} + +#endif #endif - f->f_name[0] = 0; - if ((f->u.h = (long) h) == -1) - return -1; - if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name)) - return -1; - strcpy(f->f_name, d.cFileName); - return 0; -} -ACC_LIBFUNC(int, acc_findnext) (struct acc_find_t* f) + +#if (ACCLIB_USE_OPENDIR) + +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path) { - WIN32_FIND_DATAA d; - f->f_name[0] = 0; - if (f->u.h == -1 || FindNextFileA((HANDLE) f->u.h, &d) != 0) - return -1; - if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name)) - return -1; - strcpy(f->f_name, d.cFileName); - return 0; + f->u_dirp = opendir(path); + if (!f->u_dirp) + return -2; + return acc_readdir(f); } -ACC_LIBFUNC(int, acc_findclose) (struct acc_find_t* f) -{ - int r = -1; - if (f->u.h != -1) - r = FindClose((HANDLE) f->u.h); - f->u.h = -1; - return r; -} - - -#elif (HAVE_DIRENT_H) - -ACC_LIBFUNC(int, acc_findfirst) (struct acc_find_t* f, const char* path) -{ - f->u.dirp = opendir(path); - return acc_findnext(f); -} - -ACC_LIBFUNC(int, acc_findnext) (struct acc_find_t* f) +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f) { const struct dirent* dp; f->f_name[0] = 0; - if (!f->u.dirp) + if (!f->u_dirp) return -1; - dp = readdir((DIR*) f->u.dirp); + dp = readdir((DIR*) f->u_dirp); if (!dp) return -1; if (!dp->d_name[0] || strlen(dp->d_name) >= sizeof(f->f_name)) return -1; strcpy(f->f_name, dp->d_name); +#if (ACC_CC_WATCOMC) + ACC_COMPILE_TIME_ASSERT(sizeof(f->f_name) >= sizeof(dp->d_name)) + f->f_time = dp->d_time; + f->f_date = dp->d_date; + f->f_size = dp->d_size; +#endif return 0; } -ACC_LIBFUNC(int, acc_findclose) (struct acc_find_t* f) +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f) { int r = -1; - if (f->u.dirp) - r = closedir((DIR*) f->u.dirp); - f->u.dirp = 0; + if (f->u_dirp) + r = closedir((DIR*) f->u_dirp); + f->u_dirp = 0; return r; } +#elif (ACC_OS_WIN32 || ACC_OS_WIN64) + +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path) +{ + WIN32_FIND_DATAA d; + HANDLE h; + if (acc_opendir_init(f, path, f->f_name, sizeof(f->f_name)) != 0) + return -1; + h = FindFirstFileA(f->f_name, &d); + f->f_name[0] = 0; + if ((f->u_handle = (long) h) == -1) + return -1; + if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name)) + return -1; + strcpy(f->f_name, d.cFileName); + f->f_attr = d.dwFileAttributes; + f->f_size_high = d.nFileSizeHigh; + f->f_size_low = d.nFileSizeLow; + return 0; +} + +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f) +{ + WIN32_FIND_DATAA d; + f->f_name[0] = 0; + if (f->u_handle == -1 || FindNextFileA((HANDLE) f->u_handle, &d) == 0) + return -1; + if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name)) + return -1; + strcpy(f->f_name, d.cFileName); + f->f_attr = d.dwFileAttributes; + f->f_size_high = d.nFileSizeHigh; + f->f_size_low = d.nFileSizeLow; + return 0; +} + +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f) +{ + int r = -1; + if (f->u_handle != -1) + r = FindClose((HANDLE) f->u_handle); + f->u_handle = -1; + return r; +} + + +#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16) + +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path) +{ + char tmp[ACC_FN_PATH_MAX+1]; + int r; + f->u_dirp = 0; + if (acc_opendir_init(f, path, tmp, sizeof(tmp)) != 0) + return -1; +#if (ACC_CC_AZTECC || ACC_CC_PACIFICC) + r = -1; +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + r = findfirst(tmp, (struct ffblk*) f->u_dta, FA_HIDDEN|FA_SYSTEM|FA_RDONLY|FA_DIREC); +#else + r = _dos_findfirst(tmp, _A_HIDDEN|_A_SYSTEM|_A_RDONLY|_A_SUBDIR, (struct find_t*) f->u_dta); +#endif + if (r != 0) f->f_name[0] = 0; + if (!f->f_name[0]) return -1; + f->u_dirp = 1; + return 0; +} + +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f) +{ + int r; + f->f_name[0] = 0; + if (!f->u_dirp) + return -1; +#if (ACC_CC_AZTECC || ACC_CC_PACIFICC) + r = -1; +#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC) + r = findnext((struct ffblk*) f->u_dta); +#else + r = _dos_findnext((struct find_t*) f->u_dta); +#endif + if (r != 0) f->f_name[0] = 0; + if (!f->f_name[0]) return -1; + return 0; +} + +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f) +{ + ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44); + f->f_name[0] = 0; + f->u_dirp = 0; + return 0; +} + + +#elif (ACC_OS_TOS) + +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path) +{ + char tmp[ACC_FN_PATH_MAX+1]; + int r; + DTA* olddta; + f->u_dirp = 0; + if (acc_opendir_init(f, path, tmp, sizeof(tmp)) != 0) + return -1; + olddta = Fgetdta(); + Fsetdta((DTA*) f->u_dta); + r = Fsfirst(tmp, FA_HIDDEN|FA_SYSTEM|FA_READONLY|FA_SUBDIR); + Fsetdta(olddta); + if (r != 0) f->f_name[0] = 0; + if (!f->f_name[0]) return -1; + f->u_dirp = 1; + return 0; +} + +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f) +{ + int r; + DTA* olddta; + f->f_name[0] = 0; + if (!f->u_dirp) + return -1; + olddta = Fgetdta(); + Fsetdta((DTA*) f->u_dta); + r = Fsnext(); + Fsetdta(olddta); + if (r != 0) f->f_name[0] = 0; + if (!f->f_name[0]) return -1; + return 0; +} + +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f) +{ + ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44); + f->f_name[0] = 0; + f->u_dirp = 0; + return 0; +} + + #else -ACC_LIBFUNC(int, acc_findfirst) (struct acc_find_t* f, const char* path) +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path) { ACC_UNUSED(path); f->f_name[0] = 0; - return -1; + return -3; } -ACC_LIBFUNC(int, acc_findnext) (struct acc_find_t* f) +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f) { f->f_name[0] = 0; return -1; } -ACC_LIBFUNC(int, acc_findclose) (struct acc_find_t* f) +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f) { - f->u.dirp = 0; + f->u_dirp = 0; return -1; } @@ -519,7 +697,12 @@ ACC_LIBFUNC(long, acc_get_osfhandle) (int fd) /* FIXME */ return -1; #elif (ACC_OS_WIN32 || ACC_OS_WIN64) +# if (ACC_CC_WATCOMC && __WATCOMC__ < 1100) + /* FIXME */ + return -1; +# else return _get_osfhandle(fd); +# endif #else return fd; #endif @@ -580,20 +763,34 @@ ACC_LIBFUNC(int, acc_set_binmode) (int fd, int binary) ACC_LIBFUNC(int, acc_isatty) (int fd) { -#if (ACC_H_WINDOWS_H) - /* work around naive library implementations that think that + /* work around library implementations that think that * any character device like `nul' is a tty */ - long h = acc_get_osfhandle(fd); - if (h != -1) - { - DWORD d = 0; - int r = GetConsoleMode((HANDLE)h, &d); - if (!r) - return 0; /* GetConsoleMode failed -> not a tty */ - } -#endif if (fd < 0) return 0; +#if (ACC_OS_DOS16 && !defined(ACC_CC_AZTECC)) + { + union REGS ri, ro; + ri.x.ax = 0x4400; + ri.x.bx = fd; + ro.x.ax = 0; + ro.x.cflag = 1; + int86(0x21, &ri, &ro); + if ((ro.x.cflag & 1) == 0) /* if carry flag not set */ + if ((ro.x.ax & 0x83) != 0x83) + return 0; + } +#elif (ACC_H_WINDOWS_H) + { + long h = acc_get_osfhandle(fd); + if (h != -1) + { + DWORD d = 0; + int r = GetConsoleMode((HANDLE)h, &d); + if (!r) + return 0; /* GetConsoleMode failed -> not a tty */ + } + } +#endif return (isatty(fd)) ? 1 : 0; } diff --git a/src/acc/acc_lib.h b/src/acc/acc_lib.h index c818a261..60826a0d 100644 --- a/src/acc/acc_lib.h +++ b/src/acc/acc_lib.h @@ -27,25 +27,27 @@ **************************************************************************/ #if (ACC_HAVE_MM_HUGE_PTR) -# define __acc_huge __huge -# define acc_hsize_t unsigned long +# define acc_hsize_t unsigned long +# define acc_hvoid_p void __huge * +# define acc_hbyte_p unsigned char __huge * +# define acc_hvoid_cp const void __huge * +# define acc_hbyte_cp const unsigned char __huge * #else -# define __acc_huge -# define acc_hsize_t size_t +# define acc_hsize_t size_t +# define acc_hvoid_p void * +# define acc_hbyte_p unsigned char * +# define acc_hvoid_cp const void * +# define acc_hbyte_cp const unsigned char * #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 * +/* halloc */ +ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_hsize_t size); +ACC_LIBFUNC(int, acc_hfree) (acc_hvoid_p p); -/* 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); +#if (ACC_OS_DOS16 || ACC_OS_OS216) +ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size); +ACC_LIBFUNC(int, acc_dos_free) (void __far* p); +#endif /* string */ ACC_LIBFUNC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len); @@ -54,33 +56,96 @@ ACC_LIBFUNC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, ACC_LIBFUNC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len); /* stdio */ -ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE *fp, acc_hvoid_p buf, acc_hsize_t size); -ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE *fp, const acc_hvoid_p buf, acc_hsize_t size); +ACC_LIBFUNC(acc_hsize_t, acc_hfread) (FILE* fp, acc_hvoid_p buf, acc_hsize_t size); +ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE* fp, const acc_hvoid_p buf, acc_hsize_t size); #if (ACC_HAVE_MM_HUGE_PTR) ACC_LIBFUNC(long, acc_hread) (int fd, acc_hvoid_p buf, long size); ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size); #endif +/************************************************************************* +// wrap filename limits +**************************************************************************/ + +/* maximum length of full pathname (excl. '\0') */ +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +# define ACC_FN_PATH_MAX 143 +#elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN32 || ACC_OS_WIN64) +# define ACC_FN_PATH_MAX 259 +#elif (ACC_OS_TOS) +# define ACC_FN_PATH_MAX 259 +#else +# define ACC_FN_PATH_MAX 1024 +#endif + +/* maximum length of a filename (a single path component) (excl. '\0') */ +#if (ACC_OS_DOS16 || ACC_OS_WIN16) +# define ACC_FN_NAME_MAX 12 +#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC)) +# define ACC_FN_NAME_MAX 12 +#elif (ACC_OS_DOS32 && defined(__DJGPP__)) +#elif (ACC_OS_DOS32) +# define ACC_FN_NAME_MAX 12 +#endif + +#if !defined(ACC_FN_NAME_MAX) +# define ACC_FN_NAME_MAX ACC_FN_PATH_MAX +#endif + + /************************************************************************* // wrap **************************************************************************/ -struct acc_find_t +#undef ACCLIB_USE_OPENDIR +#if (HAVE_DIRENT_H || ACC_CC_WATCOMC) +# define ACCLIB_USE_OPENDIR 1 +# if (ACC_OS_DOS32 && defined(__BORLANDC__)) +# elif (ACC_OS_DOS32 && defined(__DJGPP__)) +# elif (ACC_OS_OS2 || ACC_OS_OS216) +# elif (ACC_OS_TOS && ACC_CC_GNUC) +# elif (ACC_OS_WIN32 && !defined(ACC_H_WINDOWS_H)) +# elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +# undef ACCLIB_USE_OPENDIR +# endif +#endif + + +struct acc_dir_t { - union { acc_hvoid_p dirp; long h; } u; /* private */ -#if (ACC_OS_DOS16 || ACC_OS_WIN16) - char f_name[8+1+3+1]; -#elif (ACC_DOS32 || ACC_OS_WIN32 || ACC_OS_WIN64) - char f_name[259+1]; +#if (ACCLIB_USE_OPENDIR) + void *u_dirp; /* private */ +# if (ACC_CC_WATCOMC) + unsigned short f_time; + unsigned short f_date; + unsigned long f_size; +# endif + char f_name[ACC_FN_NAME_MAX+1]; +#elif (ACC_OS_WIN32 || ACC_OS_WIN64) + long u_handle; /* private */ + unsigned f_attr; + unsigned f_size_low; + unsigned f_size_high; + char f_name[ACC_FN_NAME_MAX+1]; +#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_TOS || ACC_OS_WIN16) + char u_dta[21]; /* private */ + unsigned char f_attr; + unsigned short f_time; + unsigned short f_date; + unsigned short f_size_low; + unsigned short f_size_high; + char f_name[ACC_FN_NAME_MAX+1]; + char u_dirp; /* private */ #else - char f_name[1024+1]; + void *u_dirp; /* private */ + char f_name[ACC_FN_NAME_MAX+1]; #endif }; -ACC_LIBFUNC(int, acc_findfirst) (struct acc_find_t* f, const char* path); -ACC_LIBFUNC(int, acc_findnext) (struct acc_find_t* f); -ACC_LIBFUNC(int, acc_findclose) (struct acc_find_t* f); +ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* d, const char* path); +ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* d); +ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* d); /************************************************************************* @@ -105,7 +170,7 @@ ACC_LIBFUNC(int, acc_findclose) (struct acc_find_t* f); #if defined(__CYGWIN__) || defined(__MINGW32__) # define acc_alloca(x) __builtin_alloca((x)) #elif defined(__BORLANDC__) && defined(__linux__) - /* FIXME: this does not work */ + /* FIXME: alloca does not work */ #elif (HAVE_ALLOCA) # define acc_alloca(x) alloca((x)) #endif diff --git a/src/acc/acc_mm.h b/src/acc/acc_mm.h index 6a1364ad..036b1d54 100644 --- a/src/acc/acc_mm.h +++ b/src/acc/acc_mm.h @@ -32,7 +32,7 @@ #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define ACC_MM_TINY 1 -#elif defined(__HUGE__) || defined(M_I86HM) || defined(_M_I86HM) +#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) # define ACC_MM_HUGE 1 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) # define ACC_MM_SMALL 1 @@ -66,9 +66,6 @@ #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) @@ -76,32 +73,38 @@ # undef ACC_HAVE_MM_HUGE_ARRAY #elif (ACC_CC_DMC || ACC_CC_SYMANTECC) # undef ACC_HAVE_MM_HUGE_ARRAY +#elif (ACC_CC_MSC && defined(_QC)) +# undef ACC_HAVE_MM_HUGE_ARRAY +# if (_MSC_VER < 600) +# undef ACC_HAVE_MM_HUGE_PTR +# endif #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 + /* pointer arithmetics with __huge arrays seems completely + * broken in OpenWatcom 1.0 */ # 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 +#if (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0200) + extern void __near _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC) + extern void __near _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_MSC || ACC_CC_TOPSPEEDC) + extern void __near _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif (ACC_CC_TURBOC && __TURBOC__ >= 0x0295) + extern void __near _AHSHIFT(void); +# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT) +#elif ((ACC_CC_AZTECC || ACC_CC_PACIFICC || 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 diff --git a/src/acc/acc_os.h b/src/acc/acc_os.h index a8ec21ae..b89448d9 100644 --- a/src/acc/acc_os.h +++ b/src/acc/acc_os.h @@ -17,22 +17,24 @@ * Operating System - exactly one of: * * ACC_OS_POSIX [default] + * ACC_OS_AMIGAOS * ACC_OS_BEOS * ACC_OS_CYGWIN hybrid WIN32 and POSIX * ACC_OS_DOS16 16-bit DOS (segmented memory model) * ACC_OS_DOS32 * ACC_OS_EMX hybrid OS/2, DOS32, WIN32 (with RSX) and POSIX - * ACC_OS_MAC9 Macintosh Classic + * ACC_OS_MACCLASSIC Macintosh Classic * ACC_OS_MACOSX Mac OS/X * ACC_OS_PALMOS * ACC_OS_OS2 OS/2 * ACC_OS_OS216 16-bit OS/2 1.x (segmented memory model) * ACC_OS_QNX + * ACC_OS_RISCOS * ACC_OS_TOS Atari TOS / MiNT * ACC_OS_VMS * ACC_OS_WIN16 16-bit Windows 3.x (segmented memory model) * ACC_OS_WIN32 - * ACC_OS_WIN64 + * ACC_OS_WIN64 64-bit Windows (LLP64 programming model) */ @@ -42,47 +44,68 @@ #elif defined(__EMX__) && defined(__GNUC__) # define ACC_OS_EMX 1 # define ACC_INFO_OS "emx" +#elif defined(__QNX__) +# define ACC_OS_QNX 1 +# define ACC_INFO_OS "qnx" +#elif defined(__BORLANDC__) && defined(__DPMI32__) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" +#elif defined(__BORLANDC__) && defined(__DPMI16__) +# define ACC_OS_DOS16 1 +# define ACC_INFO_OS "dos16" +#elif defined(__ZTC__) && defined(DOS386) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" +#elif defined(__OS2__) || defined(__OS2V2__) +# if (UINT_MAX == ACC_0xffffL) +# define ACC_OS_OS216 1 +# define ACC_INFO_OS "os216" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_OS2 1 +# define ACC_INFO_OS "os2" +# else +# error "check your limits.h header" +# endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define ACC_OS_WIN64 1 # define ACC_INFO_OS "win64" -#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) -# define ACC_OS_WIN32 1 -# define ACC_INFO_OS "win32" -#elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) +#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) # define ACC_OS_WIN32 1 # define ACC_INFO_OS "win32" #elif defined(__MWERKS__) && defined(__INTEL__) # define ACC_OS_WIN32 1 # define ACC_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# if (UINT_MAX == ACC_0xffffffffL) -# define ACC_OS_WIN32 1 -# define ACC_INFO_OS "win32" -# elif (UINT_MAX == ACC_0xffffL) +# if (UINT_MAX == ACC_0xffffL) # define ACC_OS_WIN16 1 # define ACC_INFO_OS "win16" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" # else # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) -# if (UINT_MAX == ACC_0xffffffffL) -# define ACC_OS_DOS32 1 -# define ACC_INFO_OS "dos32" -# elif (UINT_MAX == ACC_0xffffL) +# if (UINT_MAX == ACC_0xffffL) # define ACC_OS_DOS16 1 # define ACC_INFO_OS "dos16" +# elif (UINT_MAX == ACC_0xffffffffL) +# define ACC_OS_DOS32 1 +# define ACC_INFO_OS "dos32" # else # error "check your limits.h header" # endif -#elif defined(__OS2__) || defined(__OS2V2__) -# if (UINT_MAX == ACC_0xffffffffL) -# define ACC_OS_OS2 1 -# define ACC_INFO_OS "os2" -# elif (UINT_MAX == ACC_0xffffL) -# define ACC_OS_OS216 1 -# define ACC_INFO_OS "os216" +#elif defined(__WATCOMC__) +# if defined(__NT__) && (UINT_MAX == ACC_0xffffL) + /* wcl: NT host defaults to DOS target */ +# define ACC_OS_DOS16 1 +# define ACC_INFO_OS "dos16" +# elif defined(__NT__) && (__WATCOMC__ < 1100) + /* wcl386: Watcom C 11 defines _WIN32 */ +# define ACC_OS_WIN32 1 +# define ACC_INFO_OS "win32" # else -# error "check your limits.h header" +# error "please specify a target using the -bt compiler option" # endif #elif defined(__palmos__) # if (UINT_MAX == ACC_0xffffL) @@ -94,15 +117,12 @@ #elif defined(__TOS__) || defined(__atarist__) # define ACC_OS_TOS 1 # define ACC_INFO_OS "tos" -#elif defined(__QNX__) -# define ACC_OS_QNX 1 -# define ACC_INFO_OS "qnx" #elif defined(__MACOSX__) # define ACC_OS_MACOSX 1 # define ACC_INFO_OS "macosx" #elif defined(macintosh) -# define ACC_OS_MACOS9 1 -# define ACC_INFO_OS "macos9" +# define ACC_OS_MACCLASSIC 1 +# define ACC_INFO_OS "macclassic" #elif defined(__VMS) # define ACC_OS_VMS 1 # define ACC_INFO_OS "vms" @@ -159,6 +179,9 @@ # if (UINT_MAX != ACC_0xffffL) # error "this should not happen" # endif +# if (ULONG_MAX != ACC_0xffffffffL) +# error "this should not happen" +# endif #endif #if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32 || ACC_OS_WIN64) # if (UINT_MAX != ACC_0xffffffffL)