use in_addr_t and in_port_t
This commit is contained in:
parent
ca36ac9ef4
commit
7c9b908394
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: endian.h,v 1.8 1995/06/18 07:13:46 phil Exp $ */
|
||||
/* $NetBSD: endian.h,v 1.9 1996/10/13 03:12:38 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1991 Regents of the University of California.
|
||||
|
@ -57,25 +57,28 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
typedef u_int32_t in_addr_t;
|
||||
typedef u_int16_t in_port_t;
|
||||
|
||||
__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));
|
||||
in_addr_t htonl __P((in_addr_t));
|
||||
in_port_t htons __P((in_port_t));
|
||||
in_addr_t ntohl __P((in_addr_t));
|
||||
in_port_t ntohs __P((in_port_t));
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define __byte_swap_long_variable(x) \
|
||||
({ register unsigned long __x = (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); \
|
||||
({ register u_int16_t __x = (x); \
|
||||
__asm ("rotw 8,%1" \
|
||||
: "=r" (__x) \
|
||||
: "0" (__x)); \
|
||||
|
@ -117,10 +120,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((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)
|
||||
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
|
|
Loading…
Reference in New Issue