New ACC version.

committer: mfx <mfx> 1058449640 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2003-07-17 13:47:20 +00:00
parent 03f1f615e5
commit 268e13c572
9 changed files with 649 additions and 49 deletions

View File

@ -26,7 +26,7 @@
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED
#define ACC_VERSION 20030713L
#define ACC_VERSION 20030717L
#if !defined(ACC_CONFIG_INCLUDE)
# define ACC_CONFIG_INCLUDE(file) file

View File

@ -74,7 +74,7 @@
#if (ACC_OS_POSIX)
# define HAVE_STRINGS_H 1
# if (ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_OPENBSD)
# if (ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_MACOSX || ACC_OS_POSIX_OPENBSD)
# undef HAVE_MALLOC_H /* deprecated */
# elif (ACC_OS_POSIX_HPUX)
# define HAVE_ALLOCA_H 1
@ -265,7 +265,7 @@
#define HAVE_UTIME 1
#define HAVE_VSNPRINTF 1
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_MACOSX || ACC_OS_POSIX)
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_POSIX)
# define HAVE_STRCASECMP 1
# define HAVE_STRNCASECMP 1
#else
@ -476,11 +476,14 @@
#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 && defined(__linux__)))
# 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
#elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0550))
/* info: unsigned __int64 is broken in 0x0520 */
#elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0520))
/* WARNING: unsigned __int64 is somewhat broken in 0x0520 */
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && __WATCOMC__ >= 1100))
@ -489,7 +492,7 @@
#elif (ACC_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_CC_GNUC && (SIZEOF_LONG < 8))
#elif (ACC_CC_GNUC && ((SIZEOF_LONG) > 0 && (SIZEOF_LONG) < 8))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#endif

View File

@ -64,6 +64,7 @@
# define ACC_INFO_CC "Microsoft C"
# define ACC_INFO_CCVER ACC_MACRO_EXPAND(_MSC_VER)
#elif defined(__MWERKS__)
/* FIXME */
# define ACC_CC_MWERKS 1
# define ACC_INFO_CC "Metrowerks C"
# define ACC_INFO_CCVER "unknown"

343
src/acc/acc_chk.ch Normal file
View File

