/*
 * $Header: /smsa/bsd:include/sys/gprof.h:bsd  1.9  $
 * $Source: /smsa/bsd:include/sys/gprof.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* @(#)gprof.h	1.2 87/05/15 3.2/4.3NFSSRC */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)gprof.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__sys_gprof_h
#define	__sys_gprof_h

struct phdr {
    char	*lpc;
    char	*hpc;
    int		ncnt;
};

#ifdef	_KERNEL
#define	HISTCOUNTER	unsigned	/* Maintained by the kernel for kernel profiling */
#else	_KERNEL
#define	HISTCOUNTER	unsigned short	/* Maintained by the kernel for a user process */
#endif	_KERNEL

    /*
     * Each routine when compiled occupies at least 3 words - one for
     * a movs pc,lr instruction, one word of header information and one word
     * for the name (up to two characters!)  If we assume that all routines will
     * null implementations have names of more than two characters (!) we can
     * assume at least 4 words per routine.
     */
#define	HISTOGRAM_TEXT_BYTES	(4*4)
#define HISTFRACTION (HISTOGRAM_TEXT_BYTES/sizeof(HISTCOUNTER))

    /*
     *	The value of MIN_CALL_SEPARATION is the minimum number of bytes
     *	of separation between two subroutine call points in the object code.
     *
     *  For the ARM, the shortest two call sequence is:
     *
     *		bl	func1
     *		bl	func2
     *
     *	which is separated by only 4 bytes.
     */
#define	MIN_CALL_SEPARATION	4

    /*
     *	percent of text space to allocate for tostructs
     *	with a minimum.  (Note that ARM code is not very
     *  compact, hence the low % allowed.)
     */
#define ARCDENSITY	1
#define MINARCS		50

#ifdef __arm
struct tostruct {
    char		*selfpc;
    long		count;
    unsigned /*short*/	link;
};
#else
struct tostruct {
    char		*selfpc;
    long		count;
    unsigned short	link;
};
#endif __arm

    /*
     *	a raw arc,
     *	    with pointers to the calling site and the called site
     *	    and a count.
     */
struct rawarc {
    unsigned long	raw_frompc;
    unsigned long	raw_selfpc;
    long		raw_count;
};

    /*
     *	general rounding functions.
     */
#define ROUNDDOWN(x,y)	(((x)/(y))*(y))
#define ROUNDUP(x,y)	((((x)+(y)-1)/(y))*(y))


extern	int profiling;
extern	char *s_lowpc;
extern	u_long s_textsize;
extern	HISTCOUNTER *kcount;

#endif/*__sys_gprof_h*/

/* EOF gprof.h */
