1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

New ACC version.

committer: mfx <mfx> 1058788892 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2003-07-21 12:01:32 +00:00
parent 66565f7238
commit bbbea34d74
12 changed files with 193 additions and 132 deletions

View File

@ -16,17 +16,16 @@
/*
* Possible configuration values:
*
* ACC_CONFIG_NO_HEADER
* ACC_CONFIG_HEADER if given, then use this as <config.h>
* ACC_CONFIG_INCLUDE include path to acc_ files
* ACC_CONFIG_FRESSTANDING only use <limits.h> and possibly <stdint.h>
* [use this for embedded targets]
*/
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED
#define ACC_VERSION 20030717L
#define ACC_VERSION 20030720L
#if !defined(ACC_CONFIG_INCLUDE)
# define ACC_CONFIG_INCLUDE(file) file
@ -62,7 +61,8 @@
#include ACC_CONFIG_INCLUDE("acc_arch.h")
#include ACC_CONFIG_INCLUDE("acc_defs.h")
#if defined(ACC_CONFIG_HEADER)
#if defined(ACC_CONFIG_NO_HEADER)
#elif defined(ACC_CONFIG_HEADER)
# include ACC_CONFIG_HEADER
#else
# include ACC_CONFIG_INCLUDE("acc_auto.h")
@ -70,11 +70,6 @@
#include ACC_CONFIG_INCLUDE("acc_type.h")
#if !defined(ACC_CONFIG_FREESTANDING)
# include ACC_CONFIG_INCLUDE("acc_incd.h")
# include ACC_CONFIG_INCLUDE("acc_lib.h")
#endif
#endif /* already included */

View File

@ -497,6 +497,13 @@
# define SIZEOF_UNSIGNED_LONG_LONG 8
#endif
#if defined(__cplusplus) && defined(ACC_CC_GNUC)
# if(ACC_CC_GNUC < 0x020800ul)
# undef SIZEOF_LONG_LONG
# undef SIZEOF_UNSIGNED_LONG_LONG
# endif
#endif
/*************************************************************************
// misc

View File

@ -283,7 +283,7 @@
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))
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
#else
ACCCHK_ASSERT_IS_UNSIGNED(acc_uint64l_t)
ACCCHK_ASSERT(ACC_UINT64L_C(18446744073709551615) > 0)
@ -332,7 +332,6 @@
#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

View File

@ -18,22 +18,55 @@
************************************************************************/
#if !defined(ACC_UNUSED)
# define ACC_UNUSED(var) ((void) &var)
# if (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_GCC)
# define ACC_UNUSED(var) ((void) var)
# else
# define ACC_UNUSED(var) ((void) &var)
# endif
#endif
#if !defined(ACC_UNUSED_FUNC)
# define ACC_UNUSED_FUNC(func) ((void) func)
# if (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# define ACC_UNUSED_FUNC(func) if (func) ; else
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED_FUNC(func) if (func) ; else
# else
# define ACC_UNUSED_FUNC(func) ((void) func)
# endif
#endif
#if !defined(ACC_COMPILE_TIME_ASSERT)
# 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)]; }
/***********************************************************************
// compile-time-assertions
//
// The "switch" version works on all compilers, whereas the "typedef" gets
// ignored or misinterpreted (e.g. implicit cast from -1 to unsigned long)
// on some systems. OTOS, on modern compilers, the "switch" version
// may produce a pedantic warning about "selector expr. is constant".
// Also, the "switch" version must appear in a function body, so you
// cannot use this macro in header files.
************************************************************************/
/* This can be put into a header file but may get ignored by some compilers */
#if !defined(ACC_COMPILE_TIME_ASSERT_HEADER)
# if (ACC_CC_AZTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) {typedef int __acc_cta[1-!(e)];}
# else
# define ACC_COMPILE_TIME_ASSERT(expr) \
{ typedef int __acc_compile_time_assert_fail[1 - 2 * !(expr)]; }
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) {typedef int __acc_cta[1-2*!(e)];}
# endif
#endif
/* This must appear within a function body */
#if !defined(ACC_COMPILE_TIME_ASSERT)
# if (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# else
# define ACC_COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT_HEADER(e)
# endif
#endif
@ -94,7 +127,6 @@
/*
vi:ts=4:et
*/

