blob: 1164b51fa5e027c87c11863eef26b430f26868ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#include <stdio.h>
#include <sys/types.h>
#ifndef SYSV
#include <sys/timeb.h>
#endif
#include <sys/times.h>
#include <sys/time.h>
#include <time.h>
#define import_kernel
#define import_knames
#define import_spp
#include <iraf.h>
/* ZGTIME -- Get the local standard (clock) time, in units of seconds
* since 00:00:00 01-Jan-80. Return the total cpu time consumed by the
* process (and any subprocesses), in units of milliseconds.
*/
int
ZGTIME (
XLONG *clock_time, /* seconds */
XLONG *cpu_time /* milliseconds */
)
{
struct tms t;
#ifdef BSD
time_t time();
#else
long time();
#endif
time_t gmt_to_lst();
long cpu, clkfreq;
#ifdef LINUX
clkfreq = CLOCKS_PER_SEC;
#else
#ifdef MACOSX
clkfreq = CLOCKS_PER_SEC;
#else
clkfreq = CLKFREQ; /* from <kernel.h> */
#endif
#endif
times (&t);
*clock_time = gmt_to_lst ((time_t)time(0));
/* We don't want any floating point in the kernel code so do the
* following computation using integer arithment, taking care to
* avoid integer overflow (unless unavoidable) or loss of precision.
*/
cpu = (t.tms_utime + t.tms_cutime);
if (cpu > MAX_LONG/1000)
/* *cpu_time = cpu / clkfreq * 1000;*/
*cpu_time = cpu / 10;
else
/* *cpu_time = cpu * 1000 / clkfreq;*/
*cpu_time = cpu * 10;
return (XOK);
}
|