blob: 6710b83ce72ed094113a23fab890b94e43fe1151 [file] [log] [blame]
Richard Purdie64c70b12007-07-10 17:22:24 -07001/*
2 * lzodefs.h -- architecture, OS and compiler specific defines
3 *
Markus F.X.J. Oberhumer8b975bd2012-08-13 17:25:44 +02004 * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com>
Richard Purdie64c70b12007-07-10 17:22:24 -07005 *
6 * The full LZO package can be found at:
7 * http://www.oberhumer.com/opensource/lzo/
8 *
Markus F.X.J. Oberhumer8b975bd2012-08-13 17:25:44 +02009 * Changed for Linux kernel use by:
Richard Purdie64c70b12007-07-10 17:22:24 -070010 * Nitin Gupta <nitingupta910@gmail.com>
11 * Richard Purdie <rpurdie@openedhand.com>
12 */
13
Markus F.X.J. Oberhumer8b975bd2012-08-13 17:25:44 +020014
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
Richard Purdie64c70b12007-07-10 17:22:24 -070035
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
Markus F.X.J. Oberhumer8b975bd2012-08-13 17:25:44 +020055#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)
Richard Purdie64c70b12007-07-10 17:22:24 -070059#define D_HIGH ((D_MASK >> 1) + 1)