View File

@ -69,7 +69,7 @@
#endif
/* TOS */
#if defined(__TOS__) && defined(__TURBOC__)
#if defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__))
# include <ext.h>
#endif

View File

@ -58,8 +58,8 @@
# if 0
# include <os2.h>
# else
unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
unsigned short __far __pascal DosFreeSeg(unsigned short);
ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
# endif
#endif

View File

@ -49,8 +49,11 @@
************************************************************************/
#if (UINT_MAX == ACC_0xffffL)
#if defined(__ZTC__) && defined(__I86__)
# if !defined(_MSDOS) && !defined(__OS2__)
#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
# if !defined(MSDOS)
# define MSDOS 1
# endif
# if !defined(_MSDOS)
# define _MSDOS 1
# endif
#elif defined(__VERSION) && defined(MB_LEN_MAX)
@ -203,7 +206,6 @@
#endif
/*
vi:ts=4:et
*/

View File

@ -21,6 +21,9 @@
# include "acc.h"
# endif
#endif
#ifndef __ACC_INCD_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_incd.h")
#endif
#ifndef __ACC_INCE_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_ince.h")
#endif
@ -32,11 +35,16 @@
#endif
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(a,b) __ACCLIB_FUNC(a,b)
#endif
/***********************************************************************
// halloc
************************************************************************/
ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_hsize_t size)
ACCLIB_PUBLIC(acc_hvoid_p, acc_halloc) (acc_hsize_t size)
{
acc_hvoid_p p = 0;
@ -69,7 +77,7 @@ ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_hsize_t size)
}
ACC_LIBFUNC(int, acc_hfree) (acc_hvoid_p p)
ACCLIB_PUBLIC(int, acc_hfree) (acc_hvoid_p p)
{
int r = 0;
@ -107,7 +115,7 @@ ACC_LIBFUNC(int, acc_hfree) (acc_hvoid_p p)
#if (ACC_OS_DOS16)
#if !defined(ACC_CC_AZTECC)
ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size)
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
{
void __far* p = 0;
union REGS ri, ro;
@ -127,7 +135,7 @@ ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size)
}
ACC_LIBFUNC(int, acc_dos_free) (void __far* p)
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
{
union REGS ri, ro;
struct SREGS rs;
@ -152,7 +160,7 @@ ACC_LIBFUNC(int, acc_dos_free) (void __far* p)
#if (ACC_OS_OS216)
ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size)
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
{
void __far* p = 0;
unsigned short sel = 0;
@ -166,7 +174,7 @@ ACC_LIBFUNC(void __far*, acc_dos_alloc) (unsigned long size)
return p;
}
ACC_LIBFUNC(int, acc_dos_free) (void __far* p)
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
{
if (!p)
return 0;
@ -184,7 +192,7 @@ ACC_LIBFUNC(int, acc_dos_free) (void __far* p)
// huge pointer layer - string.h
************************************************************************/
ACC_LIBFUNC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len)
ACCLIB_PUBLIC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP)
const acc_hbyte_p p1 = (const acc_hbyte_p) s1;
@ -204,7 +212,7 @@ ACC_LIBFUNC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_h
}
ACC_LIBFUNC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY)
acc_hbyte_p p1 = (acc_hbyte_p) dest;
@ -222,7 +230,7 @@ ACC_LIBFUNC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src,
}
ACC_LIBFUNC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE)
acc_hbyte_p p1 = (acc_hbyte_p) dest;
@ -252,7 +260,7 @@ 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)
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET)
acc_hbyte_p p = (acc_hbyte_p) s;
@ -271,7 +279,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)
ACCLIB_PUBLIC(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)
@ -311,7 +319,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)
ACCLIB_PUBLIC(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)
@ -357,7 +365,7 @@ ACC_LIBFUNC(acc_hsize_t, acc_hfwrite) (FILE* fp, const acc_hvoid_p buf, acc_hsiz
#if (ACC_HAVE_MM_HUGE_PTR)
ACC_LIBFUNC(long, acc_hread) (int fd, acc_hvoid_p buf, long size)
ACCLIB_PUBLIC(long, acc_hread) (int fd, acc_hvoid_p buf, long size)
{
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
acc_hbyte_p b = (acc_hbyte_p) buf;
@ -397,7 +405,7 @@ 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)
ACCLIB_PUBLIC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size)
{
#if (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
const acc_hbyte_p b = (const acc_hbyte_p) buf;
@ -443,20 +451,17 @@ ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size)
// wrap <dirent.h>
**************************************************************************/
#if !defined(ACCLIB_USE_OPENDIR)
#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)
static int acc_opendir_init(struct acc_dir_t* f, const char* path, char* buf, size_t bufsize)
static int acc_opendir_init(acc_dir_t* f, const char* path, char* buf, size_t bufsize)
{
size_t l;
char* p;
f->f_name[0] = 0;
buf[0] = 0;
size_t l; char* p;
f->f_name[0] = 0; buf[0] = 0;
l = strlen(path);
if (l == 0 || l >= bufsize - 4)
if (l == 0 || bufsize <= 4 || l >= bufsize - 4)
return -1;
strcpy(buf, path);
p = buf + l;
strcpy(buf, path); p = buf + l;
if (p[-1] == ':' || p[-1] == '\\' || p[-1] == '/')
strcpy(p, "*.*");
else
@ -468,9 +473,9 @@ static int acc_opendir_init(struct acc_dir_t* f, const char* path, char* buf, si
#endif
#if (ACCLIB_USE_OPENDIR)
#if defined(__ACCLIB_USE_OPENDIR)
ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_t* f, const char* path)
{
f->u_dirp = opendir(path);
if (!f->u_dirp)
@ -478,7 +483,7 @@ ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
return acc_readdir(f);
}
ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_t* f)
{
const struct dirent* dp;
f->f_name[0] = 0;
@ -499,7 +504,7 @@ ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
return 0;
}
ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_t* f)
{
int r = -1;
if (f->u_dirp)
@ -511,7 +516,7 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
#elif (ACC_OS_WIN32 || ACC_OS_WIN64)
ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_t* f, const char* path)
{
WIN32_FIND_DATAA d;
HANDLE h;
@ -530,7 +535,7 @@ ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
return 0;
}
ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_t* f)
{
WIN32_FIND_DATAA d;
f->f_name[0] = 0;
@ -545,7 +550,7 @@ ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
return 0;
}
ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_t* f)
{
int r = -1;
if (f->u_handle != -1)
@ -557,7 +562,7 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16)
ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_t* f, const char* path)
{
char tmp[ACC_FN_PATH_MAX+1];
int r;
@ -577,7 +582,7 @@ ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
return 0;
}
ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_t* f)
{
int r;
f->f_name[0] = 0;
@ -595,7 +600,7 @@ ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
return 0;
}
ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_t* f)
{
ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44);
f->f_name[0] = 0;
@ -606,7 +611,7 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
#elif (ACC_OS_TOS)
ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_t* f, const char* path)
{
char tmp[ACC_FN_PATH_MAX+1];
int r;
@ -624,7 +629,7 @@ ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
return 0;
}
ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_t* f)
{
int r;
DTA* olddta;
@ -640,7 +645,7 @@ ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
return 0;
}
ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_t* f)
{
ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44);
f->f_name[0] = 0;
@ -651,20 +656,20 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
#else
ACC_LIBFUNC(int, acc_opendir) (struct acc_dir_t* f, const char* path)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_t* f, const char* path)
{
ACC_UNUSED(path);
f->f_name[0] = 0;
return -3;
}
ACC_LIBFUNC(int, acc_readdir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_t* f)
{
f->f_name[0] = 0;
return -1;
}
ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_t* f)
{
f->u_dirp = 0;
return -1;
@ -687,7 +692,7 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* f)
// wrap misc
**************************************************************************/
ACC_LIBFUNC(long, acc_get_osfhandle) (int fd)
ACCLIB_PUBLIC(long, acc_get_osfhandle) (int fd)
{
if (fd < 0)
return -1;
@ -709,7 +714,7 @@ ACC_LIBFUNC(long, acc_get_osfhandle) (int fd)
}
ACC_LIBFUNC(int, acc_set_binmode) (int fd, int binary)
ACCLIB_PUBLIC(int, acc_set_binmode) (int fd, int binary)
{
#if (ACC_OS_TOS && defined(__MINT__))
int old_binary;
@ -761,7 +766,7 @@ ACC_LIBFUNC(int, acc_set_binmode) (int fd, int binary)
}
ACC_LIBFUNC(int, acc_isatty) (int fd)
ACCLIB_PUBLIC(int, acc_isatty) (int fd)
{
/* work around library implementations that think that
* any character device like `nul' is a tty */
@ -795,7 +800,7 @@ ACC_LIBFUNC(int, acc_isatty) (int fd)
}
ACC_LIBFUNC(int, acc_mkdir) (const char* name, unsigned mode)
ACCLIB_PUBLIC(int, acc_mkdir) (const char* name, unsigned mode)
{
#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
ACC_UNUSED(mode);
@ -812,7 +817,7 @@ ACC_LIBFUNC(int, acc_mkdir) (const char* name, unsigned mode)
#if 0
ACC_LIBFUNC(int, acc_response) (int* argc, char*** argv)
ACCLIB_PUBLIC(int, acc_response) (int* argc, char*** argv)
{
}
#endif
@ -822,12 +827,12 @@ ACC_LIBFUNC(int, acc_response) (int* argc, char*** argv)
// some linear congruential pseudo random number generators (PRNG)
**************************************************************************/
ACC_LIBFUNC(void, acc_srand31) (acc_rand31_t* r, acc_uint32l_t seed)
ACCLIB_PUBLIC(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)
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand31) (acc_rand31_t* r)
{
r->seed = (r->seed * ACC_UINT32L_C(1103515245)) + 12345;
r->seed &= ACC_UINT32L_C(0x7fffffff);
@ -837,13 +842,13 @@ ACC_LIBFUNC(acc_uint32l_t, acc_rand31) (acc_rand31_t* r)
#if defined(acc_uint64l_t)
ACC_LIBFUNC(void, acc_srand48) (acc_rand48_t* r, acc_uint32l_t seed)
ACCLIB_PUBLIC(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)
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48) (acc_rand48_t* r)
{
r->seed = (r->seed * ACC_UINT64L_C(25214903917)) + 11;
r->seed &= ACC_UINT64L_C(0xffffffffffff);
@ -855,12 +860,12 @@ ACC_LIBFUNC(acc_uint32l_t, acc_rand48) (acc_rand48_t* r)
#if defined(acc_uint64l_t)
ACC_LIBFUNC(void, acc_srand64) (acc_rand64_t* r, acc_uint64l_t seed)
ACCLIB_PUBLIC(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)
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64) (acc_rand64_t* r)
{
r->seed = (r->seed * ACC_UINT64L_C(6364136223846793005)) + 1;
r->seed &= ACC_UINT64L_C(0xffffffffffffffff);

View File

@ -17,8 +17,11 @@
#define __ACC_LIB_H_INCLUDED
#if !defined(ACC_LIBFUNC)
# define ACC_LIBFUNC(a,b) a b
#if !defined(__ACCLIB_FUNC)
# define __ACCLIB_FUNC(a,b) a b
#endif
#if !defined(ACCLIB_EXTERN)
# define ACCLIB_EXTERN(a,b) extern __ACCLIB_FUNC(a,b)
#endif
@ -41,26 +44,27 @@
#endif
/* halloc */
ACC_LIBFUNC(acc_hvoid_p, acc_halloc) (acc_hsize_t size);
ACC_LIBFUNC(int, acc_hfree) (acc_hvoid_p p);
ACCLIB_EXTERN(acc_hvoid_p, acc_halloc) (acc_hsize_t size);
ACCLIB_EXTERN(int, acc_hfree) (acc_hvoid_p p);
#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);
ACCLIB_EXTERN(void __far*, acc_dos_alloc) (unsigned long size);
ACCLIB_EXTERN(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);
ACC_LIBFUNC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len);
ACC_LIBFUNC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len);
ACC_LIBFUNC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len);
ACCLIB_EXTERN(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len);
ACCLIB_EXTERN(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);
ACCLIB_EXTERN(acc_hsize_t, acc_hfread) (FILE* fp, acc_hvoid_p buf, acc_hsize_t size);
ACCLIB_EXTERN(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);
ACCLIB_EXTERN(long, acc_hread) (int fd, acc_hvoid_p buf, long size);
ACCLIB_EXTERN(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size);
#endif
@ -98,23 +102,23 @@ ACC_LIBFUNC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size);
// wrap <dirent.h>
**************************************************************************/
#undef ACCLIB_USE_OPENDIR
#undef __ACCLIB_USE_OPENDIR
#if (HAVE_DIRENT_H || ACC_CC_WATCOMC)
# define ACCLIB_USE_OPENDIR 1
# 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
# undef __ACCLIB_USE_OPENDIR
# endif
#endif
struct acc_dir_t
typedef struct
{
#if (ACCLIB_USE_OPENDIR)
#if defined(__ACCLIB_USE_OPENDIR)
void *u_dirp; /* private */
# if (ACC_CC_WATCOMC)
unsigned short f_time;
@ -141,11 +145,11 @@ struct acc_dir_t
void *u_dirp; /* private */
char f_name[ACC_FN_NAME_MAX+1];
#endif
};
} acc_dir_t;
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);
ACCLIB_EXTERN(int, acc_opendir) (acc_dir_t* d, const char* path);
ACCLIB_EXTERN(int, acc_readdir) (acc_dir_t* d);
ACCLIB_EXTERN(int, acc_closedir) (acc_dir_t* d);
/*************************************************************************
@ -175,33 +179,33 @@ ACC_LIBFUNC(int, acc_closedir) (struct acc_dir_t* d);
# define acc_alloca(x) alloca((x))
#endif
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);
ACCLIB_EXTERN(long, acc_get_osfhandle) (int fd);
ACCLIB_EXTERN(int, acc_isatty) (int fd);
ACCLIB_EXTERN(int, acc_mkdir) (const char* name, unsigned mode);
ACCLIB_EXTERN(int, acc_response) (int* argc, char*** argv);
ACCLIB_EXTERN(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);
ACCLIB_EXTERN(void, acc_srand31) (acc_rand31_t* r, acc_uint32l_t seed);
ACCLIB_EXTERN(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);
ACCLIB_EXTERN(void, acc_srand48) (acc_rand48_t* r, acc_uint32l_t seed);
ACCLIB_EXTERN(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);
ACCLIB_EXTERN(void, acc_srand64) (acc_rand64_t* r, acc_uint64l_t seed);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand64) (acc_rand64_t* r);
#endif /* defined(acc_uint64l_t) */

