1 /*- 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)subr.c 1.2 (Berkeley) 06/29/90"; 10 #endif /* not lint */ 11 12 #include "ktrace.h" 13 #include <sys/time.h> 14 15 getpoints(s) 16 char *s; 17 { 18 int facs = 0; 19 20 while (*s) { 21 switch(*s) { 22 case 'c': 23 facs |= KTRFAC_SYSCALL | KTRFAC_SYSRET; 24 break; 25 case 'n': 26 facs |= KTRFAC_NAMEI; 27 break; 28 case 'i': 29 facs |= KTRFAC_GENIO; 30 break; 31 case 's': 32 facs |= KTRFAC_PSIG; 33 break; 34 default: 35 return (-1); 36 } 37 s++; 38 } 39 return (facs); 40 } 41 42 timevaladd(t1, t2) 43 struct timeval *t1, *t2; 44 { 45 46 t1->tv_sec += t2->tv_sec; 47 t1->tv_usec += t2->tv_usec; 48 timevalfix(t1); 49 } 50 51 timevalsub(t1, t2) 52 struct timeval *t1, *t2; 53 { 54 55 t1->tv_sec -= t2->tv_sec; 56 t1->tv_usec -= t2->tv_usec; 57 timevalfix(t1); 58 } 59 60 timevalfix(t1) 61 struct timeval *t1; 62 { 63 64 if (t1->tv_usec < 0) { 65 t1->tv_sec--; 66 t1->tv_usec += 1000000; 67 } 68 if (t1->tv_usec >= 1000000) { 69 t1->tv_sec++; 70 t1->tv_usec -= 1000000; 71 } 72 } 73