1 /* 2 * Copyright (c) 1994 William F. Jolitz. 3 * 386BSD Copyright Restrictions Apply. All Other Rights Reserved. 4 * 5 * $Id: addupc.c,v 1.1 94/10/19 18:33:12 bill Exp $ 6 * Talley time ticks against appropriate counter if profiling. 7 * family. 8 */ 9 10 #include "sys/param.h" 11 #include "sys/time.h" 12 #include "resourcevar.h" 13 14 void addupc(int pc,struct uprof * up,int ticks)15addupc(int pc, struct uprof *up, int ticks) 16 { 17 unsigned idx; 18 19 /* is pc in range? */ 20 pc -= up->pr_off; 21 if (pc < 0) 22 return; 23 24 /* scale pc to locate counter */ 25 idx = (pc >> 1) * up->pr_scale; 26 idx >>= 16; 27 28 /* is buffer long enough? */ 29 if (idx > up->pr_size) 30 return; 31 32 /* talley count */ 33 up->pr_base[idx] += ticks; 34 35 fault: 36 up->pr_scale = 0; 37 } 38 39