Skip to content

Commit

Permalink
Create ros-humble-rostime.win.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias-Fischer authored Feb 6, 2024
1 parent ec8267a commit 74e3b80
Showing 1 changed file with 179 additions and 0 deletions.
179 changes: 179 additions & 0 deletions patch/ros-humble-rostime.win.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
diff --git a/rostime/include/ros/duration.h b/rostime/include/ros/duration.h
index edd82dd..6a0e883 100644
--- a/rostime/include/ros/duration.h
+++ b/rostime/include/ros/duration.h
@@ -95,6 +95,7 @@ class DurationBase
T& fromNSec(int64_t t);
bool isZero() const;
boost::posix_time::time_duration toBoost() const;
+#ifndef _MSC_VER
static const T MIN; //!< Minimum representable duration (negative)
static const T MAX; //!< Maximum representable duration
static const T ZERO; //!< Zero duration
@@ -105,6 +106,7 @@ class DurationBase
static const T MILLISECOND; //!< One millisecond duration
static const T MICROSECOND; //!< One microsecond duration
static const T NANOSECOND; //!< One nanosecond duration
+#endif
};

class Rate;
@@ -136,6 +138,7 @@ class ROSTIME_DECL Duration : public DurationBase<Duration>

extern ROSTIME_DECL const Duration DURATION_MAX;
extern ROSTIME_DECL const Duration DURATION_MIN;
+#ifndef _MSC_VER
template<> const Duration DurationBase<Duration>::MAX;
template<> const Duration DurationBase<Duration>::MIN;
template<> const Duration DurationBase<Duration>::ZERO;
@@ -146,6 +149,7 @@ template<> const Duration DurationBase<Duration>::SECOND;
template<> const Duration DurationBase<Duration>::MILLISECOND;
template<> const Duration DurationBase<Duration>::MICROSECOND;
template<> const Duration DurationBase<Duration>::NANOSECOND;
+#endif

