Cleaned up interrupt masking by declaring the state variable in a

machine-dependent macro and passing it to all machine-dependent
macros.

Eliminated the state variable for the GUPROF case.
This commit is contained in:
Bruce Evans 1996-08-28 20:15:32 +00:00
parent 710376c933
commit 1f403fcfbf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17879
4 changed files with 40 additions and 32 deletions

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id: mcount.c,v 1.5 1995/12/30 07:01:50 bde Exp $";
"$Id: mcount.c,v 1.6 1996/05/02 08:43:37 phk Exp $";
#endif
#include <sys/param.h>
@ -79,8 +79,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
register struct gmonparam *p;
register long toindex;
#ifdef KERNEL
register int s; /* XXX */
u_long save_eflags; /* XXX */
MCOUNT_DECL(s)
#endif
p = &_gmonparam;
@ -93,7 +92,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
return;
#endif
#ifdef KERNEL
MCOUNT_ENTER;
MCOUNT_ENTER(s);
#else
p->state = GMON_PROF_BUSY;
#endif
@ -261,7 +260,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
}
done:
#ifdef KERNEL
MCOUNT_EXIT;
MCOUNT_EXIT(s);
#else
p->state = GMON_PROF_ON;
#endif
@ -269,7 +268,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
overflow:
p->state = GMON_PROF_ERROR;
#ifdef KERNEL
MCOUNT_EXIT;
MCOUNT_EXIT(s);
#endif
return;
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)profile.h 8.1 (Berkeley) 6/11/93
* $Id: profile.h,v 1.5 1995/12/29 15:28:54 bde Exp $
* $Id: profile.h,v 1.6 1996/01/01 17:11:21 bde Exp $
*/
#ifndef _MACHINE_PROFILE_H_
@ -46,6 +46,20 @@
#define _MCOUNT_DECL void mcount
#define MCOUNT
#ifdef GUPROF
#define CALIB_SCALE 1000
#define KCOUNT(p,index) ((p)->kcount[(index) \
/ (HISTFRACTION * sizeof(*(p)->kcount))])
#define MCOUNT_DECL(s)
#define MCOUNT_ENTER(s)
#define MCOUNT_EXIT(s)
#define PC_TO_I(p, pc) ((fptrint_t)(pc) - (fptrint_t)(p)->lowpc)
#else
#define MCOUNT_DECL(s) u_long s;
#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); }
#define MCOUNT_EXIT(s) (write_eflags(s))
#endif /* GUPROF */
#else /* !KERNEL */
#define _MCOUNT_DECL static __inline void _mcount
@ -74,15 +88,6 @@ mcount() \
}
#endif /* KERNEL */
#ifdef KERNEL
#define CALIB_SCALE 1000
#define KCOUNT(p,index) ((p)->kcount[(index) \
/ (HISTFRACTION * sizeof(*(p)->kcount))])
#define MCOUNT_ENTER { save_eflags = read_eflags(); disable_intr(); }
#define MCOUNT_EXIT (write_eflags(save_eflags))
#define PC_TO_I(p, pc) ((fptrint_t)(pc) - (fptrint_t)(p)->lowpc)
#endif
/* An unsigned integral type that can hold function pointers. */
typedef u_int fptrint_t;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)profile.h 8.1 (Berkeley) 6/11/93
* $Id: profile.h,v 1.5 1995/12/29 15:28:54 bde Exp $
* $Id: profile.h,v 1.6 1996/01/01 17:11:21 bde Exp $
*/
#ifndef _MACHINE_PROFILE_H_
@ -46,6 +46,20 @@
#define _MCOUNT_DECL void mcount
#define MCOUNT
#ifdef GUPROF
#define CALIB_SCALE 1000
#define KCOUNT(p,index) ((p)->kcount[(index) \
/ (HISTFRACTION * sizeof(*(p)->kcount))])
#define MCOUNT_DECL(s)
#define MCOUNT_ENTER(s)
#define MCOUNT_EXIT(s)
#define PC_TO_I(p, pc) ((fptrint_t)(pc) - (fptrint_t)(p)->lowpc)
#else
#define MCOUNT_DECL(s) u_long s;
#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); }
#define MCOUNT_EXIT(s) (write_eflags(s))
#endif /* GUPROF */
#else /* !KERNEL */
#define _MCOUNT_DECL static __inline void _mcount
@ -74,15 +88,6 @@ mcount() \
}
#endif /* KERNEL */
#ifdef KERNEL
#define CALIB_SCALE 1000
#define KCOUNT(p,index) ((p)->kcount[(index) \
/ (HISTFRACTION * sizeof(*(p)->kcount))])
#define MCOUNT_ENTER { save_eflags = read_eflags(); disable_intr(); }
#define MCOUNT_EXIT (write_eflags(save_eflags))
#define PC_TO_I(p, pc) ((fptrint_t)(pc) - (fptrint_t)(p)->lowpc)
#endif
/* An unsigned integral type that can hold function pointers. */
typedef u_int fptrint_t;

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id: mcount.c,v 1.6 1995/12/30 07:24:13 bde Exp $";
"$Id: mcount.c,v 1.7 1996/05/02 14:20:33 phk Exp $";
#endif
#include <sys/param.h>
@ -79,8 +79,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
register struct gmonparam *p;
register long toindex;
#ifdef KERNEL
register int s; /* XXX */
u_long save_eflags; /* XXX */
MCOUNT_DECL(s)
#endif
p = &_gmonparam;
@ -93,7 +92,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
return;
#endif
#ifdef KERNEL
MCOUNT_ENTER;
MCOUNT_ENTER(s);
#else
p->state = GMON_PROF_BUSY;
#endif
@ -261,7 +260,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
}
done:
#ifdef KERNEL
MCOUNT_EXIT;
MCOUNT_EXIT(s);
#else
p->state = GMON_PROF_ON;
#endif
@ -269,7 +268,7 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
overflow:
p->state = GMON_PROF_ERROR;
#ifdef KERNEL
MCOUNT_EXIT;
MCOUNT_EXIT(s);
#endif
return;
}