diff options
author | 1996-11-25 13:11:12 +0000 | |
---|---|---|
committer | 1996-11-25 13:11:12 +0000 | |
commit | d04f3685899cf5bd08efb0b577e54322f58dcbe3 (patch) | |
tree | 16fd88ae3f234fb336aa6aae3e2fc86afe05cfa1 | |
parent | ipx sysctl. (diff) | |
download | wireguard-openbsd-d04f3685899cf5bd08efb0b577e54322f58dcbe3.tar.xz wireguard-openbsd-d04f3685899cf5bd08efb0b577e54322f58dcbe3.zip |
htons et al. works on explicit 16- and 32-bit quantities and not the
machine dependent "short" and "long" integer. Correct and enhance manpage.
Change all short and longs to u_int16_t and u_int32_t, respectively.
OpenBSD RCSIds
-rw-r--r-- | lib/libc/net/byteorder.3 | 26 | ||||
-rw-r--r-- | sys/arch/amiga/include/endian.h | 1 | ||||
-rw-r--r-- | sys/arch/arc/include/endian.h | 18 | ||||
-rw-r--r-- | sys/arch/arm32/include/endian.h | 19 | ||||
-rw-r--r-- | sys/arch/atari/include/endian.h | 1 | ||||
-rw-r--r-- | sys/arch/hp300/include/endian.h | 1 | ||||
-rw-r--r-- | sys/arch/i386/include/endian.h | 55 | ||||
-rw-r--r-- | sys/arch/m68k/include/endian.h | 20 | ||||
-rw-r--r-- | sys/arch/mvme88k/include/endian.h | 21 | ||||
-rw-r--r-- | sys/arch/pc532/include/endian.h | 51 | ||||
-rw-r--r-- | sys/arch/pmax/include/endian.h | 5 | ||||
-rw-r--r-- | sys/arch/sparc/include/endian.h | 19 | ||||
-rw-r--r-- | sys/arch/sun3/include/endian.h | 1 | ||||
-rw-r--r-- | sys/arch/vax/include/endian.h | 39 |
14 files changed, 145 insertions, 132 deletions
diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3 index 723690cb16b..b880869b055 100644 --- a/lib/libc/net/byteorder.3 +++ b/lib/libc/net/byteorder.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: byteorder.3,v 1.2 1996/08/19 08:28:34 tholo Exp $ +.\" $OpenBSD: byteorder.3,v 1.3 1996/11/25 13:11:12 niklas Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -41,18 +41,22 @@ .Nm ntohs .Nd convert values between host and network byte order .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 <sys/types.h> +.Fd #include <machine/endian.h> +.Ft u_int32_t +.Fn htonl "u_int32_t host32" +.Ft u_int16_t +.Fn htons "u_int16_t host16" +.Ft u_int32_t +.Fn ntohl "u_int32_t net32" +.Ft u_int16_t +.Fn ntohs "u_int16_t net16" .Sh DESCRIPTION These routines convert 16 and 32 bit quantities between network -byte order and host byte order. +byte order and host byte order. The last letter (s/l) is a mnemonic +for the traditional names for such quantities, short and long, +respectively. Today, the C concept of "short"/"long" integers +need not coincide with this traditional misunderstanding. On machines which have a byte order which is the same as the network order, routines are defined as null macros. .Pp diff --git a/sys/arch/amiga/include/endian.h b/sys/arch/amiga/include/endian.h index 7d109f6a4ac..bfd856c0de2 100644 --- a/sys/arch/amiga/include/endian.h +++ b/sys/arch/amiga/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:14 niklas Exp $ */ /* $NetBSD: endian.h,v 1.7 1994/10/26 02:06:09 cgd Exp $ */ #ifndef _MACHINE_ENDIAN_H_ diff --git a/sys/arch/arc/include/endian.h b/sys/arch/arc/include/endian.h index 1af3c632d28..199bbf21675 100644 --- a/sys/arch/arc/include/endian.h +++ b/sys/arch/arc/include/endian.h @@ -1,4 +1,4 @@ -/* $OpenBSD: endian.h,v 1.1.1.1 1996/06/24 09:07:17 pefo Exp $ */ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:16 niklas Exp $ */ /* $NetBSD: endian.h,v 1.4 1994/10/26 21:09:38 cgd Exp $ */ /* @@ -64,10 +64,10 @@ #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS /* @@ -86,10 +86,10 @@ __END_DECLS #else -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) +#define NTOHL(x) (x) = ntohl((u_int32_t)x) +#define NTOHS(x) (x) = ntohs((u_int16_t)x) +#define HTONL(x) (x) = htonl((u_int32_t)x) +#define HTONS(x) (x) = htons((u_int16_t)x) #endif #endif /* ! _POSIX_SOURCE */ #endif /* !_ENDIAN_H_ */ diff --git a/sys/arch/arm32/include/endian.h b/sys/arch/arm32/include/endian.h index a7eb2a40665..6bbed9ec351 100644 --- a/sys/arch/arm32/include/endian.h +++ b/sys/arch/arm32/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:18 niklas Exp $ */ /* $NetBSD: endian.h,v 1.2 1996/03/14 23:11:10 mark Exp $ */ /* @@ -52,26 +53,26 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER LITTLE_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS /* * Macros for network/external number representation conversion. */ -#define NTOHL(x) (x) = ntohl((unsigned long)(x)) -#define NTOHS(x) (x) = ntohs((unsigned short)(x)) -#define HTONL(x) (x) = htonl((unsigned long)(x)) -#define HTONS(x) (x) = htons((unsigned short)(x)) +#define NTOHL(x) (x) = ntohl((u_int32_t)(x)) +#define NTOHS(x) (x) = ntohs((u_int16_t)(x)) +#define HTONL(x) (x) = htonl((u_int32_t)(x)) +#define HTONS(x) (x) = htons((u_int16_t)(x)) #endif /* _POSIX_SOURCE */ diff --git a/sys/arch/atari/include/endian.h b/sys/arch/atari/include/endian.h index 814afb73d93..8c0a134e452 100644 --- a/sys/arch/atari/include/endian.h +++ b/sys/arch/atari/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:20 niklas Exp $ */ /* $NetBSD: endian.h,v 1.1.1.1 1995/03/26 07:12:06 leo Exp $ */ #ifndef _MACHINE_ENDIAN_H_ diff --git a/sys/arch/hp300/include/endian.h b/sys/arch/hp300/include/endian.h index 3e9a6036445..ffc96e65376 100644 --- a/sys/arch/hp300/include/endian.h +++ b/sys/arch/hp300/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:22 niklas Exp $ */ /* $NetBSD: endian.h,v 1.6 1994/10/26 07:26:22 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/i386/include/endian.h b/sys/arch/i386/include/endian.h index 056a456a205..2be9c3d4eba 100644 --- a/sys/arch/i386/include/endian.h +++ b/sys/arch/i386/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.4 1996/11/25 13:11:24 niklas Exp $ */ /* $NetBSD: endian.h,v 1.16 1995/06/01 17:19:18 mycroft Exp $ */ /* @@ -53,40 +54,40 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER LITTLE_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS #ifdef __GNUC__ #if defined(_KERNEL) && !defined(I386_CPU) -#define __byte_swap_long_variable(x) \ -({ register unsigned long __x = (x); \ +#define __byte_swap_int32_variable(x) \ +({ register u_int32 __x = (x); \ __asm ("bswap %1" \ : "=r" (__x) \ : "0" (__x)); \ __x; }) #else -#define __byte_swap_long_variable(x) \ -({ register unsigned long __x = (x); \ +#define __byte_swap_int32_variable(x) \ +({ register u_int32_t __x = (x); \ __asm ("rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1" \ : "=r" (__x) \ : "0" (__x)); \ __x; }) #endif /* _KERNEL && ... */ -#define __byte_swap_word_variable(x) \ -({ register unsigned short __x = (x); \ +#define __byte_swap_int16_variable(x) \ +({ register u_int16_t __x = (x); \ __asm ("rorw $8, %w1" \ : "=r" (__x) \ : "0" (__x)); \ @@ -94,32 +95,32 @@ __END_DECLS #ifdef __OPTIMIZE__ -#define __byte_swap_long_constant(x) \ +#define __byte_swap_int32_constant(x) \ ((((x) & 0xff000000) >> 24) | \ (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | \ (((x) & 0x000000ff) << 24)) -#define __byte_swap_word_constant(x) \ +#define __byte_swap_int16_constant(x) \ ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8)) -#define __byte_swap_long(x) \ +#define __byte_swap_int32(x) \ (__builtin_constant_p((x)) ? \ - __byte_swap_long_constant(x) : __byte_swap_long_variable(x)) -#define __byte_swap_word(x) \ + __byte_swap_int32_constant(x) : __byte_swap_int32_variable(x)) +#define __byte_swap_int16(x) \ (__builtin_constant_p((x)) ? \ - __byte_swap_word_constant(x) : __byte_swap_word_variable(x)) + __byte_swap_int16_constant(x) : __byte_swap_int16_variable(x)) #else /* __OPTIMIZE__ */ -#define __byte_swap_long(x) __byte_swap_long_variable(x) -#define __byte_swap_word(x) __byte_swap_word_variable(x) +#define __byte_swap_int32(x) __byte_swap_int32_variable(x) +#define __byte_swap_int16(x) __byte_swap_int16_variable(x) #endif /* __OPTIMIZE__ */ -#define ntohl(x) __byte_swap_long(x) -#define ntohs(x) __byte_swap_word(x) -#define htonl(x) __byte_swap_long(x) -#define htons(x) __byte_swap_word(x) +#define ntohl(x) __byte_swap_int32(x) +#define ntohs(x) __byte_swap_int16(x) +#define htonl(x) __byte_swap_int32(x) +#define htons(x) __byte_swap_int16(x) #endif /* __GNUC__ */ @@ -127,10 +128,10 @@ __END_DECLS /* * Macros for network/external number representation conversion. */ -#define NTOHL(x) (x) = ntohl((unsigned long)(x)) -#define NTOHS(x) (x) = ntohs((unsigned short)(x)) -#define HTONL(x) (x) = htonl((unsigned long)(x)) -#define HTONS(x) (x) = htons((unsigned short)(x)) +#define NTOHL(x) (x) = ntohl((u_int32_t)(x)) +#define NTOHS(x) (x) = ntohs((u_int16_t)(x)) +#define HTONL(x) (x) = htonl((u_int32_t)(x)) +#define HTONS(x) (x) = htons((u_int16_t)(x)) #endif /* _POSIX_SOURCE */ diff --git a/sys/arch/m68k/include/endian.h b/sys/arch/m68k/include/endian.h index 90ae3d5190e..979c8d844ff 100644 --- a/sys/arch/m68k/include/endian.h +++ b/sys/arch/m68k/include/endian.h @@ -1,4 +1,4 @@ -/* $OpenBSD: endian.h,v 1.2 1996/04/21 22:17:40 deraadt Exp $ */ +/* $OpenBSD: endian.h,v 1.3 1996/11/25 13:11:26 niklas Exp $ */ /* $NetBSD: endian.h,v 1.7 1996/03/29 01:40:31 briggs Exp $ */ /* @@ -52,17 +52,17 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER BIG_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS /* @@ -81,10 +81,10 @@ __END_DECLS #else -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) +#define NTOHL(x) (x) = ntohl((u_int32_t)x) +#define NTOHS(x) (x) = ntohs((u_int16_t)x) +#define HTONL(x) (x) = htonl((u_int32_t)x) +#define HTONS(x) (x) = htons((u_int16_t)x) #endif #endif /* _POSIX_SOURCE */ diff --git a/sys/arch/mvme88k/include/endian.h b/sys/arch/mvme88k/include/endian.h index 82b3588d62b..ce22d3d35bc 100644 --- a/sys/arch/mvme88k/include/endian.h +++ b/sys/arch/mvme88k/include/endian.h @@ -1,3 +1,5 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:28 niklas Exp $ */ + /* * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +33,6 @@ * SUCH DAMAGE. * * from: @(#)endian.h 8.1 (Berkeley) 6/11/93 - * $Id: endian.h,v 1.1.1.1 1995/10/18 10:54:21 deraadt Exp $ */ #ifndef _ENDIAN_H_ @@ -51,17 +52,17 @@ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, 88000 ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER BIG_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS /* @@ -80,10 +81,10 @@ __END_DECLS #else -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) +#define NTOHL(x) (x) = ntohl((u_int32_t)x) +#define NTOHS(x) (x) = ntohs((u_int16_t)x) +#define HTONL(x) (x) = htonl((u_int32_t)x) +#define HTONS(x) (x) = htons((u_int16_t)x) #endif #endif /* ! _POSIX_SOURCE */ #endif /* !_ENDIAN_H_ */ diff --git a/sys/arch/pc532/include/endian.h b/sys/arch/pc532/include/endian.h index a9d8cb4d942..ebb4778bf0d 100644 --- a/sys/arch/pc532/include/endian.h +++ b/sys/arch/pc532/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:31 niklas Exp $ */ /* $NetBSD: endian.h,v 1.8 1995/06/18 07:13:46 phil Exp $ */ /* @@ -51,31 +52,31 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax, ns32000 */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER LITTLE_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS #ifdef __GNUC__ -#define __byte_swap_long_variable(x) \ -({ register unsigned long __x = (x); \ +#define __byte_swap_int32_variable(x) \ +({ register u_int32_t __x = (x); \ __asm ("rotw 8,%1; rotd 16,%1; rotw 8,%1" \ : "=r" (__x) \ : "0" (__x)); \ __x; }) -#define __byte_swap_word_variable(x) \ -({ register unsigned short __x = (x); \ +#define __byte_swap_int16_variable(x) \ +({ register u_int16_t __x = (x); \ __asm ("rotw 8,%1" \ : "=r" (__x) \ : "0" (__x)); \ @@ -84,32 +85,32 @@ __END_DECLS #ifdef __OPTIMIZE__ -#define __byte_swap_long_constant(x) \ +#define __byte_swap_int32_constant(x) \ ((((x) & 0xff000000) >> 24) | \ (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | \ (((x) & 0x000000ff) << 24)) -#define __byte_swap_word_constant(x) \ +#define __byte_swap_int16__constant(x) \ ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8)) -#define __byte_swap_long(x) \ +#define __byte_swap_int32(x) \ (__builtin_constant_p((x)) ? \ - __byte_swap_long_constant(x) : __byte_swap_long_variable(x)) -#define __byte_swap_word(x) \ + __byte_swap_int32_constant(x) : __byte_swap_int32_variable(x)) +#define __byte_swap_int16(x) \ (__builtin_constant_p((x)) ? \ - __byte_swap_word_constant(x) : __byte_swap_word_variable(x)) + __byte_swap_int16_constant(x) : __byte_swap_int16_variable(x)) #else /* __OPTIMIZE__ */ -#define __byte_swap_long(x) __byte_swap_long_variable(x) -#define __byte_swap_word(x) __byte_swap_word_variable(x) +#define __byte_swap_int32(x) __byte_swap_int32_variable(x) +#define __byte_swap_int16(x) __byte_swap_int16_variable(x) #endif /* __OPTIMIZE__ */ -#define ntohl(x) __byte_swap_long(x) -#define ntohs(x) __byte_swap_word(x) -#define htonl(x) __byte_swap_long(x) -#define htons(x) __byte_swap_word(x) +#define ntohl(x) __byte_swap_int32(x) +#define ntohs(x) __byte_swap_int16(x) +#define htonl(x) __byte_swap_int32(x) +#define htons(x) __byte_swap_int16(x) #endif /* __GNUC__ */ @@ -117,10 +118,10 @@ __END_DECLS /* * Macros for network/external number representation conversion. */ -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) +#define NTOHL(x) (x) = ntohl((u_int32_t)x) +#define NTOHS(x) (x) = ntohs((u_int16_t)x) +#define HTONL(x) (x) = htonl((u_int32_t)x) +#define HTONS(x) (x) = htons((u_int16_t)x) #endif /* _POSIX_SOURCE */ diff --git a/sys/arch/pmax/include/endian.h b/sys/arch/pmax/include/endian.h index 33ecdafd7b5..81ca584b676 100644 --- a/sys/arch/pmax/include/endian.h +++ b/sys/arch/pmax/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.4 1996/11/25 13:11:34 niklas Exp $ */ /* $NetBSD: endian.h,v 1.5.4.1 1996/06/05 23:53:20 jonathan Exp $ */ /* @@ -56,7 +57,7 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER LITTLE_ENDIAN @@ -65,8 +66,6 @@ __BEGIN_DECLS u_int32_t htonl __P((u_int32_t)); - - u_int16_t htons __P((u_int16_t)); u_int32_t ntohl __P((u_int32_t)); u_int16_t ntohs __P((u_int16_t)); diff --git a/sys/arch/sparc/include/endian.h b/sys/arch/sparc/include/endian.h index 3d4297321bf..b7a1556c73b 100644 --- a/sys/arch/sparc/include/endian.h +++ b/sys/arch/sparc/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.3 1996/11/25 13:11:36 niklas Exp $ */ /* $NetBSD: endian.h,v 1.3 1996/02/13 17:04:58 christos Exp $ */ /* @@ -47,17 +48,17 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER BIG_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS /* @@ -76,10 +77,10 @@ __END_DECLS #else -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) +#define NTOHL(x) (x) = ntohl((u_int32_t)x) +#define NTOHS(x) (x) = ntohs((u_int16_t)x) +#define HTONL(x) (x) = htonl((u_int32_t)x) +#define HTONS(x) (x) = htons((u_int16_t)x) #endif #endif /* _MACHINE_ENDIAN_H_ */ diff --git a/sys/arch/sun3/include/endian.h b/sys/arch/sun3/include/endian.h index 1ec107a8e6d..4725a83ab43 100644 --- a/sys/arch/sun3/include/endian.h +++ b/sys/arch/sun3/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.2 1996/11/25 13:11:37 niklas Exp $ */ /* $NetBSD: endian.h,v 1.6 1994/11/21 21:33:37 gwr Exp $ */ #include <m68k/endian.h> diff --git a/sys/arch/vax/include/endian.h b/sys/arch/vax/include/endian.h index b43df880e93..ac0699c9329 100644 --- a/sys/arch/vax/include/endian.h +++ b/sys/arch/vax/include/endian.h @@ -1,3 +1,4 @@ +/* $OpenBSD: endian.h,v 1.3 1996/11/25 13:11:40 niklas Exp $ */ /* $NetBSD: endian.h,v 1.7 1996/04/08 18:35:48 ragge Exp $ */ /* @@ -49,23 +50,23 @@ */ #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in int32_t */ #define BYTE_ORDER LITTLE_ENDIAN #include <sys/cdefs.h> __BEGIN_DECLS -unsigned long htonl __P((unsigned long)); -unsigned short htons __P((unsigned short)); -unsigned long ntohl __P((unsigned long)); -unsigned short ntohs __P((unsigned short)); +u_int32_t htonl __P((u_int32_t)); +u_int16_t htons __P((u_int16_t)); +u_int32_t ntohl __P((u_int32_t)); +u_int16_t ntohs __P((u_int16_t)); __END_DECLS #ifdef __GNUC__ -#define __byte_swap_long_variable(x) \ -({ register unsigned long __y, __x = (x); \ +#define __byte_swap_int32_variable(x) \ +({ register u_int32_t __y, __x = (x); \ \ __asm ("rotl $-8, %1, %0; \ insv %0, $16, $8, %0; \ @@ -76,8 +77,8 @@ __END_DECLS : "r1", "cc" ); \ __y; }) -#define __byte_swap_word_variable(x) \ -({ register unsigned short __y, __x = (x); \ +#define __byte_swap_int16_variable(x) \ +({ register u_int16_t __y, __x = (x); \ \ __asm ("rotl $8, %1, %0; \ rotl $-8, %1, r1; \ @@ -89,23 +90,23 @@ __END_DECLS __y; }) -#define __byte_swap_long(x) __byte_swap_long_variable(x) -#define __byte_swap_word(x) __byte_swap_word_variable(x) +#define __byte_swap_int32(x) __byte_swap_int32_variable(x) +#define __byte_swap_int16(x) __byte_swap_int16_variable(x) -#define ntohl(x) __byte_swap_long(x) -#define ntohs(x) __byte_swap_word(x) -#define htonl(x) __byte_swap_long(x) -#define htons(x) __byte_swap_word(x) +#define ntohl(x) __byte_swap_int32(x) +#define ntohs(x) __byte_swap_int16(x) +#define htonl(x) __byte_swap_int32(x) +#define htons(x) __byte_swap_int16(x) #endif /* __GNUC__ */ /* * Macros for network/external number representation conversion. */ -#define NTOHL(x) (x) = ntohl((unsigned long)(x)) -#define NTOHS(x) (x) = ntohs((unsigned long)(x)) -#define HTONL(x) (x) = htonl((unsigned long)(x)) -#define HTONS(x) (x) = htons((unsigned long)(x)) +#define NTOHL(x) (x) = ntohl((u_int32_t)(x)) +#define NTOHS(x) (x) = ntohs((u_int32_t)(x)) +#define HTONL(x) (x) = htonl((u_int32_t)(x)) +#define HTONS(x) (x) = htons((u_int32_t)(x)) #endif /* _POSIX_SOURCE */ |