summaryrefslogtreecommitdiff
path: root/sys/arch/pc532
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/pc532
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/pc532')
-rw-r--r--sys/arch/pc532/include/endian.h51
1 files changed, 26 insertions, 25 deletions
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 */