From gitlab at videolan.org Wed Aug 6 15:53:47 2025 From: gitlab at videolan.org (Jean-Baptiste Kempf (@jbk)) Date: Wed, 06 Aug 2025 17:53:47 +0200 Subject: [libdvdnav-devel] [Git][videolan/libdvdread][master] 2 commits: bswap: use Clang builtins for B2N macros Message-ID: <68937a8b4318d_80cd3558c5418481583@gitlab.mail> Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread Commits: 545a9cdd by Steve Lhomme at 2025-08-06T13:48:46+02:00 bswap: use Clang builtins for B2N macros The detection works up to (at least) Clang 3.0 [^1]. [^1]: https://godbolt.org/z/nT91EzG7d - - - - - c799ef30 by Steve Lhomme at 2025-08-06T13:49:24+02:00 bswap: use GCC 4.8 builtins for B2N macros It's documented as available since GCC 4.8.0 [^1]. [^1]: https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Other-Builtins.html - - - - - 1 changed file: - src/bswap.h Changes: ===================================== src/bswap.h ===================================== @@ -30,6 +30,18 @@ #define B2N_32(x) (void)(x) #define B2N_64(x) (void)(x) +#elif defined(__clang__) && __has_builtin (__builtin_bswap16) + +#define B2N_16(x) x = __builtin_bswap16(x) +#define B2N_32(x) x = __builtin_bswap32(x) +#define B2N_64(x) x = __builtin_bswap64(x) + +#elif defined (__GNUC__) && ((__GNUC__ > (4)) || (__GNUC__ == (4) && __GNUC_MINOR__ >= (8))) + +#define B2N_16(x) x = __builtin_bswap16(x) +#define B2N_32(x) x = __builtin_bswap32(x) +#define B2N_64(x) x = __builtin_bswap64(x) + #else /* For __FreeBSD_version */ View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/786e73584b46393fbea4abdb4a25920cde82b9ec...c799ef30654a80f78a61add61c4a67426687ecae -- View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/786e73584b46393fbea4abdb4a25920cde82b9ec...c799ef30654a80f78a61add61c4a67426687ecae You're receiving this email because of your account on code.videolan.org. VideoLAN code repository instance