summaryrefslogtreecommitdiff
path: root/sys/arch/vax
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-11-25 13:11:41 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-11-25 13:11:41 +0000
commit18f45ad398b05c4efffae0a93e86d74c54b3c8d7 (patch)
treec6c23bbb71a3571cd28044d4d7c93631ebf9e4ce /sys/arch/vax
parentd85e22a85637536532097c45f5dce36b039cf6f4 (diff)
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
Diffstat (limited to 'sys/arch/vax')
-rw-r--r--sys/arch/vax/include/endian.h39
1 files changed, 20 insertions, 19 deletions
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 */