From: Wolfgang Bangerth Date: Sun, 14 Oct 2012 22:36:51 +0000 (+0000) Subject: Take over 26990 from branch_cmake as well. X-Git-Tag: v8.0.0~1944 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b96d07718a4eca92372ba039cb7b9e06467096b4;p=dealii.git Take over 26990 from branch_cmake as well. git-svn-id: https://svn.dealii.org/trunk@27125 0785d39b-7218-0410-832d-ea1e28bc413d --- 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); }