Back to index

glibc  2.9
Functions | Variables
times.c File Reference
#include <errno.h>
#include <stddef.h>
#include <sys/resource.h>
#include <sys/times.h>
#include <sys/time.h>
#include <time.h>

Go to the source code of this file.


static clock_t timeval_to_clock_t (const struct timeval *tv, clock_t clk_tck)
clock_t __times (struct tms *buffer)


time_t _posix_start_time

Function Documentation

clock_t __times ( struct tms buffer)

Definition at line 45 of file times.c.

  struct rusage usage;
  clock_t clk_tck;

  if (buffer == NULL)
      __set_errno (EINVAL);
      return (clock_t) -1;

  clk_tck = __getclktck ();
  if (__getrusage (RUSAGE_SELF, &usage) < 0)
    return (clock_t) -1;
  buffer->tms_utime = (clock_t) timeval_to_clock_t (&usage.ru_utime, clk_tck);
  buffer->tms_stime = (clock_t) timeval_to_clock_t (&usage.ru_stime, clk_tck);

  if (__getrusage (RUSAGE_CHILDREN, &usage) < 0)
    return (clock_t) -1;
  buffer->tms_cutime = (clock_t) timeval_to_clock_t (&usage.ru_utime, clk_tck);
  buffer->tms_cstime = (clock_t) timeval_to_clock_t (&usage.ru_stime, clk_tck);

  return (time ((time_t *) NULL) - _posix_start_time) * clk_tck;

Here is the call graph for this function:

static clock_t timeval_to_clock_t ( const struct timeval tv,
clock_t  clk_tck 
) [static]

Definition at line 34 of file times.c.

  return (clock_t) ((tv->tv_sec * clk_tck) +
                  (tv->tv_usec * clk_tck / 1000000L));

Here is the caller graph for this function:

Variable Documentation

Definition at line 25 of file init-posix.c.