A while ago I added the endian.h gnulib module to simplify byte-order conversions. This patch gets rid of the rest of autoconf's WORDS_BIGENDIAN macro and uses the standardized endian.h macros.
Will push in a bit if there are no objections. Collin
>From 1dc6de03bb8cd6b1a7f313ec81ee935004f898e9 Mon Sep 17 00:00:00 2001 Message-ID: <1dc6de03bb8cd6b1a7f313ec81ee935004f898e9.1751598116.git.collin.fu...@gmail.com> From: Collin Funk <collin.fu...@gmail.com> Date: Thu, 3 Jul 2025 19:48:44 -0700 Subject: [PATCH] maint: prefer endian.h macros to WORDS_BIGENDIAN * src/od.c: Include endian.h. (WORDS_BIGENDIAN): Remove definition. (main): Use BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN instead of WORDS_BIGENDIAN. Fix formatting. * src/blake2/blake2-impl.h: Include endian.h. Use BYTE_ORDER and LITTLE_ENDIAN instead of WORDS_BIGENDIAN. --- src/blake2/blake2-impl.h | 3 ++- src/od.c | 17 +++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/blake2/blake2-impl.h b/src/blake2/blake2-impl.h index 02a1b8fec..bddd4f884 100644 --- a/src/blake2/blake2-impl.h +++ b/src/blake2/blake2-impl.h @@ -15,7 +15,8 @@ #ifndef BLAKE2_IMPL_H #define BLAKE2_IMPL_H -#ifndef WORDS_BIGENDIAN +#include <endian.h> +#if BYTE_ORDER == LITTLE_ENDIAN # define NATIVE_LITTLE_ENDIAN 1 #endif diff --git a/src/od.c b/src/od.c index b64f083c6..be7d06751 100644 --- a/src/od.c +++ b/src/od.c @@ -19,6 +19,7 @@ #include <config.h> #include <ctype.h> +#include <endian.h> #include <float.h> #include <stdio.h> #include <getopt.h> @@ -301,10 +302,6 @@ static enum size_spec const fp_type_size[] = #endif }; -#ifndef WORDS_BIGENDIAN -# define WORDS_BIGENDIAN 0 -#endif - /* Use native endianness by default. */ static bool input_swap; @@ -1756,12 +1753,12 @@ main (int argc, char **argv) case ENDIAN_OPTION: switch (XARGMATCH ("--endian", optarg, endian_args, endian_types)) { - case endian_big: - input_swap = ! WORDS_BIGENDIAN; - break; - case endian_little: - input_swap = WORDS_BIGENDIAN; - break; + case endian_big: + input_swap = BYTE_ORDER != BIG_ENDIAN; + break; + case endian_little: + input_swap = BYTE_ORDER != LITTLE_ENDIAN; + break; } break; -- 2.50.0