version 1.6.0 defines a bunch of macros in include/f2fs_fs.h to be bswap_64(x) on big endian systems. This causes a type mismatch because uclibc defines bswap_64(x) to take a type double while f2fs-tools supplies a long long. This is a bug in uclibc and should be fixed there.
Here's a little piece of code to show what fails #include <byteswap.h> int main() { long long x = 42.0; // works on both glibc and uclibc //double x = 42.0; // fails on uclibc, works on glibc bswap_64(x); } Note: this only affects f2fs-tools on big endian systems because the same marcos are define in terms of __u32 and __u64 on little endian systems.
If we replace the marco defined in uclibc's /usr/include/bits/byteswap-common.h with the macro from glibc using the definition of __uint64_t from <bits/types.> it fixes the issue. Here's an inline patch just to explain the issue: --- /usr/include/bits/byteswap-common.h.bak 2016-03-12 18:56:39.812000000 +0000 +++ /usr/include/bits/byteswap-common.h 2016-03-12 19:00:11.512000000 +0000 @@ -85,24 +85,12 @@ | (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x00000000000000ffull) << 56)) -# ifndef __bswap_non_constant_64 -# define __bswap_non_constant_64(x) \ - (__extension__ \ - ({ union { __extension__ unsigned long long int __ll; \ - unsigned int __l[2]; } __w, __r; \ - __w.__ll = (x); \ - __r.__l[0] = __bswap_non_constant_32 (__w.__l[1]); \ - __r.__l[1] = __bswap_non_constant_32 (__w.__l[0]); \ - __r.__ll; })) -# endif -# define __bswap_64(x) \ - (__extension__ \ - ({ __extension__ unsigned long long int __ll; \ - if (__builtin_constant_p (x)) \ - __ll = __bswap_constant_64 (x); \ - else \ - __ll = __bswap_non_constant_64 (x); \ - __ll; })) +#include <bits/types.h> +static __inline __uint64_t +__bswap_64 (__uint64_t __bsx) +{ + return __bswap_constant_64 (__bsx); +} #endif #endif /* _BITS_BYTESWAP_H */
Looks like we should just reimport byteswap.h + byteswap-16.h from glibc.
patches gone upstream(s): https://www.mail-archive.com/uclibc@uclibc.org/msg10483.html and http://mailman.uclibc-ng.org/pipermail/devel/2016-March/000806.html
Landed https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=6e26587d1734d8071b6132fa9a4a6dc5110e4279