View File

@ -78,27 +78,27 @@
# if (_MSC_VER < 600)
# undef ACC_HAVE_MM_HUGE_PTR
# endif
#elif (ACC_CC_TURBOC && __TURBOC__ < 0x0295)
#elif (ACC_CC_TURBOC && (__TURBOC__ < 0x0295))
# undef ACC_HAVE_MM_HUGE_ARRAY
#elif (ACC_CC_WATCOMC && __WATCOMC__ >= 1200)
/* pointer arithmetics with __huge arrays seems completely
* broken in OpenWatcom 1.0 */
#elif (ACC_CC_WATCOMC && (__WATCOMC__ >= 1200))
/* pointer arithmetics with __huge arrays seems broken in OpenWatcom 1.0 */
# undef ACC_HAVE_MM_HUGE_ARRAY
#endif
#if defined(__cplusplus)
#ifdef __cplusplus
extern "C" {
#endif
#if (ACC_CC_BORLANDC && __BORLANDC__ >= 0x0200)
ACC_EXTERN_C void __near __cdecl _AHSHIFT(void);
#if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
ACC_EXTERN_C void __near __cdecl _AHSHIFT(void);
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_MSC || ACC_CC_TOPSPEEDC)
ACC_EXTERN_C void __near __cdecl _AHSHIFT(void);
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_TURBOC && __TURBOC__ >= 0x0295)
ACC_EXTERN_C void __near __cdecl _AHSHIFT(void);
#elif (ACC_CC_TURBOC && (__TURBOC__ >= 0x0295))
extern void __near __cdecl _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
@ -106,7 +106,10 @@
extern unsigned char _HShift;
# define ACC_MM_AHSHIFT ((unsigned) _HShift)
#else
# error "implement ACC_MM_AHSHIFT"
# error "FIXME - implement ACC_MM_AHSHIFT"
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -132,9 +132,6 @@
# 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"
@ -147,6 +144,9 @@
# elif defined(__linux__) || defined(__linux)
# define ACC_OS_POSIX_LINUX 1
# define ACC_INFO_OS_POSIX "linux"
# elif defined(__APPLE__)
# define ACC_OS_POSIX_MACOSX 1
# define ACC_INFO_OS_POSIX "macosx"
# elif defined(__NetBSD__)
# define ACC_OS_POSIX_NETBSD 1
# define ACC_INFO_OS_POSIX "netbsd"

