Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common: tuklib: don't redefine bswap{16,32,64} on NetBSD
Browse files Browse the repository at this point in the history
On NetBSD:
```
  In file included from common/common.h:17,
                   from common/common.c:12:
  ../../src/common/tuklib_integer.h:69: error: "bswap16" redefined [-Werror]
     69 | # define bswap16(n) __builtin_bswap16(n)
        |
  In file included from /usr/include/amd64/bswap.h:13,
                   from /usr/include/sys/endian.h:107,
                   from /usr/include/amd64/endian.h:3,
                   from /usr/include/sys/types.h:98,
                   from /usr/include/stdlib.h:41,
                   from ../../src/common/sysdefs.h:134,
                   from common/common.h:15,
                   from common/common.c:12:
  /usr/include/sys/bswap.h:71: note: this is the location of the previous definition
     71 | #define bswap16(x) \
        |
```

If we're in the case where we know we have __builtin_bswap*, just undef
_bswap* first.
thesamesam committed Apr 15, 2024
1 parent fc59b47 commit 17b52fe
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/tuklib_integer.h
Original file line number Diff line number Diff line change
@@ -66,6 +66,9 @@

#if defined(HAVE___BUILTIN_BSWAPXX)
// GCC >= 4.8 and Clang
# undef bswap16
# undef bswap32
# undef bswap64
# define bswap16(n) __builtin_bswap16(n)
# define bswap32(n) __builtin_bswap32(n)
# define bswap64(n) __builtin_bswap64(n)

0 comments on commit 17b52fe

Please sign in to comment.