summaryrefslogtreecommitdiff
path: root/gruel/src
diff options
context:
space:
mode:
authorjcorgan2008-06-23 00:25:56 +0000
committerjcorgan2008-06-23 00:25:56 +0000
commitc1ff40ad50fd29ff64c8c3991d7b5f69b43c661d (patch)
tree39fc0417c2363b65f85973a1e540e66f9f2be284 /gruel/src
parent1adf4453962da0c2ebda1a8833ef3b5b849754e3 (diff)
downloadgnuradio-c1ff40ad50fd29ff64c8c3991d7b5f69b43c661d.tar.gz
gnuradio-c1ff40ad50fd29ff64c8c3991d7b5f69b43c661d.tar.bz2
gnuradio-c1ff40ad50fd29ff64c8c3991d7b5f69b43c661d.zip
Use system byteswap implementations where available.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8658 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gruel/src')
-rw-r--r--gruel/src/include/gruel/inet.h.in21
1 files changed, 13 insertions, 8 deletions
diff --git a/gruel/src/include/gruel/inet.h.in b/gruel/src/include/gruel/inet.h.in
index dd0525708..a98d83e9c 100644
--- a/gruel/src/include/gruel/inet.h.in
+++ b/gruel/src/include/gruel/inet.h.in
@@ -19,6 +19,11 @@
#ifndef INCLUDED_INET_H
#define INCLUDED_INET_H
+#if @GR_HAVE_ARPA_INET@ /* GR_HAVE_ARPA_INET */
+#include <arpa/inet.h>
+#elif @GR_HAVE_NETINET_IN@ /* GR_HAVE_NETINET_IN */
+#include <netinet/in.h>
+#else
#include <stdint.h>
#if @GR_ARCH_BIGENDIAN@ /* GR_ARCH_BIGENDIAN */
@@ -31,19 +36,17 @@ static inline uint16_t ntohs(uint16_t x){ return x; }
#if @GR_HAVE_BYTESWAP@ /* GR_HAVE_BYTESWAP */
#include <byteswap.h>
#else
-#warning Using non-portable code (likely wrong other than ILP32).
-
-static inline unsigned short int
-bswap_16 (unsigned short int x)
+static inline uint16_t
+bswap_16 (uint16_t x)
{
return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
}
-static inline unsigned int
-bswap_32 (unsigned int x)
+static inline uint32_t
+bswap_32 (uint32_t x)
{
- return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
+ return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
+ | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
}
#endif /* GR_HAVE_BYTESWAP */
@@ -53,6 +56,8 @@ static inline uint32_t ntohl(uint32_t x){ return bswap_32(x); }
static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); }
#endif /* GR_ARCH_BIGENDIAN */
+#endif /* !(GR_HAVE_NETINET_IN || GR_HAVE_ARPA_INET) */
+
static inline uint8_t ntohx(uint8_t x){ return x; }
static inline uint16_t ntohx(uint16_t x){ return ntohs(x); }
static inline uint32_t ntohx(uint32_t x){ return ntohl(x); }