View File

@ -143,6 +143,12 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
/* acc_int64l_t is int_least64_t in <stdint.h> terminology */
#if !defined(acc_int64l_t)
#undef __ACC_PREFER___INT64
#if (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
# if (ACC_CC_BORLANDC)
# define __ACC_PREFER___INT64 1
# endif
#endif
#if (SIZEOF_INT >= 8)
# define acc_int64l_t int
# define acc_uint64l_t unsigned int
@ -157,11 +163,16 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
# 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)
#elif (SIZEOF_LONG_LONG >= 8 && SIZEOF_UNSIGNED_LONG_LONG >= 8) && !defined(__ACC_PREFER___INT64)
# 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
# if (ACC_CC_BORLANDC)
# define ACC_INT64L_C(c) ((c) + 0ll)
# define ACC_UINT64L_C(c) ((c) + 0ull)
# else
# define ACC_INT64L_C(c) c##LL
# define ACC_UINT64L_C(c) c##ULL
# endif
# define SIZEOF_ACC_INT64L_T SIZEOF_LONG_LONG
# define SIZEOF_ACC_UINT64L_T SIZEOF_LONG_LONG
#elif (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
@ -268,8 +279,11 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#if !defined(__acc_cdecl_sighandler)
# define __acc_cdecl_sighandler
#endif
#if !defined(__acc_cdecl_va)
# define __acc_cdecl_va __acc_cdecl
#endif
#if (ACC_CC_AZTECC) || (ACC_CC_TURBOC && __TURBOC__ < 0x0150)
#if (ACC_CC_AZTECC || ACC_CC_TURBOC)
typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(int);
#elif defined(RETSIGTYPE)
typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(int);