* SUCH DAMAGE.
*/
-/* Mangled into a form that works on Sparc Solaris 2 by Mark Eichin
+/* Mangled into a form that works on SPARC Solaris 2 by Mark Eichin
* for Cygnus Support, July 1992.
*/
-#include "config.h"
-#include "system.h"
+#include "tconfig.h"
+#include "tsystem.h"
+#include <fcntl.h> /* for creat() */
+#include "coretypes.h"
+#include "tm.h"
#if 0
#include "sparc/gmon.h"
#define MSG "No space for profiling buffer(s)\n"
-static void moncontrol PROTO ((int));
-extern void monstartup PROTO ((char *, char *));
-extern void _mcleanup PROTO ((void));
+static void moncontrol (int);
+extern void monstartup (char *, char *);
+extern void _mcleanup (void);
-void monstartup(lowpc, highpc)
- char *lowpc;
- char *highpc;
+void monstartup(char *lowpc, char *highpc)
{
int monsize;
char *buffer;
* so the rest of the scaling (here and in gprof) stays in ints.
*/
lowpc = (char *)
- ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
+ ROUNDDOWN((unsigned long)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
s_lowpc = lowpc;
highpc = (char *)
- ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
+ ROUNDUP((unsigned long)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
s_highpc = highpc;
s_textsize = highpc - lowpc;
monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
}
void
-_mcleanup()
+_mcleanup(void)
{
int fd;
int fromindex;
else
progname++;
- sprintf(buf, "%s/%ld.%s", profdir, getpid(), progname);
+ sprintf(buf, "%s/%ld.%s", profdir, (long) getpid(), progname);
proffile = buf;
} else {
proffile = "gmon.out";
}
# ifdef DEBUG
fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
-# endif DEBUG
+# endif /* DEBUG */
write( fd , sbuf , ssiz );
endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
fprintf( stderr ,
"[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
frompc , tos[toindex].selfpc , tos[toindex].count );
-# endif DEBUG
+# endif /* DEBUG */
rawarc.raw_frompc = (unsigned long) frompc;
rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
rawarc.raw_count = tos[toindex].count;
}
/*
- * The Sparc stack frame is only held together by the frame pointers
+ * The SPARC stack frame is only held together by the frame pointers
* in the register windows. According to the SVR4 SPARC ABI
* Supplement, Low Level System Information/Operating System
* Interface/Software Trap Types, a type 3 trap will flush all of the
* -- [eichin:19920702.1107EST]
*/
-static void internal_mcount PROTO((char *, unsigned short *)) ATTRIBUTE_UNUSED;
+static void internal_mcount (char *, unsigned short *) __attribute__ ((used));
/* i7 == last ret, -> frompcindex */
/* o7 == current ret, -> selfpc */
/* This is for compatibility with old versions of gcc which used mcount. */
asm(".global mcount; mcount: mov %i7,%o1; mov %o7,%o0;b,a internal_mcount");
-static void internal_mcount(selfpc, frompcindex)
- register char *selfpc;
- register unsigned short *frompcindex;
+static void internal_mcount(char *selfpc, unsigned short *frompcindex)
{
register struct tostruct *top;
register struct tostruct *prevtop;
if(!already_setup) {
extern char etext[];
+ extern char _start[];
+ extern char _init[];
already_setup = 1;
- monstartup(0, (char *)etext);
+ monstartup(_start < _init ? _start : _init, etext);
#ifdef USE_ONEXIT
on_exit(_mcleanup, 0);
#else
* profiling is what mcount checks to see if
* all the data structures are ready.
*/
-static void moncontrol(mode)
- int mode;
+static void moncontrol(int mode)
{
if (mode) {
/* start */
profil((unsigned short *)(sbuf + sizeof(struct phdr)),
ssiz - sizeof(struct phdr),
- (int)s_lowpc, s_scale);
+ (long)s_lowpc, s_scale);
profiling = 0;
} else {
/* stop */