From b415cf63563d2078df25a0e5224d2f35b8bffe1f Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 14 Oct 2012 22:36:51 +0000 Subject: [PATCH] Take over 26990 from branch_cmake as well. git-svn-id: https://svn.dealii.org/trunk@27125 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/base/logstream.cc | 16 +++------------- deal.II/source/base/thread_management.cc | 13 +++++++------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/deal.II/source/base/logstream.cc b/deal.II/source/base/logstream.cc index 312c3e03ca..9d6c83d3d6 100644 --- a/deal.II/source/base/logstream.cc +++ b/deal.II/source/base/logstream.cc @@ -31,16 +31,6 @@ #include -// on SunOS 4.x, getrusage is stated in the man pages and exists, but -// is not declared in resource.h. declare it ourselves -#ifdef NO_HAVE_GETRUSAGE -extern "C" { - int getrusage(int who, struct rusage* ru); -} -#endif - -// When modifying the prefix list, we need to lock it just in case -// another thread tries to do the same. DEAL_II_NAMESPACE_OPEN namespace @@ -63,7 +53,7 @@ LogStream::LogStream() { prefixes.push("DEAL:"); std_out->setf(std::ios::showpoint | std::ios::left); -#ifdef HAVE_TIMES +#if defined(HAVE_UNISTD_H) && defined(HAVE_TIMES) reference_time_val = 1./sysconf(_SC_CLK_TCK) * times(&reference_tms); #endif } @@ -371,7 +361,7 @@ LogStream::log_thread_id (const bool flag) void LogStream::print_line_head() { -#ifndef DEAL_II_MSVC +#ifdef HAVE_SYS_RESOURCE_H rusage usage; double utime = 0.; if (print_utime) @@ -464,7 +454,7 @@ void LogStream::timestamp () { struct tms current_tms; -#ifdef HAVE_TIMES +#if defined(HAVE_UNISTD_H) && defined(HAVE_TIMES) const clock_t tick = sysconf(_SC_CLK_TCK); const double time = 1./tick * times(¤t_tms); #else diff --git a/deal.II/source/base/thread_management.cc b/deal.II/source/base/thread_management.cc index 15891599f6..fd83cf10fc 100644 --- a/deal.II/source/base/thread_management.cc +++ b/deal.II/source/base/thread_management.cc @@ -19,6 +19,10 @@ #include #include +#ifdef HAVE_UNISTD_H +# include +#endif + DEAL_II_NAMESPACE_OPEN @@ -131,16 +135,13 @@ namespace Threads unsigned int this_thread_id () { #ifdef SYS_gettid - const int this_id = syscall(SYS_gettid); -#elif HAVE_GETPID + const pid_t this_id = syscall(SYS_gettid); +#elif defined(HAVE_UNISTD_H) && defined(HAVE_GETPID) const pid_t this_id = getpid(); #else -# ifdef DEAL_II_MSVC const unsigned int this_id = 0; -# else - const pid_t this_id = 0; -# endif #endif + return static_cast(this_id); } -- 2.39.5