diff options
-rw-r--r-- | lib/libc/net/byteorder.3 | 23 | ||||
-rw-r--r-- | sys/alpha/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/alpha/include/endian.h | 26 | ||||
-rw-r--r-- | sys/arm/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/i386/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/i386/include/endian.h | 21 | ||||
-rw-r--r-- | sys/ia64/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/ia64/include/endian.h | 26 | ||||
-rw-r--r-- | sys/powerpc/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/powerpc/include/endian.h | 26 | ||||
-rw-r--r-- | sys/sparc64/include/ansi.h | 2 | ||||
-rw-r--r-- | sys/sparc64/include/endian.h | 18 | ||||
-rw-r--r-- | sys/sys/types.h | 18 |
13 files changed, 105 insertions, 65 deletions
diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3 index cae00a7..03c176b 100644 --- a/lib/libc/net/byteorder.3 +++ b/lib/libc/net/byteorder.3 @@ -44,15 +44,15 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.Fd #include <sys/param.h> -.Ft u_long -.Fn htonl "u_long hostlong" -.Ft u_short -.Fn htons "u_short hostshort" -.Ft u_long -.Fn ntohl "u_long netlong" -.Ft u_short -.Fn ntohs "u_short netshort" +.Fd #include <arpa/inet.h> +.Ft uint32_t +.Fn htonl "uint32_t hostlong" +.Ft uint16_t +.Fn htons "uint16_t hostshort" +.Ft uint32_t +.Fn ntohl "uint32_t netlong" +.Ft uint16_t +.Fn ntohs "uint16_t netshort" .Sh DESCRIPTION These routines convert 16 and 32 bit quantities between network byte order and host byte order. @@ -67,6 +67,11 @@ and .Sh SEE ALSO .Xr gethostbyname 3 , .Xr getservent 3 +.Sh STANDARDS +The +.Nm byteorder +functions are expected to conform with IEEE Std POSIX.1-200x +.Pq Dq POSIX.1 . .Sh HISTORY The .Nm byteorder 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_ |