summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2002-02-18 20:35:27 +0000
committermike <mike@FreeBSD.org>2002-02-18 20:35:27 +0000
commitbcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f (patch)
tree970c36894ee638248ec810bd7570ac8aabb5eaf5 /include
parentf2e166dc7a7880a8564c2a7cb8ca2b94566d8d6b (diff)
downloadFreeBSD-src-bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f.zip
FreeBSD-src-bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f.tar.gz
o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants. o Change all occurrences of NTOHL() and associated marcros in the source tree to use the lowercase function variants. o Add missing license bits to sparc64's <machine/endian.h>. Approved by: jake o Clean up <machine/endian.h> files. o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>. o Remove prototypes for non-existent bswapXX() functions. o Include <machine/endian.h> in <arpa/inet.h> to define the POSIX-required ntohl() family of functions. o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>, and <sys/param.h>. o Prepend underscores to the ntohl() family to help deal with complexities associated with having MD (asm and inline) versions, and having to prevent exposure of these functions in other headers that happen to make use of endian-specific defines. o Create weak aliases to the canonical function name to help deal with third-party software forgetting to include an appropriate header. o Remove some now unneeded pollution from <sys/types.h>. o Add missing <arpa/inet.h> includes in userland. Tested on: alpha, i386 Reviewed by: bde, jake, tmm
Diffstat (limited to 'include')
-rw-r--r--include/arpa/inet.h22
-rw-r--r--include/rpc/xdr.h8
2 files changed, 20 insertions, 10 deletions
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
index 7ac95e5..3ac128d 100644
--- a/include/arpa/inet.h
+++ b/include/arpa/inet.h
@@ -47,9 +47,7 @@
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
- */
-
-/*
+ *
* @(#)inet.h 8.1 (Berkeley) 6/2/93
* From: Id: inet.h,v 8.5 1997/01/29 08:48:09 vixie Exp $
* $FreeBSD$
@@ -63,6 +61,9 @@
#include <sys/cdefs.h>
#include <machine/ansi.h>
+/* Required for byteorder(3) functions. */
+#include <machine/endian.h>
+
#ifndef _IN_ADDR_T_DECLARED_
typedef __uint32_t in_addr_t;
#define _IN_ADDR_T_DECLARED_
@@ -114,14 +115,23 @@ struct in_addr {
#define inet_nsap_ntoa __inet_nsap_ntoa
#endif /* !_POSIX_SOURCE */
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define _BYTEORDER_FUNC_DEFINED
+#define htonl(x) __htonl(x)
+#define htons(x) __htons(x)
+#define ntohl(x) __ntohl(x)
+#define ntohs(x) __ntohs(x)
+#endif
+
__BEGIN_DECLS
+__uint32_t htonl(__uint32_t);
+__uint16_t htons(__uint16_t);
in_addr_t inet_addr __P((const char *));
char *inet_ntoa __P((struct in_addr));
const char *inet_ntop __P((int, const void *, char *, socklen_t));
int inet_pton __P((int, const char *, void *));
-/*
- * XXX missing: ntohl() family.
- */
+__uint32_t ntohl(__uint32_t);
+__uint16_t ntohs(__uint16_t);
/* Nonstandard functions. */
#ifndef _POSIX_SOURCE
diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
index d38aa49..9867b25 100644
--- a/include/rpc/xdr.h
+++ b/include/rpc/xdr.h
@@ -261,13 +261,13 @@ struct xdr_discrim {
* N.B. and frozen for all time: each data type here uses 4 bytes
* of external representation.
*/
-#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++))
-#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))
+#define IXDR_GET_INT32(buf) ((int32_t)__ntohl((u_int32_t)*(buf)++))
+#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v))
#define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf))
#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v)))
-#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++))
-#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))
+#define IXDR_GET_LONG(buf) ((long)__ntohl((u_int32_t)*(buf)++))
+#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v))
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
OpenPOWER on IntegriCloud