Skip to content

Commit

Permalink
stored: use correct algorithm on FreeBSD
Browse files Browse the repository at this point in the history
Fixes #1180: CRC checksum algorihm changed between 18.2.7 and 19.2.5

Previously crc32.cc did not detect when it couldn't
find out what endianess the machine was. This is now
fixed so that
1. FreeBSD detects endianess correctly
2. the compile fails when there is no __BYTE_ORDER

(cherry picked from commit ee0b908)
  • Loading branch information
arogge committed Feb 10, 2020
1 parent bf4250b commit ace6c83
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/stored/crc32/crc32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@
#endif
#endif

#if not defined __BYTE_ORDER
# include <sys/endian.h>
# if defined _BYTE_ORDER && not defined __BYTE_ORDER
# define __BYTE_ORDER _BYTE_ORDER
# endif
# if defined _LITTLE_ENDIAN && not defined __LITTLE_ENDIAN
# define __LITTLE_ENDIAN _LITTLE_ENDIAN
# endif
# if defined _BIG_ENDIAN && not defined __BIG_ENDIAN
# define __BIG_ENDIAN _BIG_ENDIAN
# endif
#endif

#if not defined __BYTE_ORDER
#error __BYTE_ORDER not set
#endif


/// zlib's CRC32 polynomial
const uint32_t Polynomial = 0xEDB88320;
Expand Down

0 comments on commit ace6c83

Please sign in to comment.