]> icculus.org git repositories - icculus/xz.git/blob - src/common/sysdefs.h
Imported to git.
[icculus/xz.git] / src / common / sysdefs.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       sysdefs.h
4 /// \brief      Common includes, definitions, system-specific things etc.
5 ///
6 /// This file is used also by the lzma command line tool, that's why this
7 /// file is separate from common.h.
8 //
9 //  Copyright (C) 2007 Lasse Collin
10 //
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.
15 //
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.
20 //
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #ifndef LZMA_SYSDEFS_H
24 #define LZMA_SYSDEFS_H
25
26 //////////////
27 // Includes //
28 //////////////
29
30 #ifdef HAVE_CONFIG_H
31 #       include <config.h>
32 #endif
33
34 #include "lzma.h"
35
36 #include <stdlib.h>
37
38 #ifdef HAVE_STDBOOL_H
39 #       include <stdbool.h>
40 #else
41 #       if ! HAVE__BOOL
42 typedef unsigned char _Bool;
43 #       endif
44 #       define bool _Bool
45 #       define false 0
46 #       define true 1
47 #       define __bool_true_false_are_defined 1
48 #endif
49
50 #ifdef HAVE_ASSERT_H
51 #       include <assert.h>
52 #else
53 #       ifdef NDEBUG
54 #               define assert(x)
55 #       else
56                 // TODO: Pretty bad assert() macro.
57 #               define assert(x) (!(x) && abort())
58 #       endif
59 #endif
60
61 #ifdef HAVE_STRING_H
62 #       include <string.h>
63 #endif
64
65 #ifdef HAVE_STRINGS_H
66 #       include <strings.h>
67 #endif
68
69 #ifdef HAVE_MEMORY_H
70 #       include <memory.h>
71 #endif
72
73
74 ////////////
75 // Macros //
76 ////////////
77
78 #ifndef HAVE_MEMCPY
79 #       define memcpy(dest, src, n) bcopy(src, dest, n)
80 #endif
81
82 #ifndef HAVE_MEMMOVE
83 #       define memmove(dest, src, n) bcopy(src, dest, n)
84 #endif
85
86 #ifdef HAVE_MEMSET
87 #       define memzero(s, n) memset(s, 0, n)
88 #else
89 #       define memzero(s, n) bzero(s, n)
90 #endif
91
92 #ifndef MIN
93 #       define MIN(x, y) ((x) < (y) ? (x) : (y))
94 #endif
95
96 #ifndef MAX
97 #       define MAX(x, y) ((x) > (y) ? (x) : (y))
98 #endif
99
100 #endif