]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added "ULL" to the hex literals that needed it.
authorBill Cole <18053819+grumpybozo@users.noreply.github.com>
Tue, 10 Oct 2017 21:40:04 +0000 (17:40 -0400)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 19 Oct 2017 07:38:52 +0000 (10:38 +0300)
On 32-bit platforms with older compilers (e.g. gcc 4.2 on MacOS 10.6
running on a 1st-gen Core Duo) a 'long' is 4 bytes and the compiler does
not automatically use a 'long long' when needed, but instead generates
an error. e.g.:

libtool: compile:  /usr/bin/g++-4.2 -DHAVE_CONFIG_H -I. -I../../.. -I../../../src/lib -I../../../src/lib-mail -I../../../src/lib-index -I../../../src/lib-storage -I../../../src/plugins/fts -I../../../src/doveadm -I/opt/local/include/openssl -I/opt/local/include -I/opt/local/include/CLucene/ext -pipe -Os -arch i386 -D__STDC_LIMIT_MACROS -MT lucene-wrapper.lo -MD -MP -MF .deps/lucene-wrapper.Tpo -c lucene-wrapper.cc  -fno-common -DPIC -o .libs/lucene-wrapper.o
In file included from ../../../src/lib/lib.h:33,
                 from lucene-wrapper.cc:4:
../../../src/lib/byteorder.h:94: error: integer constant is too large for ‘long’ type
../../../src/lib/byteorder.h:95: error: integer constant is too large for ‘long’ type
../../../src/lib/byteorder.h:96: error: integer constant is too large for ‘long’ type
../../../src/lib/byteorder.h:97: error: integer constant is too large for ‘long’ type
make[4]: *** [lucene-wrapper.lo] Error 1

Adding the 'ULL' to the end of the 16-digit hex literals that are used
to test the structure of 64-bit integers fixes this and avoids any
problem which could arise from the compiler using a 32-bit type for
those literals that could fit in 32 bites.

src/lib/byteorder.h

index da0fba6715c6ef5e76f23a5b41cfd2c7b906492c..f6cdf322daa940a08f18c23783b8042fb4e973bf 100644 (file)
@@ -91,14 +91,14 @@ static inline uint8_t cpu8_to_le(uint8_t in);
  */
 static inline uint64_t bswap_64(uint64_t in)
 {
-       return ((in & 0xff00000000000000) >> 56) |
-              ((in & 0x00ff000000000000) >> 40) |
-              ((in & 0x0000ff0000000000) >> 24) |
-              ((in & 0x000000ff00000000) >> 8) |
-              ((in & 0x00000000ff000000) << 8) |
-              ((in & 0x0000000000ff0000) << 24) |
-              ((in & 0x000000000000ff00) << 40) |
-              ((in & 0x00000000000000ff) << 56);
+       return ((in & 0xff00000000000000ULL) >> 56) |
+              ((in & 0x00ff000000000000ULL) >> 40) |
+              ((in & 0x0000ff0000000000ULL) >> 24) |
+              ((in & 0x000000ff00000000ULL) >> 8) |
+              ((in & 0x00000000ff000000ULL) << 8) |
+              ((in & 0x0000000000ff0000ULL) << 24) |
+              ((in & 0x000000000000ff00ULL) << 40) |
+              ((in & 0x00000000000000ffULL) << 56);
 }
 
 static inline uint32_t bswap_32(uint32_t in)