diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-03-03 11:44:18 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-03-03 11:44:18 +0000 |
commit | 2895b8b5024af0b63eb4363ca3fb6e9a932994a1 (patch) | |
tree | 26f89ba25493b6e8405fcd15c00dc2e386dce8fa /winsup/cygwin/net.cc | |
parent | ed296a47279daf8af30812a6084ab4839c3d879d (diff) | |
download | cygnal-2895b8b5024af0b63eb4363ca3fb6e9a932994a1.tar.gz cygnal-2895b8b5024af0b63eb4363ca3fb6e9a932994a1.tar.bz2 cygnal-2895b8b5024af0b63eb4363ca3fb6e9a932994a1.zip |
* 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.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r-- | winsup/cygwin/net.cc | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 39f025aad..8ffc041b3 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -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); +} |