5 * Revision 1.2 1997/02/04 17:34:47 mclareni
6 * Merge Winnt and 97a versions
8 * Revision 1.1.1.1.2.1 1997/01/21 11:29:45 mclareni
9 * All mods for Winnt 96a on winnt branch
11 * Revision 1.1.1.1 1996/02/15 17:49:27 mclareni
15 #include "kerngen/pilot.h"
16 #if defined(CERNLIB_WINNT)
17 #include "wntgs/timel.c"
18 #elif defined(CERNLIB_QMDOS)
19 #include "dosgs/timel.c"
20 #elif defined(CERNLIB_QMIRTD)
21 #include "irtdgs/timel.c"
24 CERN PROGLIB# Z007 TIMEST .VERSION KERNFOR 4.39 940228
25 ORIG. 01/03/85 FCA, mod 03/11/93 GF
27 #include <sys/types.h>
29 #include <sys/times.h>
30 #include <sys/param.h>
32 #include <sys/resource.h>
34 #ifndef CLOCKS_PER_SEC
35 #define CLOCKS_PER_SEC CLK_TCK
40 #define RLIMIT_CPU 0 /* For HP-UX... */
43 #define RLIM_INFINITY 0x7fffffff /* For HP-UX... */
46 #if defined(CERNLIB_QSYSBSD)||defined(CERNLIB_QMVMI)||defined(CERNLIB_QMVAOS)
54 #define HZ 1./CLOCKS_PER_SEC
60 static time_t timstart, timlast;
61 static int tml_init = 1;
64 #if defined(CERNLIB_QX_SC)
65 #define timest timest_
70 #if defined(CERNLIB_QXCAPT)
77 /* local routine called by timst, and time_init */
78 static void time_st(timl)
83 timstart = tps.tms_utime+tps.tms_cutime+tps.tms_stime+tps.tms_cstime;
88 /* local routine to start by default */
89 static void time_init()
96 if (getrlimit(RLIMIT_CPU, &rlimit)==0) {
97 if ( rlimit.rlim_cur != RLIM_INFINITY )
98 maxtime = (float) rlimit.rlim_cur;
108 struct rlimit rlimit;
113 /* get maximum time allowed by system, and do not allow more */
115 if (getrlimit(RLIMIT_CPU, &rlimit)==0) {
116 maxtime = (float) rlimit.rlim_cur;
117 maxtime = ( maxtime > *timl ) ? *timl : maxtime;
126 CERN PROGLIB# Z007 TIMEX .VERSION KERNFOR 4.39 940228
138 timnow = tps.tms_utime+tps.tms_cutime+tps.tms_stime+tps.tms_cstime;
139 *tx = (float) (timnow - timstart) / HZ;
147 CERN PROGLIB# Z007 TIMED .VERSION KERNFOR 4.39 940228
159 timnow = tps.tms_utime+tps.tms_cutime+tps.tms_stime+tps.tms_cstime;
160 *td = (float) (timnow - timlast) / HZ;
169 CERN PROGLIB# Z007 TIMEL .VERSION KERNFOR 4.39 940228
181 timnow = tps.tms_utime+tps.tms_cutime+tps.tms_stime+tps.tms_cstime;
182 *tl = timlim - (float) (timnow - timstart) / HZ;
189 /*> END <----------------------------------------------------------*/