Subject: ntohl() types
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 08/22/2001 14:09:25
	XNET 5.2 (p92) says that ntohl() and friends should use uint32_t and
	uint16_t (u_int32_t and u_int16_t if you favor BSD-like types).
	NetBSD header files use in_addr_t and in_port_t.  are there any
	reasons why they should be like this?

	i guess I'm trying to suggest the following diff.

itojun


Index: endian.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/endian.h,v
retrieving revision 1.3
diff -u -r1.3 endian.h
--- endian.h	2000/03/17 11:47:43	1.3
+++ endian.h	2001/08/22 05:09:48
@@ -83,10 +83,10 @@
 typedef u_int16_t	in_port_t;
 
 __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_int32_t	htonl __P((u_int32_t)) __attribute__((__const__));
+u_int16_t	htons __P((u_int16_t)) __attribute__((__const__));
+u_int32_t	ntohl __P((u_int32_t)) __attribute__((__const__));
+u_int16_t	ntohs __P((u_int16_t)) __attribute__((__const__));
 __END_DECLS
 
 /*
@@ -105,10 +105,10 @@
 
 #else	/* LITTLE_ENDIAN || !defined(lint) */
 
-#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((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	/* LITTLE_ENDIAN || !defined(lint) */
 
 /*