Skip to content

Commit

Permalink
[XrdCl] Use nanosleep with old gcc (fixes slc6 build).
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Apr 3, 2020
1 parent 09dbb4a commit 2ecf337
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/XrdCl/XrdClClassicCopyJob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "XrdCl/XrdClPostMaster.hh"
#include "XrdCl/XrdClJobManager.hh"
#include "XrdCl/XrdClXRootDTransport.hh"
#include "XrdClXCpCtx.hh"
#include "XrdSys/XrdSysE2T.hh"

#include <memory>
Expand All @@ -51,7 +52,10 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include "XrdClXCpCtx.hh"

#if __cplusplus < 201103L
#include <time.h>
#endif

namespace
{
Expand Down Expand Up @@ -1628,20 +1632,27 @@ inline std::chrono::nanoseconds time_nsec()
}

//------------------------------------------------------------------------------
// Sleep for # nanoseconds
// Convert seconds to nanoseconds
//------------------------------------------------------------------------------
inline void sleep_nsec( long long nsec )
inline long long to_nsec( long long sec )
{
using namespace std::chrono;
std::this_thread::sleep_for( nanoseconds( nsec ) );
return sec * 1000000000;
}

//------------------------------------------------------------------------------
// Convert seconds to nanoseconds
// Sleep for # nanoseconds
//------------------------------------------------------------------------------
inline long long to_nsec( long long sec )
inline void sleep_nsec( long long nsec )
{
return sec * 1000000000;
#if __cplusplus >= 201103L
using namespace std::chrono;
std::this_thread::sleep_for( nanoseconds( nsec ) );
#else
timespec req;
req.tv_sec = nsec / to_nsec( 1 );
req.tv_nsec = nsec % to_nsec( 1 );
nanosleep( &req, 0 );
#endif
}

namespace XrdCl
Expand Down

0 comments on commit 2ecf337

Please sign in to comment.