Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/include/arpa nameser_compat.h: simplify logic to determine b...
details: https://anonhg.NetBSD.org/src/rev/215c643eacea
branches: trunk
changeset: 365725:215c643eacea
user: gutteridge <gutteridge%NetBSD.org@localhost>
date: Thu Apr 21 04:03:54 2022 +0000
description:
nameser_compat.h: simplify logic to determine byte order
There's really no need for all the complex #ifdefs present and, on top
of that, it didn't even work correctly for all NetBSD architectures.
Simply use endian.h and drop the rest. (Since there is no upstream for
this code anymore, there's no concern about complicating future merges,
either. This change is also consistent with what FreeBSD and OpenBSD
did years ago.)
Addresses PR toolchain/53880 (reported by maya@, originally encountered
by me on macppc when building a package that pulls in nameser_compat.h
before nameser.h by necessity -- necessity, that is, on another OS).
diffstat:
include/arpa/nameser_compat.h | 52 +++++++-----------------------------------
1 files changed, 9 insertions(+), 43 deletions(-)
diffs (87 lines):
diff -r 13a2ddefcd12 -r 215c643eacea include/arpa/nameser_compat.h
--- a/include/arpa/nameser_compat.h Thu Apr 21 01:15:24 2022 +0000
+++ b/include/arpa/nameser_compat.h Thu Apr 21 04:03:54 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nameser_compat.h,v 1.8 2020/11/18 12:49:52 is Exp $ */
+/* $NetBSD: nameser_compat.h,v 1.9 2022/04/21 04:03:54 gutteridge Exp $ */
/* Copyright (c) 1983, 1989
* The Regents of the University of California. All rights reserved.
@@ -36,53 +36,19 @@
#ifndef _ARPA_NAMESER_COMPAT_
#define _ARPA_NAMESER_COMPAT_
+#include <endian.h>
+
#define __BIND 19950621 /*%< (DEAD) interface version stamp. */
-#ifndef BYTE_ORDER
-#if (BSD >= 199103)
-# include <machine/endian.h>
-#else
-#ifdef __linux
-# include <endian.h>
-#else
-#define LITTLE_ENDIAN 1234 /*%< least-significant byte first (vax, pc) */
-#define BIG_ENDIAN 4321 /*%< most-significant byte first (IBM, net) */
-#define PDP_ENDIAN 3412 /*%< LSB first in word, MSW first in long (pdp) */
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
- defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
- defined(__i386__) || defined(__i386) || defined(__amd64__) || \
- defined(__x86_64__) || defined(MIPSEL) || defined(_MIPSEL) || \
- defined(BIT_ZERO_ON_RIGHT) || defined(__alpha__) || defined(__alpha) || \
- (defined(__Lynx__) && defined(__x86__))
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
- defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
- defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
- defined(apollo) || defined(__convex__) || defined(_CRAY) || \
- defined(__hppa) || defined(__hp9000) || \
- defined(__hp9000s300) || defined(__hp9000s700) || \
- defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
- defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) || \
- (defined(__Lynx__) && \
- (defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-#endif /* __linux */
-#endif /* BSD */
-#endif /* BYTE_ORDER */
-
-#if !defined(BYTE_ORDER) || \
- (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
- BYTE_ORDER != PDP_ENDIAN)
+#if !defined(_BYTE_ORDER) || \
+ (_BYTE_ORDER != _BIG_ENDIAN && _BYTE_ORDER != _LITTLE_ENDIAN && \
+ _BYTE_ORDER != _PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
-#error "Undefined or invalid BYTE_ORDER"
+#error "Undefined or invalid _BYTE_ORDER"
#endif
/*%
@@ -94,7 +60,7 @@
typedef struct {
unsigned id :16; /*%< query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /*%< response flag */
unsigned opcode: 4; /*%< purpose of message */
@@ -108,7 +74,7 @@
unsigned cd: 1; /*%< checking disabled by resolver */
unsigned rcode :4; /*%< response code */
#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
+#if _BYTE_ORDER == _LITTLE_ENDIAN || _BYTE_ORDER == _PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /*%< recursion desired */
unsigned tc :1; /*%< truncated message */
Home |
Main Index |
Thread Index |
Old Index