1 #ifndef CRC32_BRAID_P_H_ 2 #define CRC32_BRAID_P_H_ 3 4 #include "zbuild.h" 5 #include "zendian.h" 6 7 /* Define N */ 8 #ifdef Z_TESTN 9 # define N Z_TESTN 10 #else 11 # define N 5 12 #endif 13 #if N < 1 || N > 6 14 # error N must be in 1..6 15 #endif 16 17 /* 18 Define W and the associated z_word_t type. If W is not defined, then a 19 braided calculation is not used, and the associated tables and code are not 20 compiled. 21 */ 22 #ifdef Z_TESTW 23 # if Z_TESTW-1 != -1 24 # define W Z_TESTW 25 # endif 26 #else 27 # ifndef W 28 # if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) 29 # define W 8 30 # else 31 # define W 4 32 # endif 33 # endif 34 #endif 35 #ifdef W 36 # if W == 8 37 typedef uint64_t z_word_t; 38 # else 39 # undef W 40 # define W 4 41 typedef uint32_t z_word_t; 42 # endif 43 #endif 44 45 /* CRC polynomial. */ 46 #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ 47 48 extern uint32_t crc32_braid(uint32_t crc, const unsigned char *buf, uint64_t len); 49 50 #endif /* CRC32_BRAID_P_H_ */ 51