From a322b3d7b9bf9f41192ee757fa78f55816da9a71 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Wed, 11 Apr 2018 10:43:18 -0500 Subject: Handle overruns in nanosleep The nanosleep takes seconds and nanoseconds as parameters but it doesn't currently enforce that nsec doesn't exceed a sec. The change here is to handle any overlaps to get the desired results. Change-Id: Ic9f32c3164499af5d5ee888aaad4a1beee8ed625 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/57075 CI-Ready: Daniel M. Crowell Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Martin Gloff Reviewed-by: Christian R. Geddes Reviewed-by: William G. Hoffa --- src/lib/syscall_time.C | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/syscall_time.C b/src/lib/syscall_time.C index 75bc0e312..6b34c1b60 100644 --- a/src/lib/syscall_time.C +++ b/src/lib/syscall_time.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2010,2014 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -25,15 +27,19 @@ #include #include #include +#include +#include using namespace Systemcalls; -void nanosleep(uint64_t sec, uint64_t nsec) +void nanosleep(uint64_t i_sec, uint64_t i_nsec) { + uint64_t l_sec = i_sec + i_nsec/NS_PER_SEC; + uint64_t l_nsec = i_nsec%NS_PER_SEC; // If the delay is short then simpleDelay() will perform the delay - if(unlikely(!TimeManager::simpleDelay(sec, nsec))) + if(unlikely(!TimeManager::simpleDelay(l_sec, l_nsec))) { - _syscall2(TIME_NANOSLEEP, (void*)sec, (void*)nsec); + _syscall2(TIME_NANOSLEEP, (void*)l_sec, (void*)l_nsec); } } -- cgit v1.2.1