… | |
… | |
44 | #ifndef STANDALONE |
44 | #ifndef STANDALONE |
45 | # include "lzf.h" |
45 | # include "lzf.h" |
46 | #endif |
46 | #endif |
47 | |
47 | |
48 | /* |
48 | /* |
49 | * size of hashtable is (1 << HLOG) * sizeof (char *) |
49 | * Size of hashtable is (1 << HLOG) * sizeof (char *) |
50 | * decompression is independent of the hash table size |
50 | * decompression is independent of the hash table size |
51 | * the difference between 15 and 14 is very small |
51 | * the difference between 15 and 14 is very small |
52 | * for small blocks (and 14 is usually a but faster). |
52 | * for small blocks (and 14 is usually a bit faster). |
53 | * For a low-memory/faster configuration, use HLOG == 13; |
53 | * For a low-memory/faster configuration, use HLOG == 13; |
54 | * For best compression, use 15 or 16 (or more). |
54 | * For best compression, use 15 or 16 (or more). |
55 | */ |
55 | */ |
56 | #ifndef HLOG |
56 | #ifndef HLOG |
57 | # define HLOG 14 |
57 | # define HLOG 15 |
58 | #endif |
58 | #endif |
59 | |
59 | |
60 | /* |
60 | /* |
61 | * sacrifice very little compression quality in favour of compression speed. |
61 | * Sacrifice very little compression quality in favour of compression speed. |
62 | * This gives almost the same compression as the default code, and is |
62 | * This gives almost the same compression as the default code, and is |
63 | * (very roughly) 15% faster. This is the preferable mode of operation. |
63 | * (very roughly) 15% faster. This is the preferable mode of operation. |
64 | */ |
64 | */ |
65 | |
65 | |
66 | #ifndef VERY_FAST |
66 | #ifndef VERY_FAST |
67 | # define VERY_FAST 1 |
67 | # define VERY_FAST 1 |
68 | #endif |
68 | #endif |
69 | |
69 | |
70 | /* |
70 | /* |
71 | * sacrifice some more compression quality in favour of compression speed. |
71 | * Sacrifice some more compression quality in favour of compression speed. |
72 | * (roughly 1-2% worse compression for large blocks and |
72 | * (roughly 1-2% worse compression for large blocks and |
73 | * 9-10% for small, redundant, blocks and >>20% better speed in both cases) |
73 | * 9-10% for small, redundant, blocks and >>20% better speed in both cases) |
74 | * In short: when in need for speed, enable this for binary data, |
74 | * In short: when in need for speed, enable this for binary data, |
75 | * possibly disable this for text data. |
75 | * possibly disable this for text data. |
76 | */ |
76 | */ |
77 | #ifndef ULTRA_FAST |
77 | #ifndef ULTRA_FAST |
78 | # define ULTRA_FAST 0 |
78 | # define ULTRA_FAST 0 |
79 | #endif |
79 | #endif |
80 | |
80 | |
81 | /* |
81 | /* |
82 | * unconditionally aligning does not cost very much, so do it if unsure |
82 | * Unconditionally aligning does not cost very much, so do it if unsure |
83 | */ |
83 | */ |
84 | #ifndef STRICT_ALIGN |
84 | #ifndef STRICT_ALIGN |
85 | # define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) |
85 | # define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) |
86 | #endif |
86 | #endif |
87 | |
87 | |
88 | /* |
88 | /* |
89 | * use string functions to copy memory. |
89 | * Use string functions to copy memory. |
90 | * this is usually a loss, even with glibc's optimized memcpy |
90 | * this is usually a loss, even with glibc's optimized memcpy |
91 | */ |
91 | */ |
92 | #ifndef USE_MEMCPY |
92 | #ifndef USE_MEMCPY |
93 | # define USE_MEMCPY 0 |
93 | # define USE_MEMCPY 0 |
94 | #endif |
94 | #endif |
95 | |
95 | |
96 | /* |
96 | /* |
97 | * you may choose to pre-set the hash table (might be faster on some |
97 | * You may choose to pre-set the hash table (might be faster on some |
98 | * modern cpus and large (>>64k) blocks) |
98 | * modern cpus and large (>>64k) blocks) |
99 | */ |
99 | */ |
100 | #ifndef INIT_HTAB |
100 | #ifndef INIT_HTAB |
101 | # define INIT_HTAB 0 |
101 | # define INIT_HTAB 0 |
102 | #endif |
102 | #endif |
103 | |
103 | |
104 | /* |
104 | /* |
105 | * avoid assigning values to errno variable? for some embedding purposes |
105 | * Avoid assigning values to errno variable? for some embedding purposes |
106 | * (linux kernel for example), this is neccessary. NOTE: this breaks |
106 | * (linux kernel for example), this is neccessary. NOTE: this breaks |
107 | * the documentation in lzf.h. |
107 | * the documentation in lzf.h. |
108 | */ |
108 | */ |
109 | #ifndef AVOID_ERRNO |
109 | #ifndef AVOID_ERRNO |
110 | # define AVOID_ERRNO 0 |
110 | # define AVOID_ERRNO 0 |
… | |
… | |
115 | * on the stack. For small-stack environments, define this to 1. |
115 | * on the stack. For small-stack environments, define this to 1. |
116 | * NOTE: this breaks the prototype in lzf.h. |
116 | * NOTE: this breaks the prototype in lzf.h. |
117 | */ |
117 | */ |
118 | #ifndef LZF_STATE_ARG |
118 | #ifndef LZF_STATE_ARG |
119 | # define LZF_STATE_ARG 0 |
119 | # define LZF_STATE_ARG 0 |
|
|
120 | #endif |
|
|
121 | |
|
|
122 | /* |
|
|
123 | * Wether to add extra checks for input validity in lzf_decompress |
|
|
124 | * and return EINVAL if the input stream has been corrupted. This |
|
|
125 | * only shields against overflowing the input buffer and will not |
|
|
126 | * detect most corrupted streams. |
|
|
127 | * This check is not normally noticable on modern hardware |
|
|
128 | * (<1% slowdown), but might slow down older cpus considerably. |
|
|
129 | */ |
|
|
130 | #ifndef CHECK_INPUT |
|
|
131 | # define CHECK_INPUT 1 |
120 | #endif |
132 | #endif |
121 | |
133 | |
122 | /*****************************************************************************/ |
134 | /*****************************************************************************/ |
123 | /* nothing should be changed below */ |
135 | /* nothing should be changed below */ |
124 | |
136 | |