@ -0,0 +1,343 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2003 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*************************************************************************
//
**************************************************************************/
#if !defined(ACCCHK_ASSERT)
# define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr)
#endif
/* compile-time sign */
#if !defined(ACCCHK_ASSERT_SIGN)
# define ACCCHK_ASSERT_SIGN(type, relop) \
ACCCHK_ASSERT( (type) (-1) relop (type) 0 ) \
ACCCHK_ASSERT( (type) (~(type)0) relop (type) 0 ) \
ACCCHK_ASSERT( (type) (~(type)0) == (type) (-1) )
#endif
#if !defined(ACCCHK_IS_SIGNED)
# define ACCCHK_ASSERT_IS_SIGNED(type) ACCCHK_ASSERT_SIGN(type,<)
#endif
#if !defined(ACCCHK_IS_UNSIGNED)
# if (ACC_BROKEN_INTEGRAL_PROMOTION)
# define ACCCHK_ASSERT_IS_UNSIGNED(type) \
ACCCHK_ASSERT( (type) (-1) > (type) 0 )
# else
# define ACCCHK_ASSERT_IS_UNSIGNED(type) ACCCHK_ASSERT_SIGN(type,>)
# endif
#endif
/*************************************************************************
// check preprocessor
**************************************************************************/
#if (ACC_0xffffffffL - ACC_UINT32L_C(4294967294) != 1)
# error "preprocessor error 1"
#endif
#if (ACC_0xffffffffL - ACC_UINT32L_C(0xfffffffd) != 2)
# error "preprocessor error 2"
#endif
#define ACCCHK_VAL 1
#define ACCCHK_TMP1 ACCCHK_VAL
#undef ACCCHK_VAL
#define ACCCHK_VAL 2
#define ACCCHK_TMP2 ACCCHK_VAL
#if (ACCCHK_TMP1 != 2)
# error "preprocessor error 3a"
#endif
#if (ACCCHK_TMP2 != 2)
# error "preprocessor error 3b"
#endif
#undef ACCCHK_VAL
#if (ACCCHK_TMP2)
# error "preprocessor error 3c"
#endif
#if (ACCCHK_TMP2 + 0 != 0)
# error "preprocessor error 3d"
#endif
#undef ACCCHK_TMP1
#undef ACCCHK_TMP2
/*************************************************************************
// check basic arithmetics
**************************************************************************/
ACCCHK_ASSERT(__ACC_INT_MAX(2) == 1)
ACCCHK_ASSERT(__ACC_INT_MAX(8) == 127)
ACCCHK_ASSERT(__ACC_INT_MAX(16) == 32767)
ACCCHK_ASSERT(__ACC_UINT_MAX(2) == 3)
ACCCHK_ASSERT(__ACC_UINT_MAX(16) == 0xffffU)
ACCCHK_ASSERT(__ACC_UINT_MAX(32) == 0xffffffffUL)
#if !defined(ACC_BROKEN_INTEGRAL_PROMOTION)
ACCCHK_ASSERT(__ACC_UINT_MAX(__ACC_INT_BIT) == ~(0u))
ACCCHK_ASSERT(__ACC_UINT_MAX(__ACC_LONG_BIT) == ~(0ul))
#endif
/*************************************************************************
// check basic types
**************************************************************************/
ACCCHK_ASSERT_IS_SIGNED(signed char)
ACCCHK_ASSERT_IS_UNSIGNED(unsigned char)
ACCCHK_ASSERT(sizeof(signed char) == sizeof(char))
ACCCHK_ASSERT(sizeof(unsigned char) == sizeof(char))
ACCCHK_ASSERT(sizeof(char) == 1)
ACCCHK_ASSERT(sizeof(char) == sizeof((char)0))
#if defined(__cplusplus)
ACCCHK_ASSERT(sizeof('\0') == sizeof(char))
#else
# if (ACC_CC_DMC)
/* Digital Mars is broken */
# else
ACCCHK_ASSERT(sizeof('\0') == sizeof(int))
# endif
#endif
ACCCHK_ASSERT_IS_SIGNED(short)
ACCCHK_ASSERT_IS_UNSIGNED(unsigned short)
ACCCHK_ASSERT(sizeof(short) == sizeof(unsigned short))
ACCCHK_ASSERT(sizeof(short) >= 2)
ACCCHK_ASSERT(sizeof(short) >= sizeof(char))
ACCCHK_ASSERT(sizeof(short) == sizeof((short)0))
#if (SIZEOF_SHORT > 0)
ACCCHK_ASSERT(sizeof(short) == SIZEOF_SHORT)
#endif
ACCCHK_ASSERT_IS_SIGNED(int)
ACCCHK_ASSERT_IS_UNSIGNED(unsigned int)
ACCCHK_ASSERT(sizeof(int) == sizeof(unsigned int))
ACCCHK_ASSERT(sizeof(int) >= 2)
ACCCHK_ASSERT(sizeof(int) >= sizeof(short))
ACCCHK_ASSERT(sizeof(int) == sizeof(0))
ACCCHK_ASSERT(sizeof(int) == sizeof((int)0))
#if (SIZEOF_INT > 0)
ACCCHK_ASSERT(sizeof(int) == SIZEOF_INT)
#endif
ACCCHK_ASSERT_IS_SIGNED(long)
ACCCHK_ASSERT_IS_UNSIGNED(unsigned long)
ACCCHK_ASSERT(sizeof(long) == sizeof(unsigned long))
ACCCHK_ASSERT(sizeof(long) >= 4)
ACCCHK_ASSERT(sizeof(long) >= sizeof(int))
ACCCHK_ASSERT(sizeof(long) == sizeof(0L))
ACCCHK_ASSERT(sizeof(long) == sizeof((long)0))
#if (SIZEOF_LONG > 0)
ACCCHK_ASSERT(sizeof(long) == SIZEOF_LONG)
#endif
ACCCHK_ASSERT_IS_UNSIGNED(size_t)
ACCCHK_ASSERT(sizeof(size_t) >= sizeof(int))
ACCCHK_ASSERT(sizeof(size_t) == sizeof(sizeof(0))) /* sizeof() returns size_t */
#if (SIZEOF_SIZE_T > 0)
ACCCHK_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T)
#endif
ACCCHK_ASSERT_IS_SIGNED(ptrdiff_t)
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
#if !defined(ACC_BROKEN_SIZEOF)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof((char*)0 - (char*)0))
# if (ACC_HAVE_MM_HUGE_PTR)
ACCCHK_ASSERT(4 == sizeof((char __huge*)0 - (char __huge*)0))
# endif
#endif
#if (SIZEOF_PTRDIFF_T > 0)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T)
#endif
ACCCHK_ASSERT(sizeof(void*) >= sizeof(char*))
#if (SIZEOF_VOID_P > 0)
ACCCHK_ASSERT(sizeof(void*) == SIZEOF_VOID_P)
#endif
#if (SIZEOF_CHAR_P > 0)
ACCCHK_ASSERT(sizeof(char*) == SIZEOF_CHAR_P)
#endif
#if (ACC_HAVE_MM_HUGE_PTR)
ACCCHK_ASSERT(4 == sizeof(void __huge*))
ACCCHK_ASSERT(4 == sizeof(char __huge*))
#endif
/*************************************************************************
// check arithmetics
**************************************************************************/
ACCCHK_ASSERT((((1u << 15) + 1) >> 15) == 1)
ACCCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1)
#if (ACC_CC_TURBOC && (__TURBOC__ < 0x0150))
/* TC 1.0 bug, probably due to ACC_BROKEN_INTEGRAL_PROMOTION ?? */
#else
ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0)
#endif
ACCCHK_ASSERT((1u << (8*SIZEOF_INT-1)) > 0)
ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0)
ACCCHK_ASSERT((1ul << (8*SIZEOF_LONG-1)) > 0)
#if defined(acc_int32e_t)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == 4)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == SIZEOF_ACC_INT32E_T)
ACCCHK_ASSERT(sizeof(acc_uint32e_t) == 4)
ACCCHK_ASSERT(sizeof(acc_uint32e_t) == SIZEOF_ACC_UINT32E_T)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == sizeof(acc_uint32e_t))
ACCCHK_ASSERT_IS_SIGNED(acc_int32e_t)
ACCCHK_ASSERT(((( (acc_int32e_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32E_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED(acc_uint32e_t)
ACCCHK_ASSERT(((( (acc_uint32e_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32E_C(1) << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT( (acc_int32e_t) (1 + ~(acc_int32e_t)0) == 0)
#if defined(ACCCHK_PEDANTIC)
/* compiler may warn about overflow */
ACCCHK_ASSERT( (acc_uint32e_t)(1 + ~(acc_uint32e_t)0) == 0)
#endif
ACCCHK_ASSERT((ACC_INT32E_C(1) << (8*SIZEOF_ACC_INT32E_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32E_C(1) << (8*SIZEOF_ACC_INT32E_T-1)) > 0)
ACCCHK_ASSERT(ACC_INT32E_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32E_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32E_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32E_C(4294967295) == ACC_0xffffffffL)
#endif
ACCCHK_ASSERT(sizeof(acc_int32l_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_int32l_t) == SIZEOF_ACC_INT32L_T)
ACCCHK_ASSERT(sizeof(acc_uint32l_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_uint32l_t) == SIZEOF_ACC_UINT32L_T)
ACCCHK_ASSERT(sizeof(acc_int32l_t) == sizeof(acc_uint32l_t))
ACCCHK_ASSERT_IS_SIGNED(acc_int32l_t)
ACCCHK_ASSERT(((( (acc_int32l_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32L_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED(acc_uint32l_t)
ACCCHK_ASSERT(((( (acc_uint32l_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32L_C(1) << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT((ACC_INT32L_C(1) << (8*SIZEOF_ACC_INT32L_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32L_C(1) << (8*SIZEOF_ACC_INT32L_T-1)) > 0)
ACCCHK_ASSERT(ACC_INT32L_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32L_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32L_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32L_C(4294967295) == ACC_0xffffffffL)
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32l_t))
ACCCHK_ASSERT(sizeof(acc_int32f_t) == SIZEOF_ACC_INT32F_T)
ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= sizeof(acc_uint32l_t))
ACCCHK_ASSERT(sizeof(acc_uint32f_t) == SIZEOF_ACC_UINT32F_T)
ACCCHK_ASSERT(sizeof(acc_int32f_t) == sizeof(acc_uint32f_t))
ACCCHK_ASSERT_IS_SIGNED(acc_int32f_t)
ACCCHK_ASSERT(((( (acc_int32f_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32F_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED(acc_uint32f_t)
ACCCHK_ASSERT(((( (acc_uint32f_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32F_C(1) << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT((ACC_INT32F_C(1) << (8*SIZEOF_ACC_INT32F_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32F_C(1) << (8*SIZEOF_ACC_INT32F_T-1)) > 0)
ACCCHK_ASSERT(ACC_INT32F_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32F_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32F_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32F_C(4294967295) == ACC_0xffffffffL)
#if defined(acc_int64l_t)
ACCCHK_ASSERT(sizeof(acc_int64l_t) >= 8)
ACCCHK_ASSERT(sizeof(acc_int64l_t) == SIZEOF_ACC_INT64L_T)
ACCCHK_ASSERT(sizeof(acc_uint64l_t) >= 8)
ACCCHK_ASSERT(sizeof(acc_uint64l_t) == SIZEOF_ACC_UINT64L_T)
ACCCHK_ASSERT(sizeof(acc_int64l_t) == sizeof(acc_uint64l_t))
ACCCHK_ASSERT_IS_SIGNED(acc_int64l_t)
ACCCHK_ASSERT(((( (acc_int64l_t)1 << 62) + 1) >> 62) == 1)
ACCCHK_ASSERT(((( ACC_INT64L_C(1) << 62) + 1) >> 62) == 1)
#if (ACC_CC_BORLANDC && (__BORLANDC__ <= 0x0520))
#else
ACCCHK_ASSERT_IS_UNSIGNED(acc_uint64l_t)
ACCCHK_ASSERT(ACC_UINT64L_C(18446744073709551615) > 0)
#endif
ACCCHK_ASSERT(((( (acc_uint64l_t)1 << 63) + 1) >> 63) == 1)
ACCCHK_ASSERT(((( ACC_UINT64L_C(1) << 63) + 1) >> 63) == 1)
ACCCHK_ASSERT((ACC_INT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) > 0)
ACCCHK_ASSERT(ACC_INT64L_C(9223372036854775807) > 0)
ACCCHK_ASSERT(ACC_INT64L_C(-9223372036854775807) - 1 < 0)
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483629l == 721)
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483647l == 1)
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483629ul == 721)
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483647ul == 1)
#endif
/*************************************************************************
// check memory model ACC_MM
**************************************************************************/
#if (ACC_MM_FLAT)
ACCCHK_ASSERT(sizeof(void*) == sizeof(void (*)(void)))
#endif
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
ACCCHK_ASSERT(sizeof(void*) == 2)
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
ACCCHK_ASSERT(sizeof(void*) == 4)
#endif
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_COMPACT)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 2)
#elif (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 4)
#endif
/*************************************************************************
// check promotion rules
**************************************************************************/
/* check that the compiler correctly casts signed to unsigned */
ACCCHK_ASSERT( (int) ((unsigned char) ((signed char) -1)) == 255)
#if !defined(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
/* check that the compiler correctly promotes integrals */
ACCCHK_ASSERT(sizeof(int) == SIZEOF_INT)
ACCCHK_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0)
#endif
/*
vi:ts=4:et
*/

View File

@ -19,7 +19,7 @@
************************************************************************/
/* workaround for preprocessor bugs in some compilers */
#if defined(_MSC_VER)
#if 0
#define ACC_0xffffL 0xfffful
#define ACC_0xffffffffL 0xfffffffful
#else
@ -28,16 +28,19 @@
#endif
/* some things we cannot work around */
#if 0
#if (ACC_0xffffL == ACC_0xffffffffL)
# error "your preprocessor is broken 1"
#endif
#if (32767 >= 4294967295ul)
#if (16ul * 16384ul != 262144ul)
# error "your preprocessor is broken 2"
#endif
#if (65535u >= 4294967295ul)
#if 0
#if (32767 >= 4294967295ul)
# error "your preprocessor is broken 3"
#endif
#if (65535u >= 4294967295ul)
# error "your preprocessor is broken 4"
#endif
#endif
@ -47,8 +50,8 @@
#if (UINT_MAX == ACC_0xffffL)
#if defined(__ZTC__) && defined(__I86__)
# if !defined(__DOS__) && !defined(__OS2__)
# define __DOS__ 1
# if !defined(_MSDOS) && !defined(__OS2__)
# define _MSDOS 1
# endif
#elif defined(__VERSION) && defined(MB_LEN_MAX)
# if (__VERSION == 520) && (MB_LEN_MAX == 1)
@ -142,18 +145,31 @@
#if (UINT_MAX == ACC_0xffffL)
#if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0200)
# define ACC_BROKEN_SIZEOF 1
#if defined(__MSDOS__) && defined(__TURBOC__)
# if (__TURBOC__ < 0x0150)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
# 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
# if(__TURBOC__ < 0x0200)
# define ACC_BROKEN_SIZEOF 1
# endif
#elif defined(MSDOS) && defined(_MSC_VER)
# if (_MSC_VER < 600)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
# endif
# if (_MSC_VER < 700)
# define ACC_BROKEN_INTEGRAL_PROMOTION 1
# define ACC_BROKEN_SIZEOF 1
# endif
#elif defined(__PACIFIC__) && defined(DOS)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
#elif defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__))
# define ACC_BROKEN_SIZEOF 1
#endif
#endif
#if defined(__WATCOMC__) && (__WATCOMC__ < 900)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
#endif
/***********************************************************************

View File

@ -797,16 +797,16 @@ ACC_LIBFUNC(int, acc_isatty) (int fd)
ACC_LIBFUNC(int, acc_mkdir) (const char* name, unsigned mode)
{
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_EMX || ACC_OS_MACOSX || ACC_OS_POSIX)
return mkdir(name, mode);
#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
ACC_UNUSED(mode);
return Dcreate(name);
#elif defined(__DJGPP__) || (ACC_OS_TOS)
#elif defined(__DJGPP__)
return mkdir(name, mode);
#else
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
ACC_UNUSED(mode);
return mkdir(name);
#else
return mkdir(name, mode);
#endif
}
@ -818,6 +818,58 @@ ACC_LIBFUNC(int, acc_response) (int* argc, char*** argv)
#endif
/*************************************************************************
// some linear congruential pseudo random number generators (PRNG)
**************************************************************************/
ACC_LIBFUNC(void, acc_srand31) (acc_rand31_t* r, acc_uint32l_t seed)
{
r->seed = seed & ACC_UINT32L_C(0xffffffff);
}
ACC_LIBFUNC(acc_uint32l_t, acc_rand31) (acc_rand31_t* r)
{
r->seed = (r->seed * ACC_UINT32L_C(1103515245)) + 12345;
r->seed &= ACC_UINT32L_C(0x7fffffff);
return r->seed;
}
#if defined(acc_uint64l_t)
ACC_LIBFUNC(void, acc_srand48) (acc_rand48_t* r, acc_uint32l_t seed)
{
r->seed = seed & ACC_UINT32L_C(0xffffffff);
r->seed <<= 16; r->seed |= 0x330e;
}
ACC_LIBFUNC(acc_uint32l_t, acc_rand48) (acc_rand48_t* r)
{
r->seed = (r->seed * ACC_UINT64L_C(25214903917)) + 11;
r->seed &= ACC_UINT64L_C(0xffffffffffff);
return (acc_uint32l_t) (r->seed >> 17);
}
#endif /* defined(acc_uint64l_t) */
#if defined(acc_uint64l_t)
ACC_LIBFUNC(void, acc_srand64) (acc_rand64_t* r, acc_uint64l_t seed)
{
r->seed = seed & ACC_UINT64L_C(0xffffffffffffffff);
}
ACC_LIBFUNC(acc_uint32l_t, acc_rand64) (acc_rand64_t* r)
{
r->seed = (r->seed * ACC_UINT64L_C(6364136223846793005)) + 1;
r->seed &= ACC_UINT64L_C(0xffffffffffffffff);
return (acc_uint32l_t) (r->seed >> 33);
}
#endif /* defined(acc_uint64l_t) */
/*
vi:ts=4:et
*/

View File

@ -181,6 +181,30 @@ 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);
typedef struct {
acc_uint32l_t seed;
} acc_rand31_t;
ACC_LIBFUNC(void, acc_srand31) (acc_rand31_t* r, acc_uint32l_t seed);
ACC_LIBFUNC(acc_uint32l_t, acc_rand31) (acc_rand31_t* r);
#if defined(acc_uint64l_t)
typedef struct {
acc_uint64l_t seed;
} acc_rand48_t;
ACC_LIBFUNC(void, acc_srand48) (acc_rand48_t* r, acc_uint32l_t seed);
ACC_LIBFUNC(acc_uint32l_t, acc_rand48) (acc_rand48_t* r);
#endif /* defined(acc_uint64l_t) */
#if defined(acc_uint64l_t)
typedef struct {
acc_uint64l_t seed;
} acc_rand64_t;
ACC_LIBFUNC(void, acc_srand64) (acc_rand64_t* r, acc_uint64l_t seed);
ACC_LIBFUNC(acc_uint32l_t, acc_rand64) (acc_rand64_t* r);
#endif /* defined(acc_uint64l_t) */
#endif /* already included */

View File

@ -24,7 +24,6 @@
* ACC_OS_DOS32
* ACC_OS_EMX hybrid OS/2, DOS32, WIN32 (with RSX) and POSIX
* 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)
@ -117,9 +116,6 @@
#elif defined(__TOS__) || defined(__atarist__)
# define ACC_OS_TOS 1
# define ACC_INFO_OS "tos"
#elif defined(__MACOSX__)
# define ACC_OS_MACOSX 1
# define ACC_INFO_OS "macosx"
#elif defined(macintosh)
# define ACC_OS_MACCLASSIC 1
# define ACC_INFO_OS "macclassic"
@ -136,6 +132,9 @@
# if defined(_AIX) || defined(__AIX__) || defined(__aix__)
# define ACC_OS_POSIX_AIX 1
# define ACC_INFO_OS_POSIX "aix"
# elif defined(__APPLE__)
# define ACC_OS_POSIX_MACOSX 1
# define ACC_INFO_OS_POSIX "macosx"
# elif defined(__FreeBSD__)
# define ACC_OS_POSIX_FREEBSD 1
# define ACC_INFO_OS_POSIX "freebsd"

View File

@ -30,27 +30,180 @@ __acc_gnuc_extension__ typedef long long acc_llong_t;
__acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#endif
/* acc_int64l_t is int_least64_t in <stdint.h> terminology */
#if (SIZEOF_LONG >= 8)
# define acc_int64l_t long int
# define acc_uint64l_t unsigned long int
#elif (SIZEOF_LONG_LONG >= 8 && SIZEOF_UNSIGNED_LONG_LONG >= 8)
# define acc_int64l_t acc_llong_t
# define acc_uint64l_t acc_ullong_t
#elif (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
# define acc_int64l_t __int64
# define acc_uint64l_t unsigned __int64
/***********************************************************************
// some <stdint.h> types:
// required: least & fast: acc_int32l_t, acc_int32f_t
// optional: exact32 acc_int32e_t
// optional: least64 acc_int64l_t
************************************************************************/
/* acc_int32e_t is int32_t in <stdint.h> terminology */
#if !defined(acc_int32e_t)
#if (SIZEOF_INT == 4)
# define acc_int32e_t int
# define acc_uint32e_t unsigned int
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
#elif (SIZEOF_LONG == 4)
# define acc_int32e_t long int
# define acc_uint32e_t unsigned long int
# define ACC_INT32E_C(c) c##L
# define ACC_UINT32E_C(c) c##UL
#elif (SIZEOF_SHORT == 4)
# define acc_int32e_t short int
# define acc_uint32e_t unsigned short int
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
#elif (SIZEOF_LONG_LONG == 4 && SIZEOF_UNSIGNED_LONG_LONG == 4)
# define acc_int32e_t acc_llong_t
# define acc_uint32e_t acc_ullong_t
# define ACC_INT32E_C(c) c##LL
# define ACC_UINT32E_C(c) c##ULL
#elif (SIZEOF___INT32 == 4 && SIZEOF_UNSIGNED___INT32 == 4)
# define acc_int32e_t __int32
# define acc_uint32e_t unsigned __int32
# if (SIZEOF_INT > 4)
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
# elif (SIZEOF_LONG > 4)
# define ACC_INT32E_C(c) c##L
# define ACC_UINT32E_C(c) c##UL
# else
# define ACC_INT32E_C(c) c##i32
# define ACC_UINT32E_C(c) c##ui32
# endif
#else
/* no exact 32-bit integral type on this machine */
#endif
#endif
#if defined(acc_int32e_t)
# define SIZEOF_ACC_INT32E_T 4
# define SIZEOF_ACC_UINT32E_T 4
#endif
#if !defined(ACC_UINT32_C)
# if (ACC_OS_DOS16 && ACC_CC_PACIFICC)
/* workaround for Pacific C */
# define ACC_UINT32_C(c) c
# elif (UINT_MAX < ACC_0xffffffffL)
# define ACC_UINT32_C(c) c ## UL
/* acc_int32l_t is int_least32_t in <stdint.h> terminology */
#if !defined(acc_int32l_t)
#if defined(acc_int32e_t)
# define acc_int32l_t acc_int32e_t
# define acc_uint32l_t acc_uint32e_t
# define ACC_INT32L_C ACC_INT32E_C
# define ACC_UINT32L_C ACC_UINT32E_C
# define SIZEOF_ACC_INT32L_T SIZEOF_ACC_INT32E_T
# define SIZEOF_ACC_UINT32L_T SIZEOF_ACC_UINT32E_T
#elif (SIZEOF_INT > 4)
# define acc_int32l_t int
# define acc_uint32l_t unsigned int
# define ACC_INT32L_C(c) c
# define ACC_UINT32L_C(c) c##U
# define SIZEOF_ACC_INT32L_T SIZEOF_INT
# define SIZEOF_ACC_UINT32L_T SIZEOF_INT
#elif (SIZEOF_LONG > 4)
# define acc_int32l_t long int
# define acc_uint32l_t unsigned long int
# define ACC_INT32L_C(c) c##L
# define ACC_UINT32L_C(c) c##UL
# define SIZEOF_ACC_INT32L_T SIZEOF_LONG
# define SIZEOF_ACC_UINT32L_T SIZEOF_LONG
#else
# error "acc_int32l_t"
#endif
#endif
/* acc_int32f_t is int_fast32_t in <stdint.h> terminology */
#if !defined(acc_int32f_t)
#if (SIZEOF_INT >= 4)
# define acc_int32f_t int
# define acc_uint32f_t unsigned int
# define ACC_INT32F_C(c) c
# define ACC_UINT32F_C(c) c##U
# define SIZEOF_ACC_INT32F_T SIZEOF_INT
# define SIZEOF_ACC_UINT32F_T SIZEOF_INT
#elif (SIZEOF_LONG >= 4)
# define acc_int32f_t long int
# define acc_uint32f_t unsigned long int
# define ACC_INT32F_C(c) c##L
# define ACC_UINT32F_C(c) c##UL
# define SIZEOF_ACC_INT32F_T SIZEOF_LONG
# define SIZEOF_ACC_UINT32F_T SIZEOF_LONG
#elif defined(acc_int32e_t)
# define acc_int32f_t acc_int32e_t
# define acc_uint32f_t acc_uint32e_t
# define ACC_INT32F_C ACC_INT32E_C
# define ACC_UINT32F_C ACC_UINT32E_C
# define SIZEOF_ACC_INT32F_T SIZEOF_ACC_INT32E_T
# define SIZEOF_ACC_UINT32F_T SIZEOF_ACC_UINT32E_T
#else
# error "acc_int32f_t"
#endif
#endif
/* acc_int64l_t is int_least64_t in <stdint.h> terminology */
#if !defined(acc_int64l_t)
#if (SIZEOF_INT >= 8)
# define acc_int64l_t int
# define acc_uint64l_t unsigned int
# define ACC_INT64L_C(c) c
# define ACC_UINT64L_C(c) c##U
# define SIZEOF_ACC_INT64L_T SIZEOF_INT
# define SIZEOF_ACC_UINT64L_T SIZEOF_INT
#elif (SIZEOF_LONG >= 8)
# define acc_int64l_t long int
# define acc_uint64l_t unsigned long int
# define ACC_INT64L_C(c) c##L
# define ACC_UINT64L_C(c) c##UL
# define SIZEOF_ACC_INT64L_T SIZEOF_LONG
# define SIZEOF_ACC_UINT64L_T SIZEOF_LONG
#elif (SIZEOF_LONG_LONG >= 8 && SIZEOF_UNSIGNED_LONG_LONG >= 8)
# define acc_int64l_t acc_llong_t
# define acc_uint64l_t acc_ullong_t
# define ACC_INT64L_C(c) c##LL
# define ACC_UINT64L_C(c) c##ULL
# define SIZEOF_ACC_INT64L_T SIZEOF_LONG_LONG
# define SIZEOF_ACC_UINT64L_T SIZEOF_LONG_LONG
#elif (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
# define acc_int64l_t __int64
# define acc_uint64l_t unsigned __int64
# if (ACC_CC_BORLANDC)
# define ACC_INT64L_C(c) ((c) + 0i64)
# define ACC_UINT64L_C(c) ((c) + 0ui64)
# else
# define ACC_UINT32_C(c) c ## U
# define ACC_INT64L_C(c) c##i64
# define ACC_UINT64L_C(c) c##ui64
# endif
# define SIZEOF_ACC_INT64L_T SIZEOF___INT64
# define SIZEOF_ACC_UINT64L_T SIZEOF___INT64
#else
/* no least 64-bit integral type on this machine */
#endif
#endif
/* workaround for broken compilers */
#if (ACC_BROKEN_INTEGRAL_CONSTANTS)
# undef ACC_INT32E_C
# undef ACC_UINT32E_C
# undef ACC_INT32L_C
# undef ACC_UINT32L_C
# undef ACC_INT32F_C
# undef ACC_UINT32F_C
# if (SIZEOF_INT == 4)
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) ((c) + 0U)
# define ACC_INT32L_C(c) c
# define ACC_UINT32L_C(c) ((c) + 0U)
# define ACC_INT32F_C(c) c
# define ACC_UINT32F_C(c) ((c) + 0U)
# elif (SIZEOF_LONG == 4)
# define ACC_INT32E_C(c) ((c) + 0L)
# define ACC_UINT32E_C(c) ((c) + 0UL)
# define ACC_INT32L_C(c) ((c) + 0L)
# define ACC_UINT32L_C(c) ((c) + 0UL)
# define ACC_INT32F_C(c) ((c) + 0L)
# define ACC_UINT32F_C(c) ((c) + 0UL)
# endif
#endif
@ -61,11 +214,17 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_GNUC || ACC_CC_PACIFICC)
# elif (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC))
# elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
# define __acc_cdecl __cdecl
# define __acc_cdecl_atexit __pascal
# define __acc_cdecl_atexit
# define __acc_cdecl_main __cdecl
# define __acc_cdecl_qsort __pascal
# if (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC))
# define __acc_cdecl_qsort __pascal
# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC))
# define __acc_cdecl_qsort _stdcall
# else
# define __acc_cdecl_qsort __cdecl
# endif
# elif (ACC_CC_WATCOMC)
# define __acc_cdecl __cdecl
# else
@ -75,8 +234,10 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
# define __acc_cdecl_qsort __cdecl
# endif
# if (ACC_CC_GNUC || ACC_CC_PACIFICC || ACC_CC_WATCOMC)
# elif (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC))
# elif (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC))
# define __acc_cdecl_sighandler __pascal
# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC))
# define __acc_cdecl_sighandler _stdcall
# elif (ACC_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
# if defined(_DLL)
# define __acc_cdecl_sighandler _far _cdecl _loadds
@ -108,14 +269,15 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
# define __acc_cdecl_sighandler
#endif
#if (ACC_CC_AZTECC) || (ACC_CC_TURBOC && __TURBOC__ < 0x150)
#if (ACC_CC_AZTECC) || (ACC_CC_TURBOC && __TURBOC__ < 0x0150)
typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(int);
#elif defined(RETSIGTYPE)
typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(int);
#else
typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(int);
#endif
/*
vi:ts=4:et
*/