commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9107 - in gnuradio/branches/releases/3.1: . omnithrea


From: jcorgan
Subject: [Commit-gnuradio] r9107 - in gnuradio/branches/releases/3.1: . omnithread
Date: Thu, 31 Jul 2008 21:56:29 -0600 (MDT)

Author: jcorgan
Date: 2008-07-31 21:56:28 -0600 (Thu, 31 Jul 2008)
New Revision: 9107

Added:
   gnuradio/branches/releases/3.1/omnithread/omni_time.cc
   gnuradio/branches/releases/3.1/omnithread/omni_time.h
Modified:
   gnuradio/branches/releases/3.1/configure.ac
   gnuradio/branches/releases/3.1/omnithread/Makefile.am
Log:
Applied relevant portion of changeset r8624 on trunk to release branch.

Modified: gnuradio/branches/releases/3.1/configure.ac
===================================================================
--- gnuradio/branches/releases/3.1/configure.ac 2008-08-01 03:48:13 UTC (rev 
9106)
+++ gnuradio/branches/releases/3.1/configure.ac 2008-08-01 03:56:28 UTC (rev 
9107)
@@ -234,7 +234,7 @@
 )
 
 build_dirs="config"
-GRC_OMNITHREAD                 dnl must come before gnuradio-core and mblock
+GRC_OMNITHREAD                 dnl must come before gnuradio-core
 GRC_GNURADIO_CORE
 GRC_USRP
 GRC_GR_USRP                    dnl this must come after GRC_USRP

Modified: gnuradio/branches/releases/3.1/omnithread/Makefile.am
===================================================================
--- gnuradio/branches/releases/3.1/omnithread/Makefile.am       2008-08-01 
03:48:13 UTC (rev 9106)
+++ gnuradio/branches/releases/3.1/omnithread/Makefile.am       2008-08-01 
03:56:28 UTC (rev 9107)
@@ -37,11 +37,13 @@
 
 if OMNITHREAD_POSIX
 libgromnithread_la_SOURCES =           \
+       omni_time.cc \
        posix.cc
 endif
 
 if OMNITHREAD_NT
 libgromnithread_la_SOURCES =           \
+       omni_time.cc \
        nt.cc
 endif
 
@@ -67,6 +69,7 @@
 
 grinclude_HEADERS =                    \
        omnithread.h                    \
+       omni_time.h                     \
        ot_mach.h                       \
        ot_nt.h                         \
        ot_posix.h                      \

Copied: gnuradio/branches/releases/3.1/omnithread/omni_time.cc (from rev 8624, 
gnuradio/trunk/omnithread/omni_time.cc)
===================================================================
--- gnuradio/branches/releases/3.1/omnithread/omni_time.cc                      
        (rev 0)
+++ gnuradio/branches/releases/3.1/omnithread/omni_time.cc      2008-08-01 
03:56:28 UTC (rev 9107)
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <omni_time.h>
+#include <omnithread.h>
+#include <math.h>
+#include <assert.h>
+
+
+omni_time::omni_time(double real_secs)
+{
+  double floor_secs = floor(real_secs);
+  d_secs = (long) floor_secs;
+  d_nsecs = (long) ((real_secs - floor_secs) * 1e9);     // always positive
+}
+
+omni_time
+omni_time::time(const omni_time &delta_t)
+{
+  unsigned long        abs_sec, abs_nsec;
+  unsigned long rel_sec  = delta_t.d_secs;
+  unsigned long rel_nsec = delta_t.d_nsecs;
+  
+  omni_thread::get_time(&abs_sec, &abs_nsec, rel_sec, rel_nsec);
+  return omni_time(abs_sec, abs_nsec);
+}
+
+
+omni_time
+operator+(const omni_time &x, const omni_time &y)
+{
+  omni_time r(x.d_secs + y.d_secs, x.d_nsecs + y.d_nsecs);
+  while (r.d_nsecs >= 1000000000){
+    r.d_nsecs -= 1000000000;
+    r.d_secs++;
+  }
+  return r;
+}
+
+omni_time
+operator-(const omni_time &x, const omni_time &y)
+{
+  // assert(!(x < y));
+
+  omni_time r(x.d_secs - y.d_secs, x.d_nsecs - y.d_nsecs);
+  while (r.d_nsecs < 0){
+    r.d_nsecs += 1000000000;
+    r.d_secs--;
+  }
+  return r;
+}
+
+omni_time
+operator+(const omni_time &x, double y)
+{
+  return x + omni_time(y);
+}
+
+omni_time
+operator-(const omni_time &x, double y)
+{
+  return x - omni_time(y);
+}

Copied: gnuradio/branches/releases/3.1/omnithread/omni_time.h (from rev 8624, 
gnuradio/trunk/omnithread/omni_time.h)
===================================================================
--- gnuradio/branches/releases/3.1/omnithread/omni_time.h                       
        (rev 0)
+++ gnuradio/branches/releases/3.1/omnithread/omni_time.h       2008-08-01 
03:56:28 UTC (rev 9107)
@@ -0,0 +1,89 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_OMNI_TIME_H
+#define INCLUDED_OMNI_TIME_H
+
+struct omni_time {
+  long int d_secs;     // seconds.
+  long int d_nsecs;    // nanoseconds.  Always in [0, 1e9-1]
+
+  omni_time() : d_secs(0), d_nsecs(0) {}
+  omni_time(long secs, long nanosecs=0) : d_secs(secs), d_nsecs(nanosecs) {}
+
+  // N.B., this only makes sense for differences between times.
+  // Double doesn't have enough bits to precisely represent an absolute time.
+  omni_time(double secs);
+
+  // N.B. This only makes sense for differences between times.
+  // Double doesn't have enough bits to precisely represent an absolute time.
+  double double_time() const { return (double)d_secs + d_nsecs * 1e-9; }
+
+  /*!
+   * \brief Return an absolute time suitable for use with
+   * schedule_one_shot_timeout & schedule_periodic_timeout
+   *
+   * The return value is the current time plus the given relative offset.
+   */
+  static omni_time time(const omni_time &relative_offset = omni_time());
+};
+
+
+inline static bool
+operator<(const omni_time &x, const omni_time &y)
+{
+  return ((x.d_secs < y.d_secs)
+         || (x.d_secs == y.d_secs && x.d_nsecs < y.d_nsecs));
+}
+
+inline static bool
+operator>(const omni_time &x, const omni_time &y)
+{
+  return ((x.d_secs > y.d_secs)
+         || (x.d_secs == y.d_secs && x.d_nsecs > y.d_nsecs));
+}
+
+inline static bool
+operator>=(const omni_time &x, const omni_time &y)
+{
+  return ((x.d_secs > y.d_secs)
+         || (x.d_secs == y.d_secs && x.d_nsecs >= y.d_nsecs));
+}
+
+inline static bool
+operator<=(const omni_time &x, const omni_time &y)
+{
+  return ((x.d_secs < y.d_secs)
+         || (x.d_secs == y.d_secs && x.d_nsecs <= y.d_nsecs));
+}
+
+inline static bool
+operator==(const omni_time &x, const omni_time &y)
+{
+  return (x.d_secs == y.d_secs && x.d_nsecs == y.d_nsecs);
+}
+
+
+omni_time operator+(const omni_time &x, const omni_time &y);
+omni_time operator+(const omni_time &x, double y);
+omni_time operator-(const omni_time &x, const omni_time &y);
+omni_time operator-(const omni_time &x, double y);
+
+#endif /* INCLUDED_OMNI_TIME_H */





reply via email to

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