Message ID | 20240611162433.413069-1-collin.funk1@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v2] endian.h: Define unsigned fixed-width integer types [BZ #31749] | expand |
These patches look good to me.
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Hi Paul, On 6/11/24 10:00 AM, Paul Eggert wrote: > These patches look good to me. > > Reviewed-by: Paul Eggert <eggert@cs.ucla.edu> This patch causes the CI to fail the conform tests. Now that __USE_MISC is removed netinet/in.h, and other files that include it, show LITTLE_ENDIAN, be16toh, etc. It appears the header is only used to check __BYTE_ORDER so I think including <bits/endian.h> there would solve the issue. Also, I'm not sure how things are done in glibc so feel free to push the change if it is okay. :) Collin
diff --git a/string/endian.h b/string/endian.h index fd20a2b198..32001761c8 100644 --- a/string/endian.h +++ b/string/endian.h @@ -23,14 +23,15 @@ /* Get the definitions of __*_ENDIAN, __BYTE_ORDER, and __FLOAT_WORD_ORDER. */ #include <bits/endian.h> -#ifdef __USE_MISC -# define LITTLE_ENDIAN __LITTLE_ENDIAN -# define BIG_ENDIAN __BIG_ENDIAN -# define PDP_ENDIAN __PDP_ENDIAN -# define BYTE_ORDER __BYTE_ORDER -#endif +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#define PDP_ENDIAN __PDP_ENDIAN +#define BYTE_ORDER __BYTE_ORDER + +#ifndef __ASSEMBLER__ +/* Define uintN_t types. */ +# include <bits/stdint-uintn.h> -#if defined __USE_MISC && !defined __ASSEMBLER__ /* Conversion interfaces. */ # include <bits/byteswap.h> # include <bits/uintn-identity.h> diff --git a/string/test-endian-types.c b/string/test-endian-types.c index a0ff971f24..fa624e39c2 100644 --- a/string/test-endian-types.c +++ b/string/test-endian-types.c @@ -17,7 +17,6 @@ <https://www.gnu.org/licenses/>. */ #include <endian.h> -#include <stdint.h> int i; uint16_t u16;
The #ifdef __ASSEMBLER__ is required since sysdeps/unix/sysv/linux/sysdep.h includes <endian.h> which is then included by assembly files. It seems that most assembly uses the pre-defined macros by GCC now so it *could* be removed there. But this method remains compatible with assembly code that assumes <endian.h> can be included like previous versions of glibc. -- 8< -- The upcoming POSIX revision requires that uint16_t, uint32_t, and uint64_t are defined in endian.h. Optionally all symbols from <stdint.h> may be defined. This patch includes <bits/stdint-uintn.h> which defines the required types and uint8_t. This allows glibc to pass Gnulib's checks. Signed-off-by: Collin Funk <collin.funk1@gmail.com> --- string/endian.h | 15 ++++++++------- string/test-endian-types.c | 1 - 2 files changed, 8 insertions(+), 8 deletions(-)