summaryrefslogtreecommitdiff
path: root/gruel
diff options
context:
space:
mode:
Diffstat (limited to 'gruel')
-rw-r--r--gruel/src/include/gruel/CMakeLists.txt20
-rw-r--r--gruel/src/include/gruel/inet.h.in100
-rw-r--r--gruel/src/lib/pmt/pmt-serial-tags.scm2
-rw-r--r--gruel/src/lib/pmt/pmt_serialize.cc56
-rw-r--r--gruel/src/swig/CMakeLists.txt4
5 files changed, 55 insertions, 127 deletions
diff --git a/gruel/src/include/gruel/CMakeLists.txt b/gruel/src/include/gruel/CMakeLists.txt
index 9818f1c09..d4c36eddb 100644
--- a/gruel/src/include/gruel/CMakeLists.txt
+++ b/gruel/src/include/gruel/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Free Software Foundation, Inc.
+# Copyright 2010-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -18,30 +18,12 @@
# Boston, MA 02110-1301, USA.
########################################################################
-# Generate inet.h header file
-########################################################################
-include(TestBigEndian)
-enable_language(C)
-TEST_BIG_ENDIAN(GR_ARCH_BIGENDIAN)
-
-include(CheckIncludeFileCXX)
-CHECK_INCLUDE_FILE_CXX(byteswap.h GR_HAVE_BYTESWAP)
-CHECK_INCLUDE_FILE_CXX(arpa/inet.h GR_HAVE_ARPA_INET)
-CHECK_INCLUDE_FILE_CXX(netinet/in.h GR_HAVE_NETINET_IN)
-
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/inet.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/inet.h
-@ONLY)
-
-########################################################################
# Install the headers
########################################################################
install(FILES
api.h
attributes.h
high_res_timer.h
- ${CMAKE_CURRENT_BINARY_DIR}/inet.h
msg_accepter.h
msg_accepter_msgq.h
msg_queue.h
diff --git a/gruel/src/include/gruel/inet.h.in b/gruel/src/include/gruel/inet.h.in
deleted file mode 100644
index 74f14bd92..000000000
--- a/gruel/src/include/gruel/inet.h.in
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008, 2009 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 <gruel/api.h>
-#include <stdint.h>
-
-#if 1 /* missing htonll or ntohll */
-#if @GR_ARCH_BIGENDIAN@ /* GR_ARCH_BIGENDIAN */
-// Nothing to do...
-static inline uint64_t htonll(uint64_t x){ return x;}
-static inline uint64_t ntohll(uint64_t x){ return x;}
-#else
-#if @GR_HAVE_BYTESWAP@ /* GR_HAVE_BYTESWAP */
-#include <byteswap.h>
-#else
-
-static inline uint64_t
-bswap_64(uint64_t x)
-{
- return ((x & 0x00000000000000ffull) << 56) | ((x & 0x000000000000ff00ull) << 40) |
- ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x00000000ff000000ull) << 8) |
- ((x & 0x000000ff00000000ull) >> 8) | ((x & 0x0000ff0000000000ull) >> 24) |
- ((x & 0x00ff000000000000ull) >> 40) | ((x & 0xff00000000000000ull) >> 56);
-}
-
-#endif /* GR_HAVE_BYTESWAP */
-
-static inline uint64_t htonll(uint64_t x){ return bswap_64(x);}
-static inline uint64_t ntohll(uint64_t x){ return bswap_64(x);}
-
-#endif /* GR_ARCH_BIGENDIAN */
-#endif /* missing htonll or ntohll */
-
-#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 */
-// 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
-static inline uint16_t
-bswap_16 (uint16_t x)
-{
- return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
-}
-
-static inline uint32_t
-bswap_32 (uint32_t 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 */
-
-#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); }
-static inline uint64_t ntohx(uint64_t x){ return ntohll(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); }
-static inline uint64_t htonx(uint64_t x){ return htonll(x);}
-
-#endif /* INCLUDED_INET_H */
diff --git a/gruel/src/lib/pmt/pmt-serial-tags.scm b/gruel/src/lib/pmt/pmt-serial-tags.scm
index ca25a43a8..4f06bf75f 100644
--- a/gruel/src/lib/pmt/pmt-serial-tags.scm
+++ b/gruel/src/lib/pmt/pmt-serial-tags.scm
@@ -33,6 +33,8 @@
(define pst-dict #x09) ; untagged-int32 n; followed by n key/value tuples
(define pst-uniform-vector #x0a)
+(define pst-uint64 #x0b)
+(define pst-tuple #x0c)
;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
;;
diff --git a/gruel/src/lib/pmt/pmt_serialize.cc b/gruel/src/lib/pmt/pmt_serialize.cc
index de9644c3c..a19809a66 100644
--- a/gruel/src/lib/pmt/pmt_serialize.cc
+++ b/gruel/src/lib/pmt/pmt_serialize.cc
@@ -79,7 +79,6 @@ serialize_untagged_f64(double i, std::streambuf &sb)
}
-#if 0
// always writes big-endian
static bool
serialize_untagged_u64(uint64_t i, std::streambuf &sb)
@@ -93,7 +92,6 @@ serialize_untagged_u64(uint64_t i, std::streambuf &sb)
sb.sputc((i >> 8) & 0xff);
return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof();
}
-#endif
// ----------------------------------------------------------------
// input primitives
@@ -152,7 +150,6 @@ deserialize_untagged_u32(uint32_t *ip, std::streambuf &sb)
return t != std::streambuf::traits_type::eof();
}
-#if 0
// always reads big-endian
static bool
deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb)
@@ -181,7 +178,6 @@ deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb)
*ip = i;
return t != std::streambuf::traits_type::eof();
}
-#endif
static bool
deserialize_untagged_f64(double *ip, std::streambuf &sb)
@@ -217,6 +213,24 @@ deserialize_untagged_f64(double *ip, std::streambuf &sb)
return t != std::streambuf::traits_type::eof();
}
+static bool
+deserialize_tuple(pmt_t *tuple, std::streambuf &sb)
+{
+ uint32_t nitems;
+ bool ok = deserialize_untagged_u32(&nitems, sb);
+ pmt_t list(PMT_NIL);
+ for(uint32_t i=0; i<nitems; i++){
+ pmt_t item = pmt_deserialize( sb );
+ if(pmt_eq(list, PMT_NIL)){
+ list = pmt_list1(item);
+ } else {
+ list = pmt_list_add(list, item);
+ }
+ }
+ (*tuple) = pmt_to_tuple(list);
+ return ok;
+}
+
/*
* Write portable byte-serial representation of \p obj to \p sb
@@ -260,7 +274,13 @@ pmt_serialize(pmt_t obj, std::streambuf &sb)
}
if (pmt_is_number(obj)){
-
+
+ if (pmt_is_uint64(obj)){
+ uint64_t i = pmt_to_uint64(obj);
+ ok = serialize_untagged_u8(PST_UINT64, sb);
+ ok &= serialize_untagged_u64(i, sb);
+ return ok;
+ } else
if (pmt_is_integer(obj)){
long i = pmt_to_long(obj);
if (sizeof(long) > 4){
@@ -298,6 +318,16 @@ pmt_serialize(pmt_t obj, std::streambuf &sb)
if (pmt_is_dict(obj))
throw pmt_notimplemented("pmt_serialize (dict)", obj);
+ if (pmt_is_tuple(obj)){
+ size_t tuple_len = pmt::pmt_length(obj);
+ ok = serialize_untagged_u8(PST_TUPLE, sb);
+ ok &= serialize_untagged_u32(tuple_len, sb);
+ for(size_t i=0; i<tuple_len; i++){
+ ok &= pmt_serialize(pmt_tuple_ref(obj, i), sb);
+ }
+ return ok;
+ }
+ //throw pmt_notimplemented("pmt_serialize (tuple)", obj);
throw pmt_notimplemented("pmt_serialize (?)", obj);
}
@@ -315,7 +345,7 @@ pmt_deserialize(std::streambuf &sb)
//uint8_t u8;
uint16_t u16;
uint32_t u32;
- //uint32_t u64;
+ uint64_t u64;
double f64;
static char tmpbuf[1024];
@@ -347,6 +377,11 @@ pmt_deserialize(std::streambuf &sb)
goto error;
return pmt_from_long((int32_t) u32);
+ case PST_UINT64:
+ if(!deserialize_untagged_u64(&u64, sb))
+ goto error;
+ return pmt_from_uint64(u64);
+
case PST_PAIR:
return parse_pair(sb);
@@ -362,6 +397,15 @@ pmt_deserialize(std::streambuf &sb)
goto error;
return pmt_make_rectangular( r,i );
}
+
+ case PST_TUPLE:
+ {
+ pmt_t tuple;
+ if(!deserialize_tuple(&tuple, sb)){
+ goto error;
+ }
+ return tuple;
+ }
case PST_VECTOR:
case PST_DICT:
diff --git a/gruel/src/swig/CMakeLists.txt b/gruel/src/swig/CMakeLists.txt
index f9d1758ec..a0f84c832 100644
--- a/gruel/src/swig/CMakeLists.txt
+++ b/gruel/src/swig/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,7 +23,7 @@
include(GrPython)
include(GrSwig)
-set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS})
+set(GR_SWIG_INCLUDE_DIRS ${GRUEL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
set(GR_SWIG_LIBRARIES gruel)
set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i)