1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Common includes, definitions, system-specific things etc.
6 /// This file is used also by the lzma command line tool, that's why this
7 /// file is separate from common.h.
9 // Copyright (C) 2007 Lasse Collin
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
21 ///////////////////////////////////////////////////////////////////////////////
23 #ifndef LZMA_SYSDEFS_H
24 #define LZMA_SYSDEFS_H
34 #include <sys/types.h>
36 #ifdef HAVE_INTTYPES_H
37 # include <inttypes.h>
44 // Be more compatible with systems that have non-conforming inttypes.h.
45 // We assume that int is 32-bit and that long is either 32-bit or 64-bit.
46 // Full Autoconf test could be more correct, but this should work well enough.
48 # define UINT32_C(n) n ## U
51 # define UINT32_MAX UINT32_C(4294967295)
59 #if SIZEOF_UNSIGNED_LONG == 4
61 # define UINT64_C(n) n ## ULL
71 # define UINT64_C(n) n ## UL
81 # define UINT64_MAX UINT64_C(18446744073709551615)
84 # if SIZEOF_SIZE_T == 4
85 # define SIZE_MAX UINT32_MAX
87 # define SIZE_MAX UINT64_MAX
97 typedef unsigned char _Bool;
102 # define __bool_true_false_are_defined 1
111 // TODO: Pretty bad assert() macro.
112 # define assert(x) (!(x) && abort())
120 #ifdef HAVE_STRINGS_H
121 # include <strings.h>
136 # define memcpy(dest, src, n) bcopy(src, dest, n)
140 # define memmove(dest, src, n) bcopy(src, dest, n)
144 # define memzero(s, n) memset(s, 0, n)
146 # define memzero(s, n) bzero(s, n)
150 # define MIN(x, y) ((x) < (y) ? (x) : (y))
154 # define MAX(x, y) ((x) > (y) ? (x) : (y))
158 # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))