pull down from libc

This commit is contained in:
cgd 1996-10-17 01:41:35 +00:00
parent 98a0fb0a16
commit f929fef799
4 changed files with 24 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: htonl.c,v 1.7 1996/05/29 23:39:30 cgd Exp $ */
/* $NetBSD: htonl.c,v 1.8 1996/10/17 01:41:35 cgd Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
@ -6,24 +6,21 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: htonl.c,v 1.7 1996/05/29 23:39:30 cgd Exp $";
static char *rcsid = "$NetBSD: htonl.c,v 1.8 1996/10/17 01:41:35 cgd Exp $";
#endif
#include <sys/types.h>
#include <machine/endian.h>
#undef htonl
unsigned long
in_addr_t
htonl(x)
unsigned long x;
in_addr_t x;
{
u_int32_t y = x;
#if BYTE_ORDER == LITTLE_ENDIAN
u_char *s = (u_char *)&y;
return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
u_char *s = (u_char *)&x;
return (in_addr_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
#else
return y;
return x;
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: htons.c,v 1.7 1996/05/29 23:39:37 cgd Exp $ */
/* $NetBSD: htons.c,v 1.8 1996/10/17 01:41:37 cgd Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
@ -6,21 +6,20 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: htons.c,v 1.7 1996/05/29 23:39:37 cgd Exp $";
static char *rcsid = "$NetBSD: htons.c,v 1.8 1996/10/17 01:41:37 cgd Exp $";
#endif
#include <sys/types.h>
#include <machine/endian.h>
#undef htons
unsigned short
in_port_t
htons(x)
unsigned short x;
in_port_t x;
{
#if BYTE_ORDER == LITTLE_ENDIAN
u_char *s = (u_char *) &x;
return (u_int16_t)(s[0] << 8 | s[1]);
return (in_port_t)(s[0] << 8 | s[1]);
#else
return x;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntohl.c,v 1.7 1996/05/29 23:39:42 cgd Exp $ */
/* $NetBSD: ntohl.c,v 1.8 1996/10/17 01:41:39 cgd Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
@ -6,24 +6,21 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: ntohl.c,v 1.7 1996/05/29 23:39:42 cgd Exp $";
static char *rcsid = "$NetBSD: ntohl.c,v 1.8 1996/10/17 01:41:39 cgd Exp $";
#endif
#include <sys/types.h>
#include <machine/endian.h>
#undef ntohl
unsigned long
in_addr_t
ntohl(x)
unsigned long x;
in_addr_t x;
{
u_int32_t y = x;
#if BYTE_ORDER == LITTLE_ENDIAN
u_char *s = (u_char *)&y;
return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
u_char *s = (u_char *)&x;
return (in_addr_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
#else
return y;
return x;
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntohs.c,v 1.6 1996/05/29 23:39:46 cgd Exp $ */
/* $NetBSD: ntohs.c,v 1.7 1996/10/17 01:41:41 cgd Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
@ -6,21 +6,20 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$NetBSD: ntohs.c,v 1.6 1996/05/29 23:39:46 cgd Exp $";
static char *rcsid = "$NetBSD: ntohs.c,v 1.7 1996/10/17 01:41:41 cgd Exp $";
#endif
#include <sys/types.h>
#include <machine/endian.h>
#undef ntohs
unsigned short
in_port_t
ntohs(x)
unsigned short x;
in_port_t x;
{
#if BYTE_ORDER == LITTLE_ENDIAN
u_char *s = (u_char *) &x;
return (u_int16_t)(s[0] << 8 | s[1]);
return (in_port_t)(s[0] << 8 | s[1]);
#else
return x;
#endif