cpu_time.cpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Includes
00010 *****************************************************************************/
00011 
00012 #include "../../include/ecl/time_lite/cpu_time.hpp"
00013 #include <errno.h>
00014 
00015 /*****************************************************************************
00016 ** Namespaces
00017 *****************************************************************************/
00018 
00019 namespace ecl {
00020 
00021 #ifdef ECL_HAS_CPUTIME
00022 TimeError cpu_time(TimeStructure &time) {
00023         // On the man page, it says that this function should need _POSIX_CPUTIME
00024         // defined, but in practice I'm a bit unusre about this. On one system,
00025         // I've had _POSIX_CPUTIME defined to 0, but this function would still work.
00026         // Just assuming that you need clock_gettime for now.
00027         int result = clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&time);
00028         switch (result) {
00029                 case(0) : { return TimeError(NoError); }
00030                 case(EFAULT) : { return TimeError(MemoryError); }          // time was not in addressable memory space
00031                 case(EINVAL) : { return TimeError(ArgNotSupportedError); } // clock id is not supported (actually impossible if cmake detects)
00032                 case(EPERM) : { return TimeError(PermissionsError); }      // user does not have permissions to use the clock.
00033                 default : { return TimeError(UnknownError); }
00034         }
00035 }
00036 #endif
00037 
00038 } // namespace ecl


ecl_time_lite
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 18:53:26