[libdvdnav-devel] [Git][videolan/libdvdread][master] 2 commits: bswap: use Clang builtins for B2N macros

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Aug 6 15:53:47 UTC 2025



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


More information about the libdvdnav-devel mailing list