/* iclock.c $Revision: 4.1.0 Patch(4.1): 61 $
/**********************************************************************/
/*                                                                    */
/*    Extract the CPU-time used by the current process                */
/*                                                                    */
/*    Note:                                                           */
/*    This is a replacement for the corresponding routines            */
/*    available on IBM and SGI computers                              */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*                                                                    */
/*    written by:                                                     */
/*    M.P. Fuelscher                                                  */
/*    University of Lund, Sweden, 1994                                */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*                                                                    */
/*    history: none                                                   */
/*                                                                    */
/*--------------------------------------------------------------------*/
#include <sys/types.h>
#include <sys/times.h>
#include </usr/include/timebits.h>
#include <sys/resource.h>
#include <unistd.h>

#ifndef SUN
#ifndef RS6K
#ifndef HPUX
#ifdef CRAY
#include <time.h>
#define iclock ICLOCK
#else
#define iclock iclock_
#endif
#endif
#endif

#ifdef DECAXP
#define INT long int
#else
#ifdef IRIX64
#define INT long int
#define RUSAGE_SELF      0
#else
#define INT long int
#endif
#endif

INT iclock()

#ifdef CRAY
{

  struct tms buf;
  INT rc;
  INT cpu;
  INT ticks;

  rc=times(&buf);
  cpu=(buf.tms_utime)/CLK_TCK;

  return(cpu);
}
#else
#ifdef LINUX
{

  struct tms buf;
  INT rc;
  INT cpu;
  INT ticks;

  rc=times(&buf);
  cpu=(buf.tms_utime)/CLK_TCK;

  return(cpu);
}
#else
{

  extern getrusage();
  struct rusage RU;
  INT rc;
  INT cpu;
  INT ticks;

  rc=getrusage(RUSAGE_SELF,&RU);
  cpu=RU.ru_utime.tv_sec;

  return(cpu);
}
#endif
#endif
#else
#include <sys/time.h>
#define iclock iclock_
#define INT int

int iclock()

{
  struct tms buf;
  INT rc;
  INT cpu;
  INT ticks;

  rc=times(&buf);
  cpu=buf.tms_utime/100;

  return(cpu);
}
#endif

