comparison crc32i.h @ 3:6483683ac857 default tip

*: add profiling code too; expand x86 to use all eight XMM registers basically ported verbatim from the assembly
author Paper <paper@tflc.us>
date Mon, 09 Feb 2026 21:30:30 -0500
parents 90cb48b87dcc
children
comparison
equal deleted inserted replaced
2:ead9f84d11db 3:6483683ac857
11 * We could also create these structures at compile 11 * We could also create these structures at compile
12 * time and have a flag that says whether it needs 12 * time and have a flag that says whether it needs
13 * to be destroyed or if it can be cached. */ 13 * to be destroyed or if it can be cached. */
14 #define CRC32_POLYNOMIAL 0xedb88320 14 #define CRC32_POLYNOMIAL 0xedb88320
15 15
16 /* crc32b.c */ 16 #if (__STDC_VERSION__ >= 201112L)
17 # define CRC32_ALIGN(N) alignas(N)
18 #elif defined(__GNUC__)
19 # define CRC32_ALIGN(N) __attribute__((__aligned__(N)))
20 #elif defined(_MSC_VER)
21 # define CRC32_ALIGN(N) __declspec(align(N))
22 #else
23 # error fuck
24 #endif
25
17 #ifdef __GNUC__ 26 #ifdef __GNUC__
18 # define CRC32_PURE __attribute__((__pure__)) 27 # define CRC32_FORCEINLINE static inline __attribute__((__always_inline__))
28 #elif defined(_MSC_VER)
29 # define CRC32_FORCEINLINE static __forceinline
19 #else 30 #else
20 # define CRC32_PURE 31 # define CRC32_FORCEINLINE static inline
21 #endif 32 #endif
22 33
23 #define ALIGNOF(type) offsetof(struct { type a; char b; }, b) 34 #define ALIGNOF(type) offsetof(struct { type a; char b; }, b)
24 #define ALIGNED(ptr, alignment) (((uintptr_t)(ptr) % (alignment)) == 0) 35 #define ALIGNED(ptr, alignment) (((uintptr_t)(ptr) % (alignment)) == 0)
25 #define ALIGNED_TYPE(ptr, type) ALIGNED(ptr, ALIGNOF(type)) 36 #define ALIGNED_TYPE(ptr, type) ALIGNED(ptr, ALIGNOF(type))