Skip to content

Commit

Permalink
Add ROSTIME_DECL storage-class attribute (#90)
Browse files Browse the repository at this point in the history
* Add ROSTIME_DECL storage-class attribute

* Fix build issue on Windows, signal/alarm not available on Windows
  • Loading branch information
johnsonshih authored and dirk-thomas committed Aug 3, 2018
1 parent d2bb8cb commit 11db0ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rostime/include/ros/duration.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class ROSTIME_DECL WallDuration : public DurationBase<WallDuration>
bool sleep() const;
};

std::ostream &operator <<(std::ostream &os, const Duration &rhs);
std::ostream &operator <<(std::ostream &os, const WallDuration &rhs);
ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Duration &rhs);
ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallDuration &rhs);


}
Expand Down
9 changes: 9 additions & 0 deletions rostime/test/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include <gtest/gtest.h>
#include <ros/rate.h>
#include <ros/time.h>
#ifndef _WIN32
#include <sys/time.h>
#endif

#include <boost/date_time/posix_time/ptime.hpp>

Expand All @@ -45,9 +47,13 @@ double epsilon = 1e-9;
void seed_rand()
{
//Seed random number generator with current microseond count
#ifndef _WIN32
timeval temp_time_struct;
gettimeofday(&temp_time_struct,NULL);
srand(temp_time_struct.tv_usec);
#else
srand(time(nullptr));
#endif
};

void generate_rand_times(uint32_t range, uint64_t runs, std::vector<ros::Time>& values1, std::vector<ros::Time>& values2)
Expand Down Expand Up @@ -509,8 +515,11 @@ void alarmHandler(int sig)

TEST(Duration, sleepWithSignal)
{
#ifndef _WIN32
signal(SIGALRM, alarmHandler);
alarm(1);
#endif

Time start = Time::now();
Duration d(2.0);
bool rc = d.sleep();
Expand Down

0 comments on commit 11db0ec

Please sign in to comment.