/**
* \brief Duration representation for use with the WallTime class.
@@ -172,6 +176,7 @@ class ROSTIME_DECL WallDuration : public DurationBase<WallDuration>
bool sleep() const;
};

+#ifndef _MSC_VER
template<> const WallDuration DurationBase<WallDuration>::MAX;
template<> const WallDuration DurationBase<WallDuration>::MIN;
template<> const WallDuration DurationBase<WallDuration>::ZERO;
@@ -182,6 +187,7 @@ template<> const WallDuration DurationBase<WallDuration>::SECOND;
template<> const WallDuration DurationBase<WallDuration>::MILLISECOND;
template<> const WallDuration DurationBase<WallDuration>::MICROSECOND;
template<> const WallDuration DurationBase<WallDuration>::NANOSECOND;
+#endif

ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Duration &rhs);
ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallDuration &rhs);
diff --git a/rostime/include/ros/time.h b/rostime/include/ros/time.h
index c4ff2fe..79f2eae 100644
--- a/rostime/include/ros/time.h
+++ b/rostime/include/ros/time.h
@@ -160,10 +160,12 @@ namespace ros
inline bool is_zero() const { return isZero(); }
boost::posix_time::ptime toBoost() const;

+#ifndef _MSC_VER
static const T MIN; //!< Minimum representable time
static const T MAX; //!< Maximum representable time
static const T ZERO; //!< Zero (invalid) time
static const T UNINITIALIZED; //!< Uninitialized time
+#endif
};

/**
@@ -221,10 +223,12 @@ namespace ros

extern ROSTIME_DECL const Time TIME_MAX;
extern ROSTIME_DECL const Time TIME_MIN;
+#ifndef _MSC_VER
template<> const Time TimeBase<Time, Duration>::MAX;
template<> const Time TimeBase<Time, Duration>::MIN;
template<> const Time TimeBase<Time, Duration>::ZERO;
template<> const Time TimeBase<Time, Duration>::UNINITIALIZED;
+#endif

/**
* \brief Time representation. Always wall-clock time.
@@ -258,11 +262,13 @@ namespace ros
static bool isSystemTime() { return true; }
};

+#ifndef _MSC_VER
template<> const WallTime TimeBase<WallTime, WallDuration>::MAX;
template<> const WallTime TimeBase<WallTime, WallDuration>::MIN;
template<> const WallTime TimeBase<WallTime, WallDuration>::ZERO;
template<> const WallTime TimeBase<WallTime, WallDuration>::UNINITIALIZED;
-
+#endif
+
/**
* \brief Time representation. Always steady-clock time.
*
@@ -297,10 +303,12 @@ namespace ros
static bool isSystemTime() { return true; }
};

+#ifndef _MSC_VER
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MAX;
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MIN;
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::ZERO;
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::UNINITIALIZED;
+#endif

ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Time &rhs);
ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallTime &rhs);
diff --git a/rostime/src/time.cpp b/rostime/src/time.cpp
index 7edb3cc..0bca1c4 100644
--- a/rostime/src/time.cpp
+++ b/rostime/src/time.cpp
@@ -83,6 +83,7 @@ namespace ros
const Duration DURATION_MAX(std::numeric_limits<int32_t>::max(), 999999999);
const Duration DURATION_MIN(std::numeric_limits<int32_t>::min(), 0);

+#ifndef _MSC_VER
template<> const Duration DurationBase<Duration>::MAX = DURATION_MAX;
template<> const Duration DurationBase<Duration>::MIN = DURATION_MIN;
template<> const Duration DurationBase<Duration>::ZERO = Duration(0, 0);
@@ -104,10 +105,12 @@ namespace ros
template<> const WallDuration DurationBase<WallDuration>::MILLISECOND = WallDuration(Duration::MILLISECOND.sec, Duration::MILLISECOND.nsec);
template<> const WallDuration DurationBase<WallDuration>::MICROSECOND = WallDuration(Duration::MICROSECOND.sec, Duration::MICROSECOND.nsec);
template<> const WallDuration DurationBase<WallDuration>::NANOSECOND = WallDuration(Duration::NANOSECOND.sec, Duration::NANOSECOND.nsec);
+#endif

const Time TIME_MAX(std::numeric_limits<uint32_t>::max(), 999999999);
const Time TIME_MIN(0, 1);

+#ifndef _MSC_VER
template<> const Time TimeBase<Time, Duration>::MAX = TIME_MAX;
template<> const Time TimeBase<Time, Duration>::MIN = TIME_MIN;
template<> const Time TimeBase<Time, Duration>::ZERO = Time(0, 0);
@@ -122,6 +125,7 @@ namespace ros
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MIN = SteadyTime(Time::MIN.sec, Time::MIN.nsec);
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::ZERO = SteadyTime(Time::ZERO.sec, Time::ZERO.nsec);
template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::UNINITIALIZED = SteadyTime(Time::UNINITIALIZED.sec, Time::UNINITIALIZED.nsec);
+#endif

// This is declared here because it's set from the Time class but read from
// the Duration class, and need not be exported to users of either.
diff --git a/rostime/test/time.cpp b/rostime/test/time.cpp
index 96ef161..e52a960 100644
--- a/rostime/test/time.cpp
+++ b/rostime/test/time.cpp
@@ -370,6 +370,7 @@ TEST(Time, OperatorPlusExceptions)
EXPECT_THROW(t5 + d3, std::runtime_error);
}

+#ifndef _MSC_VER
TEST(Time, Constants)
{
EXPECT_EQ(Time::MAX.sec, static_cast<uint32_t>(-1));
@@ -399,6 +400,7 @@ TEST(Time, Constants)
EXPECT_EQ(SteadyTime::UNINITIALIZED.sec, 0);
EXPECT_EQ(SteadyTime::UNINITIALIZED.nsec, 0);
}
+#endif

/************************************* Duration Tests *****************/

@@ -588,6 +590,7 @@ TEST(Duration, sleepWithSignal)
ASSERT_TRUE(rc);
}

+#ifndef _MSC_VER
TEST(Duration, Constants)
{
EXPECT_EQ(Duration::MAX.sec, std::numeric_limits<int32_t>::max());
@@ -632,6 +635,7 @@ TEST(Duration, Constants)
EXPECT_EQ(WallDuration::DAY.sec, 60 * 60 * 24);
EXPECT_EQ(WallDuration::DAY.nsec, 0);
}
+#endif

TEST(Rate, constructFromDuration){
Duration d(4, 0);

0 comments on commit 74e3b80

Please sign in to comment.