Commit 89be2b7c authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed useless checks for sys/resource.h and sys/ioctl.h

They are part of POSIX so they should work on anything but Windows. This
can be checked simply by a predefined macro, configuration during build
is not necessary. See https://stackoverflow.com/a/4575466 for reference.
parent 17a72aeb
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -309,33 +309,6 @@ if( ${WITH_GMP} )
   endif()
endif()

####
# Check for some system header
#
find_path( SYS_RESOURCE_INCLUDE_DIR sys/resource.h
           /usr/include/x86_64-linux-gnu
           /usr/include  
           DOC "System resources headers." )
if( ${SYS_RESOURCE_INCLUDE_DIR} STREQUAL "SYS_RESOURCE_INCLUDE_DIR-NOTFOUND" )
    message( "Missing header file sys/time.h" )
    set( HAVE_SYS_RESOURCE_H "//#define HAVE_SYS_RESOURCE_H 1" )
else()
    #include_directories( ${SYS_RESOURCE_INCLUDE_DIR} )
    set( HAVE_SYS_RESOURCE_H "#define HAVE_SYS_RESOURCE_H 1" )
endif()

find_path( SYS_IOCTL_INCLUDE_DIR sys/ioctl.h
           /usr/include/x86_64-linux-gnu
           /usr/include  
           DOC "System ioctl headers." )
if( ${SYS_IOCTL_INCLUDE_DIR} STREQUAL "SYS_IOCTL_INCLUDE_DIR-NOTFOUND" )
    message( "Missing header file sys/time.h" )
    set( HAVE_SYS_IOCTL_H "//#define HAVE_SYS_IOCTL_H 1" )
else()
    #include_directories( ${SYS_IOCTL_INCLUDE_DIR} )
    set( HAVE_SYS_IOCTL_H "#define HAVE_SYS_IOCTL_H 1" )
endif()

if( ${WITH_TESTS} )
   enable_testing()

+6 −6
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@
#include <iomanip>
#include <limits>

// make sure to include the config before the check
#include <TNL/tnlConfig.h>
#ifdef HAVE_SYS_IOCTL_H
// check if we are on a POSIX system or Windows,
// see https://stackoverflow.com/a/4575466
#if !defined(_WIN32) && !defined(_WIN64)
   #include <sys/ioctl.h>
   #include <unistd.h>
#endif
@@ -190,7 +190,7 @@ void IterativeSolverMonitor< Real, Index > :: refresh()
template< typename Real, typename Index>
int IterativeSolverMonitor< Real, Index > :: getLineWidth()
{
#ifdef HAVE_SYS_IOCTL_H
#if !defined(_WIN32) && !defined(_WIN64)
   struct winsize w;
   ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
   return w.ws_col;
+4 −3
Original line number Diff line number Diff line
@@ -11,8 +11,9 @@
#include <TNL/Timer.h>
#include <TNL/Logger.h>

#include <TNL/tnlConfig.h>
#ifdef HAVE_SYS_RESOURCE_H
// check if we are on a POSIX system or Windows,
// see https://stackoverflow.com/a/4575466
#if !defined(_WIN32) && !defined(_WIN64)
   #include <sys/resource.h>
#endif

@@ -84,7 +85,7 @@ typename Timer::TimePoint Timer::readRealTime() const

double Timer::readCPUTime() const
{
#ifdef HAVE_SYS_RESOURCE_H
#if !defined(_WIN32) && !defined(_WIN64)
   rusage initUsage;
   getrusage( RUSAGE_SELF, &initUsage );
   return initUsage. ru_utime. tv_sec + 1.0e-6 * ( double ) initUsage. ru_utime. tv_usec;
+0 −4
Original line number Diff line number Diff line
@HAVE_SYS_RESOURCE_H@

@HAVE_SYS_IOCTL_H@

@HAVE_DCMTK_H@

@HAVE_PNG_H@