1 /* portab.h -- portability layer
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 #include "lzo/lzoconf.h"
31 #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1200))
32 /* avoid '-W4' warnings in system header files */
33 # pragma warning(disable: 4201 4214 4514)
35 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
36 /* avoid '-Wall' warnings in system header files */
37 # pragma warning(disable: 4163 4255 4820)
38 /* avoid warnings about inlining */
39 # pragma warning(disable: 4710 4711)
41 /* disable silly warnings about using "deprecated" POSIX functions like "fopen" */
42 #if (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1100))
43 # pragma warning(disable: 1786)
44 #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1000))
45 # pragma warning(disable: 1478)
46 #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
47 # pragma warning(disable: 4996)
49 #if (LZO_CC_PELLESC && (__POCC__ >= 290))
50 # pragma warn(disable:2002)
54 /*************************************************************************
56 **************************************************************************/
58 #if defined(LZO_WANT_ACCLIB_GETOPT) || !(defined(LZO_LIBC_ISOC90) || defined(LZO_LIBC_ISOC99))
60 #include "examples/portab_a.h"
64 /* On any halfway modern machine we can use the following pure ANSI-C code. */
72 #if defined(CLK_TCK) && !defined(CLOCKS_PER_SEC)
73 # define CLOCKS_PER_SEC CLK_TCK
76 #if defined(WANT_LZO_MALLOC)
77 # define lzo_malloc(a) (malloc(a))
78 # define lzo_free(a) (free(a))
80 #if defined(WANT_LZO_FREAD)
81 # define lzo_fread(f,b,s) (fread(b,1,s,f))
82 # define lzo_fwrite(f,b,s) (fwrite(b,1,s,f))
84 #if defined(WANT_LZO_PCLOCK)
85 # define lzo_pclock_handle_t int
86 # define lzo_pclock_t double
87 # define lzo_pclock_open_default(a) ((void)(a))
88 # define lzo_pclock_close(a) ((void)(a))
89 # define lzo_pclock_read(a,b) *(b) = (clock() / (double)(CLOCKS_PER_SEC))
90 # define lzo_pclock_get_elapsed(a,b,c) (*(c) - *(b))
91 # define lzo_pclock_flush_cpu_cache(a,b) ((void)(a))
93 #if defined(WANT_LZO_WILDARGV)
94 # define lzo_wildargv(a,b) ((void)0)
100 /*************************************************************************
102 **************************************************************************/
104 /* turn on assertions */
119 #if defined(WANT_XMALLOC)
120 static lzo_voidp
xmalloc(lzo_uint len
)
123 lzo_uint align
= (lzo_uint
) sizeof(lzo_align_t
);
125 p
= (lzo_voidp
) lzo_malloc(len
> 0 ? len
: 1);
128 printf("%s: out of memory\n", progname
);
131 if (len
>= align
&& __lzo_align_gap(p
, align
) != 0)
133 printf("%s: C library problem: malloc() returned misaligned pointer!\n", progname
);
141 /* vim:set ts=4 sw=4 et: */