commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8654 - in gnuradio/trunk: . config gruel/src/include/


From: jcorgan
Subject: [Commit-gnuradio] r8654 - in gnuradio/trunk: . config gruel/src/include/gruel
Date: Sun, 22 Jun 2008 16:56:49 -0600 (MDT)

Author: jcorgan
Date: 2008-06-22 16:56:48 -0600 (Sun, 22 Jun 2008)
New Revision: 8654

Added:
   gnuradio/trunk/gruel/src/include/gruel/inet.h.in
Modified:
   gnuradio/trunk/config/grc_gruel.m4
   gnuradio/trunk/configure.ac
   gnuradio/trunk/gruel/src/include/gruel/
   gnuradio/trunk/gruel/src/include/gruel/Makefile.am
Log:
Added autoconf independent bytesex routines to libgruel.

Modified: gnuradio/trunk/config/grc_gruel.m4
===================================================================
--- gnuradio/trunk/config/grc_gruel.m4  2008-06-22 21:25:21 UTC (rev 8653)
+++ gnuradio/trunk/config/grc_gruel.m4  2008-06-22 22:56:48 UTC (rev 8654)
@@ -37,6 +37,7 @@
         gruel/src/Makefile \
         gruel/src/include/Makefile \
         gruel/src/include/gruel/Makefile \
+       gruel/src/include/gruel/inet.h \
         gruel/src/lib/Makefile \
     ])
 

Modified: gnuradio/trunk/configure.ac
===================================================================
--- gnuradio/trunk/configure.ac 2008-06-22 21:25:21 UTC (rev 8653)
+++ gnuradio/trunk/configure.ac 2008-06-22 22:56:48 UTC (rev 8654)
@@ -128,13 +128,16 @@
 AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h)
 AC_CHECK_HEADERS(netinet/in.h)
 AC_CHECK_HEADERS(windows.h)
+AC_CHECK_HEADER(byteswap.h, [GR_HAVE_BYTESWAP=1],[GR_HAVE_BYTESWAP=0])
+AC_SUBST(GR_HAVE_BYTESWAP)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
-AC_C_BIGENDIAN
+AC_C_BIGENDIAN([GR_ARCH_BIGENDIAN=1],[GR_ARCH_BIGENDIAN=0])
+AC_SUBST(GR_ARCH_BIGENDIAN)
 AC_STRUCT_TM
 
 dnl Checks for library functions.


Property changes on: gnuradio/trunk/gruel/src/include/gruel
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in

   + Makefile
Makefile.in
inet.h


Modified: gnuradio/trunk/gruel/src/include/gruel/Makefile.am
===================================================================
--- gnuradio/trunk/gruel/src/include/gruel/Makefile.am  2008-06-22 21:25:21 UTC 
(rev 8653)
+++ gnuradio/trunk/gruel/src/include/gruel/Makefile.am  2008-06-22 22:56:48 UTC 
(rev 8654)
@@ -21,7 +21,11 @@
 
 include $(top_srcdir)/Makefile.common
 
+BUILT_SOURCES = \
+       inet.h
+
 gruelincludedir = $(prefix)/include/gruel
 
 gruelinclude_HEADERS = \
+       $(BUILT_SOURCES) \
        realtime.h

Added: gnuradio/trunk/gruel/src/include/gruel/inet.h.in
===================================================================
--- gnuradio/trunk/gruel/src/include/gruel/inet.h.in                            
(rev 0)
+++ gnuradio/trunk/gruel/src/include/gruel/inet.h.in    2008-06-22 22:56:48 UTC 
(rev 8654)
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_INET_H
+#define INCLUDED_INET_H
+
+#include <stdint.h>
+
+#if @GR_ARCH_BIGENDIAN@  /* GR_ARCH_BIGENDIAN */
+// Nothing to do...
+static inline uint32_t htonl(uint32_t x){ return x; }
+static inline uint16_t htons(uint16_t x){ return x; }
+static inline uint32_t ntohl(uint32_t x){ return x; }
+static inline uint16_t ntohs(uint16_t x){ return x; }
+#else
+#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)
+{
+  return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+
+static inline unsigned int
+bswap_32 (unsigned int x)
+{
+  return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8)      \
+       | (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24));
+}
+#endif /* GR_HAVE_BYTESWAP */
+
+static inline uint32_t htonl(uint32_t x){ return bswap_32(x); }
+static inline uint16_t htons(uint16_t x){ return bswap_16(x); }
+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 */
+
+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); }
+static inline uint8_t  htonx(uint8_t  x){ return x;        }
+static inline uint16_t htonx(uint16_t x){ return htons(x); }
+static inline uint32_t htonx(uint32_t x){ return htonl(x); }
+
+#endif /* INCLUDED_INET_H */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]