aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alkondratenko@gmail.com>2016-03-12 10:54:05 -0800
committerAliaksey Kandratsenka <alkondratenko@gmail.com>2016-03-12 10:55:42 -0800
commit6682016092c735feb29021acbb8c2067fdf1a209 (patch)
treeb2ad4bb79104dcd6bcd81546b09fdbed4e810c9f
parent6ff86ff6a783a277956e45db68c6a2b729f27000 (diff)
downloadgperftools-6682016092c735feb29021acbb8c2067fdf1a209.tar.gz
Unbreak profiling with CPUPROFILE_FREQUENCY=1
This closes ticket #777. No test sadly, since it's not trivial to unittest this case. But fix with single-shot manual testing is better than nothing.
-rw-r--r--src/profile-handler.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/profile-handler.cc b/src/profile-handler.cc
index db97345..7fdcb69 100644
--- a/src/profile-handler.cc
+++ b/src/profile-handler.cc
@@ -492,8 +492,10 @@ void ProfileHandler::UpdateTimer(bool enable) {
timer_running_ = enable;
struct itimerval timer;
- timer.it_interval.tv_sec = 0;
- timer.it_interval.tv_usec = (enable ? (1000000 / frequency_) : 0);
+ static const int kMillion = 1000000;
+ int interval_usec = enable ? kMillion / frequency_ : 0;
+ timer.it_interval.tv_sec = interval_usec / kMillion;
+ timer.it_interval.tv_usec = interval_usec % kMillion;
timer.it_value = timer.it_interval;
setitimer(timer_type_, &timer, 0);
}