Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/runtime/Kernel/timeUnix.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <stdlib.h>
#include <stdio.h>
#ifdef __hppa__
#define _POSIX_SOURCE
#endif
#include <sys/types.h>
#include <sys/times.h>

#include "runtime.h"

void timerClear(timer *t)
{
  t->l = 0;
  t->h = 0;
}

void timerRead(timer *t)
{
  struct tms buffer;
  if(times(&buffer)==(clock_t)-1) {
    fprintf(stderr,"times failed.");
    exit(-1);
  }
  t->l = (unsigned int)buffer.tms_utime;
  t->h = 0;
}
    
void timerStart(timer *t)
{
  timer t2;
  timerRead(&t2);
  t->l -= t2.l;
}

void timerStop(timer *t)
{
  timer t2;
  timerRead(&t2);
  t->l += t2.l;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.