kusano 7d535a
/* portab.h -- portability layer
kusano 7d535a
kusano 7d535a
   This file is part of the LZO real-time data compression library.
kusano 7d535a
kusano 7d535a
   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   All Rights Reserved.
kusano 7d535a
kusano 7d535a
   The LZO library is free software; you can redistribute it and/or
kusano 7d535a
   modify it under the terms of the GNU General Public License as
kusano 7d535a
   published by the Free Software Foundation; either version 2 of
kusano 7d535a
   the License, or (at your option) any later version.
kusano 7d535a
kusano 7d535a
   The LZO library is distributed in the hope that it will be useful,
kusano 7d535a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
kusano 7d535a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
kusano 7d535a
   GNU General Public License for more details.
kusano 7d535a
kusano 7d535a
   You should have received a copy of the GNU General Public License
kusano 7d535a
   along with the LZO library; see the file COPYING.
kusano 7d535a
   If not, write to the Free Software Foundation, Inc.,
kusano 7d535a
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
kusano 7d535a
kusano 7d535a
   Markus F.X.J. Oberhumer
kusano 7d535a
   <markus@oberhumer.com></markus@oberhumer.com>
kusano 7d535a
   http://www.oberhumer.com/opensource/lzo/
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
#include "lzo/lzoconf.h"
kusano 7d535a
kusano 7d535a
#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1200))
kusano 7d535a
   /* avoid `-W4' warnings in system header files */
kusano 7d535a
#  pragma warning(disable: 4201 4214 4514)
kusano 7d535a
#endif
kusano 7d535a
#if (LZO_CC_MSC && (_MSC_VER >= 1300))
kusano 7d535a
   /* avoid `-Wall' warnings in system header files */
kusano 7d535a
#  pragma warning(disable: 4163 4255 4820)
kusano 7d535a
   /* avoid warnings about inlining */
kusano 7d535a
#  pragma warning(disable: 4710 4711)
kusano 7d535a
#endif
kusano 7d535a
#if (LZO_CC_MSC && (_MSC_VER >= 1400))
kusano 7d535a
   /* avoid warnings when using "deprecated" POSIX functions */
kusano 7d535a
#  pragma warning(disable: 4996)
kusano 7d535a
#endif
kusano 7d535a
#if (LZO_CC_PELLESC && (__POCC__ >= 290))
kusano 7d535a
#  pragma warn(disable:2002)
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*************************************************************************
kusano 7d535a
//
kusano 7d535a
**************************************************************************/
kusano 7d535a
kusano 7d535a
#if defined(__LZO_MMODEL_HUGE) || !(defined(LZO_LIBC_ISOC90) || defined(LZO_LIBC_ISOC99))
kusano 7d535a
kusano 7d535a
#include "examples/portab_a.h"
kusano 7d535a
kusano 7d535a
#else
kusano 7d535a
kusano 7d535a
/* INFO:
kusano 7d535a
 *   The "portab_a.h" version above uses the ACC library to add
kusano 7d535a
 *   support for ancient systems (like 16-bit DOS) and to provide
kusano 7d535a
 *   some gimmicks like Windows high-resolution timers.
kusano 7d535a
 *   Still, on any halfway modern machine you can also use the
kusano 7d535a
 *   following pure ANSI-C code instead.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#include <stddef.h></stddef.h>
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
#include <string.h></string.h>
kusano 7d535a
#include <ctype.h></ctype.h>
kusano 7d535a
#include <time.h></time.h>
kusano 7d535a
#if defined(CLK_TCK) && !defined(CLOCKS_PER_SEC)
kusano 7d535a
#  define CLOCKS_PER_SEC CLK_TCK
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#if defined(WANT_LZO_MALLOC)
kusano 7d535a
#  define lzo_malloc(a)         (malloc(a))
kusano 7d535a
#  define lzo_free(a)           (free(a))
kusano 7d535a
#endif
kusano 7d535a
#if defined(WANT_LZO_FREAD)
kusano 7d535a
#  define lzo_fread(f,b,s)      (fread(b,1,s,f))
kusano 7d535a
#  define lzo_fwrite(f,b,s)     (fwrite(b,1,s,f))
kusano 7d535a
#endif
kusano 7d535a
#if defined(WANT_LZO_UCLOCK)
kusano 7d535a
#  define lzo_uclock_handle_t   int
kusano 7d535a
#  define lzo_uclock_t          double
kusano 7d535a
#  define lzo_uclock_open(a)    ((void)(a))
kusano 7d535a
#  define lzo_uclock_close(a)   ((void)(a))
kusano 7d535a
#  define lzo_uclock_read(a,b)  *(b) = (clock() / (double)(CLOCKS_PER_SEC))
kusano 7d535a
#  define lzo_uclock_get_elapsed(a,b,c) (*(c) - *(b))
kusano 7d535a
#endif
kusano 7d535a
#if defined(WANT_LZO_WILDARGV)
kusano 7d535a
#  define lzo_wildargv(a,b)     ((void)0)
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*************************************************************************
kusano 7d535a
// misc
kusano 7d535a
**************************************************************************/
kusano 7d535a
kusano 7d535a
/* turn on assertions */
kusano 7d535a
#undef NDEBUG
kusano 7d535a
#include <assert.h></assert.h>
kusano 7d535a
kusano 7d535a
/* just in case */
kusano 7d535a
#undef xmalloc
kusano 7d535a
#undef xfree
kusano 7d535a
#undef xread
kusano 7d535a
#undef xwrite
kusano 7d535a
#undef xputc
kusano 7d535a
#undef xgetc
kusano 7d535a
#undef xread32
kusano 7d535a
#undef xwrite32
kusano 7d535a
kusano 7d535a
kusano 7d535a
#if defined(WANT_LZO_UCLOCK)
kusano 7d535a
kusano 7d535a
/* High quality benchmarking.
kusano 7d535a
 *
kusano 7d535a
 * Flush the CPU cache to get more accurate benchmark values.
kusano 7d535a
 * This needs custom kernel patches. As a result - in combination with
kusano 7d535a
 * the perfctr Linux kernel patches - accurate high-quality benchmarking
kusano 7d535a
 * is possible.
kusano 7d535a
 *
kusano 7d535a
 * All other methods (rdtsc, QueryPerformanceCounter, gettimeofday, ...)
kusano 7d535a
 * are completely unreliable for our purposes, and the only other
kusano 7d535a
 * option is to boot into a legacy single-task operating system
kusano 7d535a
 * like plain MSDOS and to directly reprogram the hardware clock.
kusano 7d535a
 * [The djgpp2 port of the gcc compiler has support functions for this.]
kusano 7d535a
 *
kusano 7d535a
 * Also, for embedded systems it's best to benchmark by using a
kusano 7d535a
 * CPU emulator/simulator software that can exactly count all
kusano 7d535a
 * virtual clock ticks.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#if !defined(lzo_uclock_flush_cpu_cache)
kusano 7d535a
#  define lzo_uclock_flush_cpu_cache(h,flags)  ((void)(h))
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
vi:ts=4:et
kusano 7d535a
*/
kusano 7d535a