configure.ac: don't add -L /usr/local
[rofl0r-gnuboy.git] / xz / xz_config.h
blob33deb068bd1d4c6b4ce0cbd7c1b4f58f338f791e
1 /*
2 * Private includes and definitions for userspace use of XZ Embedded
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
10 #ifndef XZ_CONFIG_H
11 #define XZ_CONFIG_H
13 /* Uncomment to enable CRC64 support. */
14 #define XZ_USE_CRC64
16 /* Uncomment as needed to enable BCJ filter decoders. */
17 #if 0
18 #define XZ_DEC_X86
19 #define XZ_DEC_POWERPC
20 #define XZ_DEC_IA64
21 #define XZ_DEC_ARM
22 #define XZ_DEC_ARMTHUMB
23 #define XZ_DEC_SPARC
24 #endif
27 * MSVC doesn't support modern C but XZ Embedded is mostly C89
28 * so these are enough.
30 #ifdef _MSC_VER
31 typedef unsigned char bool;
32 # define true 1
33 # define false 0
34 # define inline __inline
35 #else
36 # if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
37 # if defined(__GNUC__)
38 # define inline __inline
39 # else
40 # define inline
41 # endif
42 # endif
43 # include <stdbool.h>
44 #endif
46 #include <stdlib.h>
47 #include <string.h>
49 #include "xz.h"
51 #define kmalloc(size, flags) malloc(size)
52 #define kfree(ptr) free(ptr)
53 #define vmalloc(size) malloc(size)
54 #define vfree(ptr) free(ptr)
56 #define memeq(a, b, size) (memcmp(a, b, size) == 0)
57 #define memzero(buf, size) memset(buf, 0, size)
59 #ifndef min
60 # define min(x, y) ((x) < (y) ? (x) : (y))
61 #endif
62 #define min_t(type, x, y) min(x, y)
65 * Some functions have been marked with __always_inline to keep the
66 * performance reasonable even when the compiler is optimizing for
67 * small code size. You may be able to save a few bytes by #defining
68 * __always_inline to plain inline, but don't complain if the code
69 * becomes slow.
71 * NOTE: System headers on GNU/Linux may #define this macro already,
72 * so if you want to change it, you need to #undef it first.
74 #ifndef __always_inline
75 # ifdef __GNUC__
76 # define __always_inline \
77 inline __attribute__((__always_inline__))
78 # else
79 # define __always_inline inline
80 # endif
81 #endif
83 /* Inline functions to access unaligned unsigned 32-bit integers */
84 #ifndef get_unaligned_le32
85 static inline uint32_t get_unaligned_le32(const uint8_t *buf)
87 return (uint32_t)buf[0]
88 | ((uint32_t)buf[1] << 8)
89 | ((uint32_t)buf[2] << 16)
90 | ((uint32_t)buf[3] << 24);
92 #endif
94 #ifndef get_unaligned_be32
95 static inline uint32_t get_unaligned_be32(const uint8_t *buf)
97 return (uint32_t)(buf[0] << 24)
98 | ((uint32_t)buf[1] << 16)
99 | ((uint32_t)buf[2] << 8)
100 | (uint32_t)buf[3];
102 #endif
104 #ifndef put_unaligned_le32
105 static inline void put_unaligned_le32(uint32_t val, uint8_t *buf)
107 buf[0] = (uint8_t)val;
108 buf[1] = (uint8_t)(val >> 8);
109 buf[2] = (uint8_t)(val >> 16);
110 buf[3] = (uint8_t)(val >> 24);
112 #endif
114 #ifndef put_unaligned_be32
115 static inline void put_unaligned_be32(uint32_t val, uint8_t *buf)
117 buf[0] = (uint8_t)(val >> 24);
118 buf[1] = (uint8_t)(val >> 16);
119 buf[2] = (uint8_t)(val >> 8);
120 buf[3] = (uint8_t)val;
122 #endif
125 * Use get_unaligned_le32() also for aligned access for simplicity. On
126 * little endian systems, #define get_le32(ptr) (*(const uint32_t *)(ptr))
127 * could save a few bytes in code size.
129 #ifndef get_le32
130 # define get_le32 get_unaligned_le32
131 #endif
133 #endif