* net.cc: Include asm/byteorder.h.
(htonl): Move to end of file. Add comment to explain why. Align definition to POSIX. Use related macro from asm/byteorder.h. (ntohl): Ditto. (htons): Ditto. (ntohs): Ditto. * include/asm/byteorder.h: Revert previous patch.
This commit is contained in:
parent
ed296a4727
commit
2895b8b502
|
@ -1,3 +1,13 @@
|
|||
2009-03-03 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* net.cc: Include asm/byteorder.h.
|
||||
(htonl): Move to end of file. Add comment to explain why. Align
|
||||
definition to POSIX. Use related macro from asm/byteorder.h.
|
||||
(ntohl): Ditto.
|
||||
(htons): Ditto.
|
||||
(ntohs): Ditto.
|
||||
* include/asm/byteorder.h: Revert previous patch.
|
||||
|
||||
2009-03-03 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* include/asm/byteorder.h: Disable optimization when building
|
||||
|
|
|
@ -70,8 +70,7 @@ __ntohs(uint16_t x)
|
|||
#define __constant_htonl(x) __constant_ntohl(x)
|
||||
#define __constant_htons(x) __constant_ntohs(x)
|
||||
|
||||
#if defined (__OPTIMIZE__) && !defined (__NO_INLINE__) \
|
||||
&& !defined (__INSIDE_CYGWIN_NET__)
|
||||
#if defined (__OPTIMIZE__) && !defined (__NO_INLINE__)
|
||||
# define ntohl(x) \
|
||||
(__builtin_constant_p((long)(x)) ? \
|
||||
__constant_ntohl((x)) : \
|
||||
|
|
|
@ -23,6 +23,7 @@ details. */
|
|||
#include <unistd.h>
|
||||
#undef gethostname
|
||||
#include <netdb.h>
|
||||
#include <asm/byteorder.h>
|
||||
#define USE_SYS_TYPES_FD_SET
|
||||
#include <winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
|
@ -73,38 +74,6 @@ get (const int fd)
|
|||
return fh;
|
||||
}
|
||||
|
||||
/* htonl: standards? */
|
||||
extern "C" unsigned long int
|
||||
htonl (unsigned long int x)
|
||||
{
|
||||
return ((((x & 0x000000ffU) << 24) |
|
||||
((x & 0x0000ff00U) << 8) |
|
||||
((x & 0x00ff0000U) >> 8) |
|
||||
((x & 0xff000000U) >> 24)));
|
||||
}
|
||||
|
||||
/* ntohl: standards? */
|
||||
extern "C" unsigned long int
|
||||
ntohl (unsigned long int x)
|
||||
{
|
||||
return htonl (x);
|
||||
}
|
||||
|
||||
/* htons: standards? */
|
||||
extern "C" unsigned short
|
||||
htons (unsigned short x)
|
||||
{
|
||||
return ((((x & 0x000000ffU) << 8) |
|
||||
((x & 0x0000ff00U) >> 8)));
|
||||
}
|
||||
|
||||
/* ntohs: standards? */
|
||||
extern "C" unsigned short
|
||||
ntohs (unsigned short x)
|
||||
{
|
||||
return htons (x);
|
||||
}
|
||||
|
||||
/* exported as inet_ntoa: BSD 4.3 */
|
||||
extern "C" char *
|
||||
cygwin_inet_ntoa (struct in_addr in)
|
||||
|
@ -4019,7 +3988,8 @@ cygwin_getnameinfo (const struct sockaddr *sa, socklen_t salen,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* The below function has been taken from OpenBSD's src/sys/netinet6/in6.c. */
|
||||
/* The below function in6_are_prefix_equal has been taken from OpenBSD's
|
||||
src/sys/netinet6/in6.c. */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -4103,3 +4073,39 @@ in6_are_prefix_equal (struct in6_addr *p1, struct in6_addr *p2, int len)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* These functions are stick to the end of this file so that the
|
||||
optimization in asm/byteorder.h can be used even here in net.cc. */
|
||||
|
||||
#undef htonl
|
||||
#undef ntohl
|
||||
#undef htons
|
||||
#undef ntohs
|
||||
|
||||
/* htonl: standards? */
|
||||
extern "C" uint32_t
|
||||
htonl (uint32_t x)
|
||||
{
|
||||
return __htonl (x);
|
||||
}
|
||||
|
||||
/* ntohl: standards? */
|
||||
extern "C" uint32_t
|
||||
ntohl (uint32_t x)
|
||||
{
|
||||
return __ntohl (x);
|
||||
}
|
||||
|
||||
/* htons: standards? */
|
||||
extern "C" uint16_t
|
||||
htons (uint16_t x)
|
||||
{
|
||||
return __htons (x);
|
||||
}
|
||||
|
||||
/* ntohs: standards? */
|
||||
extern "C" uint16_t
|
||||
ntohs (uint16_t x)
|
||||
{
|
||||
return __ntohs (x);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue