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