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 5.2 (Berkeley) 04/15/92"; 10 #endif /* not lint */ 11 12 #include <sys/param.h> 13 #include <sys/file.h> 14 #include <sys/user.h> 15 #include <sys/proc.h> 16 #include <sys/time.h> 17 #include <sys/ktrace.h> 18 #include <stdio.h> 19 #include "ktrace.h" 20 21 getpoints(s) 22 char *s; 23 { 24 int facs = 0; 25 26 while (*s) { 27 switch(*s) { 28 case 'c': 29 facs |= KTRFAC_SYSCALL | KTRFAC_SYSRET; 30 break; 31 case 'n': 32 facs |= KTRFAC_NAMEI; 33 break; 34 case 'i': 35 facs |= KTRFAC_GENIO; 36 break; 37 case 's': 38 facs |= KTRFAC_PSIG; 39 break; 40 case 'w': 41 facs |= KTRFAC_CSW; 42 break; 43 case '+': 44 facs |= DEF_POINTS; 45 break; 46 default: 47 return (-1); 48 } 49 s++; 50 } 51 return (facs); 52 } 53 54 timevaladd(t1, t2) 55 struct timeval *t1, *t2; 56 { 57 t1->tv_sec += t2->tv_sec; 58 t1->tv_usec += t2->tv_usec; 59 timevalfix(t1); 60 } 61 62 timevalsub(t1, t2) 63 struct timeval *t1, *t2; 64 { 65 t1->tv_sec -= t2->tv_sec; 66 t1->tv_usec -= t2->tv_usec; 67 timevalfix(t1); 68 } 69 70 timevalfix(t1) 71 struct timeval *t1; 72 { 73 if (t1->tv_usec < 0) { 74 t1->tv_sec--; 75 t1->tv_usec += 1000000; 76 } 77 if (t1->tv_usec >= 1000000) { 78 t1->tv_sec++; 79 t1->tv_usec -= 1000000; 80 } 81 } 82