Module Name:    src
Committed By:   martin
Date:           Fri Oct 11 19:07:20 UTC 2024

Modified Files:
        src/sys/sys [netbsd-10]: endian.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #952):

        sys/sys/endian.h: revision 1.32
        sys/sys/endian.h: revision 1.33
        sys/sys/endian.h: revision 1.34
        sys/sys/endian.h: revision 1.35

break the cycle: this does not need <sys/types.h> it only needs <sys/stdint.h>

arpa/inet.h: Define htonl &c. under _POSIX_C_SOURCE >= 200112L too.
These do not require _XOPEN_SOURCE as of POSIX 2001:
https://pubs.opengroup.org/onlinepubs/009696799/functions/htonl.html

XXX Since this change is actually sys/endian.h, in principle it might
bleed into header files than just arpa/inet.h.  But sys/endian.h is
not used by anything that looks especially risky to me.

PR standards/57806: #include <arpa/inet.h> fails to define
htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L

sys/endian.h: Hide le32enc/be32enc/... under _NETBSD_SOURCE.
These are non-standard extensions, so they should not be exposed by,
e.g., _XOPEN_SOURCE=700.

PR standards/57807: #include <arpa/inet.h> spuriously defines
le32enc/be32enc/... under _XOPEN_SOURCE=700

sys/endian.h: sync comment with code


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/sys/endian.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/endian.h
diff -u src/sys/sys/endian.h:1.31 src/sys/sys/endian.h:1.31.4.1
--- src/sys/sys/endian.h:1.31	Mon Aug  8 18:55:18 2022
+++ src/sys/sys/endian.h	Fri Oct 11 19:07:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: endian.h,v 1.31 2022/08/08 18:55:18 rillig Exp $	*/
+/*	$NetBSD: endian.h,v 1.31.4.1 2024/10/11 19:07:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -45,14 +45,16 @@
 #define	_PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
 
 
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || \
+    (_POSIX_C_SOURCE - 0) >= 200112L || \
+    defined(_NETBSD_SOURCE)
 #ifndef _LOCORE
 
 /* C-family endian-ness definitions */
 
 #include <sys/ansi.h>
 #include <sys/cdefs.h>
-#include <sys/types.h>
+#include <sys/stdint.h>
 
 #ifndef in_addr_t
 typedef __in_addr_t	in_addr_t;
@@ -72,7 +74,7 @@ uint16_t ntohs(uint16_t) __constfunc;
 __END_DECLS
 
 #endif /* !_LOCORE */
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
+#endif /* _XOPEN_SOURCE || _POSIX_C_SOURCE >= 200112L || _NETBSD_SOURCE */
 
 
 #include <machine/endian_machdep.h>
@@ -190,6 +192,8 @@ __END_DECLS
  * to/from an octet stream.
  */
 
+#ifdef _NETBSD_SOURCE
+
 #if __GNUC_PREREQ__(2, 95)
 
 #define __GEN_ENDIAN_ENC(bits, endian) \
@@ -335,6 +339,8 @@ le64dec(const void *buf)
 
 #endif	/* GCC >= 2.95 */
 
+#endif	/* _NETBSD_SOURCE */
+
 #endif /* !_LOCORE */
 #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
 #endif /* !_SYS_ENDIAN_H_ */

Reply via email to