53
53
// The maximum size that can be compressed while still allowing for the worst case compression expansion.
54
54
#define PITHY_UNCOMPRESSED_MAX_LENGTH 0xdb6db6bfu // 0xdb6db6bf == 3681400511, or 3510.857 Mbytes.
55
55
56
- #if defined(__i386__ ) || defined(__x86_64__ ) || defined(__powerpc__ ) || defined(__arm__ )
57
- #define PITHY_UNALIGNED_LOADS_AND_STORES
58
- #endif
59
-
60
56
typedef const char * pithy_hashOffset_t ;
61
57
62
58
enum {
@@ -100,7 +96,6 @@ enum {
100
96
} while(0)
101
97
#endif
102
98
103
-
104
99
PITHY_STATIC_INLINE const char * pithy_Parse32WithLimit (const char * p , const char * l , size_t * OUTPUT );
105
100
PITHY_STATIC_INLINE char * pithy_Encode32 (char * ptr , uint32_t v );
106
101
@@ -112,56 +107,15 @@ PITHY_STATIC_INLINE char *pithy_EmitCopyGreaterThan63(char *op, size_t off
112
107
PITHY_STATIC_INLINE char * pithy_EmitCopyLessThan63 (char * op , size_t offset , size_t len );
113
108
PITHY_STATIC_INLINE char * pithy_EmitCopy (char * op , size_t offset , size_t len );
114
109
115
-
116
- #ifdef PITHY_UNALIGNED_LOADS_AND_STORES
117
-
118
- #define pithy_Load16 (_p ) (*((uint16_t *)(_p)))
119
- #define pithy_Load32 (_p ) (*((uint32_t *)(_p)))
120
- #define pithy_Store16 (_p , _val ) (*((uint16_t *)(_p)) = (_val))
121
- #define pithy_Store32 (_p , _val ) (*((uint32_t *)(_p)) = (_val))
122
-
123
- #if defined(__arm__ )
124
-
125
- #if defined(__ARM_NEON__ )
126
- #define pithy_Load64 (_p ) ((uint64_t)vld1_u64(_p))
127
- #define pithy_Store64 (_p , _val ) vst1_u64(_p, (uint64x1_t)_val)
128
- #else
129
- #define PITHY_32BIT_MOVE64
130
- PITHY_STATIC_INLINE uint64_t pithy_Load64 (const void * p ) { uint64_t t ; memcpy (& t , p , sizeof (t )); return (t ); }
131
- #endif
132
-
133
- #else // not __arm__
134
- #define pithy_Load64 (_p ) (*((uint64_t *)(_p)))
135
- #define pithy_Store64 (_p , _val ) (*((uint64_t *)(_p)) = (_val))
136
- #endif // __arm__
137
-
138
- #else
139
-
140
110
PITHY_STATIC_INLINE uint16_t pithy_Load16 (const void * p ) { uint16_t t ; memcpy (& t , p , sizeof (t )); return (t ); }
141
111
PITHY_STATIC_INLINE uint32_t pithy_Load32 (const void * p ) { uint32_t t ; memcpy (& t , p , sizeof (t )); return (t ); }
142
112
PITHY_STATIC_INLINE uint64_t pithy_Load64 (const void * p ) { uint64_t t ; memcpy (& t , p , sizeof (t )); return (t ); }
143
113
PITHY_STATIC_INLINE void pithy_Store16 (void * p , uint16_t v ) { memcpy (p , & v , sizeof (v )); }
144
114
PITHY_STATIC_INLINE void pithy_Store32 (void * p , uint32_t v ) { memcpy (p , & v , sizeof (v )); }
145
115
PITHY_STATIC_INLINE void pithy_Store64 (void * p , uint64_t v ) { memcpy (p , & v , sizeof (v )); }
146
116
147
- #endif
148
-
149
-
150
- #ifdef PITHY_32BIT_MOVE64
151
- #define pithy_Move64 (dst ,src ) pithy_Store32(dst, pithy_Load32(src)); \
152
- pithy_Store32(dst + 4ul, pithy_Load32(src + 4ul));
153
- #else
154
117
#define pithy_Move64 (dst ,src ) pithy_Store64(dst, pithy_Load64(src));
155
- #endif
156
-
157
-
158
- #if defined(__arm__ ) && defined(__ARM_NEON__ ) && defined(PITHY_UNALIGNED_LOADS_AND_STORES )
159
- #define pithy_Move128 (_dst ,_src ) ({ \
160
- asm ("vld1.64 {d0-d1}, [%[src]]\n\tvst1.64 {d0-d1}, [%[dst]]" : : \
161
- [src]"r"(_src), [dst]"r"(_dst) : "d0", "d1", "memory"); })
162
- #else
163
118
#define pithy_Move128 (dst ,src ) pithy_Move64(dst, src); pithy_Move64(dst + 8ul, src + 8ul);
164
- #endif
165
119
166
120
#ifdef __BIG_ENDIAN__
167
121
0 commit comments