[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] maint: prefer endian.h for byte order conversions
From: |
Bernhard Voelker |
Subject: |
[PATCH 3/4] maint: prefer endian.h for byte order conversions |
Date: |
Sun, 3 Nov 2024 21:53:40 +0100 |
Now that <endian.h> is a part of POSIX 2024 it should become more
portable than <byteswap.h>.
* bootstrap.conf (gnulib_modules): Remove byteswap; add endian.
* locate/word_io.c: Include endian.h instead of byteswap.h.
(decode_value): Use htobe32 instead of bswap_32.
---
bootstrap.conf | 2 +-
locate/word_io.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 815b603c..85e42648 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -76,7 +76,6 @@ gnulib_modules="
argmatch
argv-iter
assert
- byteswap
c-strcasestr
c-strstr
canonicalize
@@ -89,6 +88,7 @@ gnulib_modules="
dirent-safer
dirname
dup2
+ endian
errno
error
faccessat
diff --git a/locate/word_io.c b/locate/word_io.c
index 9e90c057..c51167f2 100644
--- a/locate/word_io.c
+++ b/locate/word_io.c
@@ -26,7 +26,7 @@
#include <string.h>
/* gnulib headers. */
-#include "byteswap.h"
+#include <endian.h>
#include "quotearg.h"
/* find headers. */
@@ -50,7 +50,7 @@ decode_value (const unsigned char data[],
} u;
u.ival = 0;
memcpy (&u.data, data, WORDBYTES);
- swapped = bswap_32(u.ival); /* byteswapped */
+ swapped = htobe32 (u.ival); /* byteswapped */
if (*endian_state_flag == GetwordEndianStateInitial)
{
--
2.47.0