summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2001-08-30 00:04:19 +0000
committermike <mike@FreeBSD.org>2001-08-30 00:04:19 +0000
commita45063618a1d6723c7f698850318bdd8b65f27a0 (patch)
tree2a398220f9e238744c0dfb240b714a2129e1c526 /sys
parent77d67fb5682dc550f62559210baf33988ee0f890 (diff)
downloadFreeBSD-src-a45063618a1d6723c7f698850318bdd8b65f27a0.zip
FreeBSD-src-a45063618a1d6723c7f698850318bdd8b65f27a0.tar.gz
o Remove some GCCisms in src/powerpc/include/endian.h.
o Unify <machine/endian.h>'s across all architectures. o Make bswapXX() functions use a different spelling of u_int16_t and friends to reduce namespace pollution. The bswapXX() functions don't actually exist, but we'll probably import these at some point. Atleast one driver (if_de) depends on bswapXX() for big endian cases. o Deprecate byteorder(3) prototypes from <sys/types.h>, these are now prototyped indirectly in <arpa/inet.h>. o Deprecate in_addr_t and in_port_t typedefs in <sys/types.h>, these are now typedef'd in <arpa/inet.h>. o Change byteorder(3) prototypes to use standards compliant uint32_t (spelled __uint32_t to reduce namespace pollution). o Document new preferred headers and standards compliance. Discussed with: bde PR: 29946 Reviewed by: bmilekic
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/include/ansi.h2
-rw-r--r--sys/alpha/include/endian.h26
-rw-r--r--sys/arm/include/ansi.h2
-rw-r--r--sys/i386/include/ansi.h2
-rw-r--r--sys/i386/include/endian.h21
-rw-r--r--sys/ia64/include/ansi.h2
-rw-r--r--sys/ia64/include/endian.h26
-rw-r--r--sys/powerpc/include/ansi.h2
-rw-r--r--sys/powerpc/include/endian.h26
-rw-r--r--sys/sparc64/include/ansi.h2
-rw-r--r--sys/sparc64/include/endian.h18
-rw-r--r--sys/sys/types.h18
12 files changed, 91 insertions, 56 deletions
diff --git a/sys/alpha/include/ansi.h b/sys/alpha/include/ansi.h
index e9f14d6..c2ec7f2 100644
--- a/sys/alpha/include/ansi.h
+++ b/sys/alpha/include/ansi.h
@@ -49,6 +49,8 @@
*/
#define _BSD_CLOCK_T_ int /* clock() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h
index 068f2f4..0ba53cd 100644
--- a/sys/alpha/include/endian.h
+++ b/sys/alpha/include/endian.h
@@ -56,17 +56,19 @@
#define BYTE_ORDER LITTLE_ENDIAN
+#ifndef _KERNEL
#include <sys/cdefs.h>
-#include <sys/types.h>
+#endif
+#include <machine/ansi.h>
__BEGIN_DECLS
-in_addr_t htonl __P((in_addr_t));
-in_port_t htons __P((in_port_t));
-in_addr_t ntohl __P((in_addr_t));
-in_port_t ntohs __P((in_port_t));
-u_int16_t bswap16 __P((u_int16_t));
-u_int32_t bswap32 __P((u_int32_t));
-u_int64_t bswap64 __P((u_int64_t));
+__uint32_t htonl __P((__uint32_t));
+__uint16_t htons __P((__uint16_t));
+__uint32_t ntohl __P((__uint32_t));
+__uint16_t ntohs __P((__uint16_t));
+__uint16_t bswap16 __P((__uint16_t));
+__uint32_t bswap32 __P((__uint32_t));
+__uint64_t bswap64 __P((__uint64_t));
__END_DECLS
/*
@@ -85,10 +87,10 @@ __END_DECLS
#else
-#define NTOHL(x) (x) = ntohl((in_addr_t)x)
-#define NTOHS(x) (x) = ntohs((in_port_t)x)
-#define HTONL(x) (x) = htonl((in_addr_t)x)
-#define HTONS(x) (x) = htons((in_port_t)x)
+#define NTOHL(x) (x) = ntohl((__uint32_t)x)
+#define NTOHS(x) (x) = ntohs((__uint16_t)x)
+#define HTONL(x) (x) = htonl((__uint32_t)x)
+#define HTONS(x) (x) = htons((__uint16_t)x)
#endif
#endif /* !_POSIX_SOURCE */
#endif /* !_ENDIAN_H_ */
diff --git a/sys/arm/include/ansi.h b/sys/arm/include/ansi.h
index 456c8a7..ca6d5f2 100644
--- a/sys/arm/include/ansi.h
+++ b/sys/arm/include/ansi.h
@@ -49,6 +49,8 @@
*/
#define _BSD_CLOCK_T_ int /* clock() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/i386/include/ansi.h b/sys/i386/include/ansi.h
index c375f31..3aff58e 100644
--- a/sys/i386/include/ansi.h
+++ b/sys/i386/include/ansi.h
@@ -48,6 +48,8 @@
*/
#define _BSD_CLOCK_T_ unsigned long /* clock()... */
#define _BSD_CLOCKID_T_ int /* clock_gettime()... */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h
index 41ceda4..f929b64 100644
--- a/sys/i386/include/endian.h
+++ b/sys/i386/include/endian.h
@@ -58,26 +58,27 @@
#ifndef _KERNEL
#include <sys/cdefs.h>
#endif
+#include <machine/ansi.h>
__BEGIN_DECLS
-unsigned long htonl(unsigned long);
-unsigned short htons(unsigned short);
-unsigned long ntohl(unsigned long);
-unsigned short ntohs(unsigned short);
+__uint32_t htonl(__uint32_t);
+__uint16_t htons(__uint16_t);
+__uint32_t ntohl(__uint32_t);
+__uint16_t ntohs(__uint16_t);
__END_DECLS
#ifdef __GNUC__
-static __inline unsigned long
-__uint16_swap_uint32(unsigned long __x)
+static __inline __uint32_t
+__uint16_swap_uint32(__uint32_t __x)
{
__asm ("rorl $16, %1" : "=r" (__x) : "0" (__x));
return __x;
}
-static __inline unsigned long
-__uint8_swap_uint32(unsigned long __x)
+static __inline __uint32_t
+__uint8_swap_uint32(__uint32_t __x)
{
#if defined(_KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU)
__asm ("bswap %0" : "=r" (__x) : "0" (__x));
@@ -88,8 +89,8 @@ __uint8_swap_uint32(unsigned long __x)
return __x;
}
-static __inline unsigned short
-__uint8_swap_uint16(unsigned short __x)
+static __inline __uint16_t
+__uint8_swap_uint16(__uint16_t __x)
{
__asm ("xchgb %h1, %b1" : "=q" (__x) : "0" (__x));
diff --git a/sys/ia64/include/ansi.h b/sys/ia64/include/ansi.h
index 5d8cacc..395f54e 100644
--- a/sys/ia64/include/ansi.h
+++ b/sys/ia64/include/ansi.h
@@ -49,6 +49,8 @@
*/
#define _BSD_CLOCK_T_ int /* clock() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h
index 068f2f4..0ba53cd 100644
--- a/sys/ia64/include/endian.h
+++ b/sys/ia64/include/endian.h
@@ -56,17 +56,19 @@
#define BYTE_ORDER LITTLE_ENDIAN
+#ifndef _KERNEL
#include <sys/cdefs.h>
-#include <sys/types.h>
+#endif
+#include <machine/ansi.h>
__BEGIN_DECLS
-in_addr_t htonl __P((in_addr_t));
-in_port_t htons __P((in_port_t));
-in_addr_t ntohl __P((in_addr_t));
-in_port_t ntohs __P((in_port_t));
-u_int16_t bswap16 __P((u_int16_t));
-u_int32_t bswap32 __P((u_int32_t));
-u_int64_t bswap64 __P((u_int64_t));
+__uint32_t htonl __P((__uint32_t));
+__uint16_t htons __P((__uint16_t));
+__uint32_t ntohl __P((__uint32_t));
+__uint16_t ntohs __P((__uint16_t));
+__uint16_t bswap16 __P((__uint16_t));
+__uint32_t bswap32 __P((__uint32_t));
+__uint64_t bswap64 __P((__uint64_t));
__END_DECLS
/*
@@ -85,10 +87,10 @@ __END_DECLS
#else
-#define NTOHL(x) (x) = ntohl((in_addr_t)x)
-#define NTOHS(x) (x) = ntohs((in_port_t)x)
-#define HTONL(x) (x) = htonl((in_addr_t)x)
-#define HTONS(x) (x) = htons((in_port_t)x)
+#define NTOHL(x) (x) = ntohl((__uint32_t)x)
+#define NTOHS(x) (x) = ntohs((__uint16_t)x)
+#define HTONL(x) (x) = htonl((__uint32_t)x)
+#define HTONS(x) (x) = htons((__uint16_t)x)
#endif
#endif /* !_POSIX_SOURCE */
#endif /* !_ENDIAN_H_ */
diff --git a/sys/powerpc/include/ansi.h b/sys/powerpc/include/ansi.h
index a2e3198..733b0d7 100644
--- a/sys/powerpc/include/ansi.h
+++ b/sys/powerpc/include/ansi.h
@@ -48,6 +48,8 @@
*/
#define _BSD_CLOCK_T_ int /* clock() */
#define _BSD_CLOCKID_T_ int /* clockid_t */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/powerpc/include/endian.h b/sys/powerpc/include/endian.h
index e8f11a7..a1f5ce6 100644
--- a/sys/powerpc/include/endian.h
+++ b/sys/powerpc/include/endian.h
@@ -55,17 +55,19 @@
#define BYTE_ORDER BIG_ENDIAN
+#ifndef _KERNEL
#include <sys/cdefs.h>
-#include <sys/types.h>
+#endif
+#include <machine/ansi.h>
__BEGIN_DECLS
-in_addr_t htonl __P((in_addr_t)) __attribute__((__const__));
-in_port_t htons __P((in_port_t)) __attribute__((__const__));
-in_addr_t ntohl __P((in_addr_t)) __attribute__((__const__));
-in_port_t ntohs __P((in_port_t)) __attribute__((__const__));
-u_int16_t bswap16 __P((u_int16_t)) __attribute__((__const__));
-u_int32_t bswap32 __P((u_int32_t)) __attribute__((__const__));
-u_int64_t bswap64 __P((u_int64_t)) __attribute__((__const__));
+__uint32_t htonl __P((__uint32_t));
+__uint16_t htons __P((__uint16_t));
+__uint32_t ntohl __P((__uint32_t));
+__uint16_t ntohs __P((__uint16_t));
+__uint16_t bswap16 __P((__uint16_t));
+__uint32_t bswap32 __P((__uint32_t));
+__uint64_t bswap64 __P((__uint64_t));
__END_DECLS
/*
@@ -84,10 +86,10 @@ __END_DECLS
#else
-#define NTOHL(x) (x) = ntohl((in_addr_t)(x))
-#define NTOHS(x) (x) = ntohs((in_port_t)(x))
-#define HTONL(x) (x) = htonl((in_addr_t)(x))
-#define HTONS(x) (x) = htons((in_port_t)(x))
+#define NTOHL(x) (x) = ntohl((__uint32_t)(x))
+#define NTOHS(x) (x) = ntohs((__uint16_t)(x))
+#define HTONL(x) (x) = htonl((__uint32_t)(x))
+#define HTONS(x) (x) = htons((__uint16_t)(x))
#endif
#endif /* !_POSIX_SOURCE */
diff --git a/sys/sparc64/include/ansi.h b/sys/sparc64/include/ansi.h
index 30b6e7d..47f5552 100644
--- a/sys/sparc64/include/ansi.h
+++ b/sys/sparc64/include/ansi.h
@@ -49,6 +49,8 @@
*/
#define _BSD_CLOCK_T_ int /* clock() */
#define _BSD_CLOCKID_T_ int /* clock_gettime()... */
+#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
+#define _BSD_IN_PORT_T_ __uint16_t
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
diff --git a/sys/sparc64/include/endian.h b/sys/sparc64/include/endian.h
index 0e8e1f1..b63b68e 100644
--- a/sys/sparc64/include/endian.h
+++ b/sys/sparc64/include/endian.h
@@ -47,17 +47,19 @@
#define BYTE_ORDER BIG_ENDIAN
+#ifndef _KERNEL
#include <sys/cdefs.h>
-#include <sys/types.h>
+#endif
+#include <machine/ansi.h>
__BEGIN_DECLS
-in_addr_t htonl __P((in_addr_t));
-in_port_t htons __P((in_port_t));
-in_addr_t ntohl __P((in_addr_t));
-in_port_t ntohs __P((in_port_t));
-u_int16_t bswap16 __P((u_int16_t));
-u_int32_t bswap32 __P((u_int32_t));
-u_int64_t bswap64 __P((u_int64_t));
+__uint32_t htonl __P((__uint32_t));
+__uint16_t htons __P((__uint16_t));
+__uint32_t ntohl __P((__uint32_t));
+__uint16_t ntohs __P((__uint16_t));
+__uint16_t bswap16 __P((__uint16_t));
+__uint32_t bswap32 __P((__uint32_t));
+__uint64_t bswap64 __P((__uint64_t));
__END_DECLS
/*
diff --git a/sys/sys/types.h b/sys/sys/types.h
index b5c9326..c731795 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -73,8 +73,6 @@ typedef int32_t daddr_t; /* disk address */
typedef u_int32_t u_daddr_t; /* unsigned disk address */
typedef u_int32_t fixpt_t; /* fixed point number */
typedef u_int32_t gid_t; /* group id */
-typedef u_int32_t in_addr_t; /* base type for internet address */
-typedef u_int16_t in_port_t;
typedef u_int32_t ino_t; /* inode number */
typedef long key_t; /* IPC key (for Sys V IPC) */
typedef u_int16_t mode_t; /* permissions */
@@ -124,6 +122,10 @@ typedef u_int32_t dev_t; /* device number */
#endif /* !_KERNEL */
+/*
+ * XXX: Deprecated;
+ * byteorder(3) functions now defined in <apra/inet.h>.
+ */
#include <machine/endian.h>
#ifdef _BSD_CLOCK_T_
@@ -136,6 +138,18 @@ typedef _BSD_CLOCKID_T_ clockid_t;
#undef _BSD_CLOCKID_T_
#endif
+/* XXX: Deprecated; now defined in <apra/inet.h>. */
+#ifdef _BSD_IN_ADDR_T_
+typedef _BSD_IN_ADDR_T_ in_addr_t;
+#undef _BSD_IN_ADDR_T_
+#endif
+
+/* XXX: Deprecated; now defined in <apra/inet.h>. */
+#ifdef _BSD_IN_PORT_T_
+typedef _BSD_IN_PORT_T_ in_port_t;
+#undef _BSD_IN_PORT_T_
+#endif
+
#ifdef _BSD_SIZE_T_
typedef _BSD_SIZE_T_ size_t;
#undef _BSD_SIZE_T_
OpenPOWER on IntegriCloud