xref: /linux/lib/lzo/lzodefs.h (revision c4ee0af3fa0dc65f690fc908f02b8355f9576ea0)
1 /*
2  *  lzodefs.h -- architecture, OS and compiler specific defines
3  *
4  *  Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com>
5  *
6  *  The full LZO package can be found at:
7  *  http://www.oberhumer.com/opensource/lzo/
8  *
9  *  Changed for Linux kernel use by:
10  *  Nitin Gupta <nitingupta910@gmail.com>
11  *  Richard Purdie <rpurdie@openedhand.com>
12  */
13 
14 
15 #define COPY4(dst, src)	\
16 		put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
17 #if defined(__x86_64__)
18 #define COPY8(dst, src)	\
19 		put_unaligned(get_unaligned((const u64 *)(src)), (u64 *)(dst))
20 #else
21 #define COPY8(dst, src)	\
22 		COPY4(dst, src); COPY4((dst) + 4, (src) + 4)
23 #endif
24 
25 #if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
26 #error "conflicting endian definitions"
27 #elif defined(__x86_64__)
28 #define LZO_USE_CTZ64	1
29 #define LZO_USE_CTZ32	1
30 #elif defined(__i386__) || defined(__powerpc__)
31 #define LZO_USE_CTZ32	1
32 #elif defined(__arm__) && (__LINUX_ARM_ARCH__ >= 5)
33 #define LZO_USE_CTZ32	1
34 #endif
35 
36 #define M1_MAX_OFFSET	0x0400
37 #define M2_MAX_OFFSET	0x0800
38 #define M3_MAX_OFFSET	0x4000
39 #define M4_MAX_OFFSET	0xbfff
40 
41 #define M1_MIN_LEN	2
42 #define M1_MAX_LEN	2
43 #define M2_MIN_LEN	3
44 #define M2_MAX_LEN	8
45 #define M3_MIN_LEN	3
46 #define M3_MAX_LEN	33
47 #define M4_MIN_LEN	3
48 #define M4_MAX_LEN	9
49 
50 #define M1_MARKER	0
51 #define M2_MARKER	64
52 #define M3_MARKER	32
53 #define M4_MARKER	16
54 
55 #define lzo_dict_t      unsigned short
56 #define D_BITS		13
57 #define D_SIZE		(1u << D_BITS)
58 #define D_MASK		(D_SIZE - 1)
59 #define D_HIGH		((D_MASK >> 1) + 1)
60