Deleted Added
full compact
subr_prof.c (81493) subr_prof.c (82717)
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
34 * $FreeBSD: head/sys/kern/subr_prof.c 81493 2001-08-10 22:53:32Z jhb $
34 * $FreeBSD: head/sys/kern/subr_prof.c 82717 2001-09-01 05:47:58Z dillon $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>

--- 303 unchanged lines hidden (view full) ---

346#ifndef _SYS_SYSPROTO_H_
347struct profil_args {
348 caddr_t samples;
349 size_t size;
350 size_t offset;
351 u_int scale;
352};
353#endif
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>

--- 303 unchanged lines hidden (view full) ---

346#ifndef _SYS_SYSPROTO_H_
347struct profil_args {
348 caddr_t samples;
349 size_t size;
350 size_t offset;
351 u_int scale;
352};
353#endif
354/*
355 * MPSAFE
356 */
354/* ARGSUSED */
355int
356profil(p, uap)
357 struct proc *p;
358 register struct profil_args *uap;
359{
360 register struct uprof *upp;
361 int s;
357/* ARGSUSED */
358int
359profil(p, uap)
360 struct proc *p;
361 register struct profil_args *uap;
362{
363 register struct uprof *upp;
364 int s;
365 int error = 0;
362
366
363 if (uap->scale > (1 << 16))
364 return (EINVAL);
367 mtx_lock(&Giant);
368
369 if (uap->scale > (1 << 16)) {
370 error = EINVAL;
371 goto done2;
372 }
365 if (uap->scale == 0) {
366 stopprofclock(p);
373 if (uap->scale == 0) {
374 stopprofclock(p);
367 return (0);
375 goto done2;
368 }
369 upp = &p->p_stats->p_prof;
370
371 /* Block profile interrupts while changing state. */
372 s = splstatclock();
373 upp->pr_off = uap->offset;
374 upp->pr_scale = uap->scale;
375 upp->pr_base = uap->samples;
376 upp->pr_size = uap->size;
377 startprofclock(p);
378 splx(s);
379
376 }
377 upp = &p->p_stats->p_prof;
378
379 /* Block profile interrupts while changing state. */
380 s = splstatclock();
381 upp->pr_off = uap->offset;
382 upp->pr_scale = uap->scale;
383 upp->pr_base = uap->samples;
384 upp->pr_size = uap->size;
385 startprofclock(p);
386 splx(s);
387
380 return (0);
388done2:
389 mtx_unlock(&Giant);
390 return (error);
381}
382
383/*
384 * Scale is a fixed-point number with the binary point 16 bits
385 * into the value, and is <= 1.0. pc is at most 32 bits, so the
386 * intermediate result is at most 48 bits.
387 */
388#define PC_TO_INDEX(pc, prof) \

--- 76 unchanged lines hidden ---
391}
392
393/*
394 * Scale is a fixed-point number with the binary point 16 bits
395 * into the value, and is <= 1.0. pc is at most 32 bits, so the
396 * intermediate result is at most 48 bits.
397 */
398#define PC_TO_INDEX(pc, prof) \

--- 76 unchanged lines hidden ---