Commit 4f5afe7d by Roger Sayle Committed by Roger Sayle

gmon-sol2.c: Silence compilation warnings by partially synchronizing code with...


	* config/i386/gmon-sol2.c: Silence compilation warnings by partially
	synchronizing code with config/sparc/gmon-sol2.c.  Remove #if 0
	blocks.  #include "tconfig.h" and "tsystem.h" to prototype system
	functions such as sbrk, write, etc..  Add function prototypes.
	Convert function declarations from K&R to ISO C.  Cast pointers
	to "long" and "unsigned long" instead of "int" and "unsigned int".
	Convert tokens following #endif into comments.


Co-Authored-By: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>

From-SVN: r115540
parent d4bc44ea
2006-07-17 Roger Sayle <roger@eyesopen.com>
Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* config/i386/gmon-sol2.c: Silence compilation warnings by partially
synchronizing code with config/sparc/gmon-sol2.c. Remove #if 0
blocks. #include "tconfig.h" and "tsystem.h" to prototype system
functions such as sbrk, write, etc.. Add function prototypes.
Convert function declarations from K&R to ISO C. Cast pointers
to "long" and "unsigned long" instead of "int" and "unsigned int".
Convert tokens following #endif into comments.
2006-07-17 Toon Moene <toon@moene.indiv.nluug.nl> 2006-07-17 Toon Moene <toon@moene.indiv.nluug.nl>
* invoke.texi: Remove mention of f77; Reformat table for * invoke.texi: Remove mention of f77; Reformat table for
......
...@@ -53,22 +53,19 @@ ...@@ -53,22 +53,19 @@
* This code could easily be integrated with the original gmon.c and perhaps * This code could easily be integrated with the original gmon.c and perhaps
* should be. * should be.
*/ */
#include "tconfig.h"
#include "tsystem.h"
#include <fcntl.h> /* for creat() */
#ifndef lint
static char sccsid[] = "@(#)gmon.c 5.3 (Berkeley) 5/22/91";
#endif /* not lint */
#if 0
#include <unistd.h>
#endif
#ifdef DEBUG #ifdef DEBUG
#include <stdio.h> #include <stdio.h>
#endif #endif
#if 0 static void moncontrol (int);
#include "i386/gmon.h" extern void monstartup (char *, char *);
#else extern void _mcleanup (void);
extern void internal_mcount (void);
struct phdr { struct phdr {
char *lpc; char *lpc;
...@@ -90,6 +87,7 @@ struct tostruct { ...@@ -90,6 +87,7 @@ struct tostruct {
long count; long count;
unsigned short link; unsigned short link;
}; };
struct rawarc { struct rawarc {
unsigned long raw_frompc; unsigned long raw_frompc;
unsigned long raw_selfpc; unsigned long raw_selfpc;
...@@ -97,14 +95,9 @@ struct rawarc { ...@@ -97,14 +95,9 @@ struct rawarc {
}; };
#define ROUNDDOWN(x,y) (((x)/(y))*(y)) #define ROUNDDOWN(x,y) (((x)/(y))*(y))
#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
#endif
/* char *minbrk; */ /* char *minbrk; */
#ifdef __alpha
extern char *sbrk ();
#endif
/* /*
* froms is actually a bunch of unsigned shorts indexing tos * froms is actually a bunch of unsigned shorts indexing tos
*/ */
...@@ -126,9 +119,8 @@ static int s_scale; ...@@ -126,9 +119,8 @@ static int s_scale;
extern int errno; extern int errno;
monstartup(lowpc, highpc) void
char *lowpc; monstartup(char *lowpc, char *highpc)
char *highpc;
{ {
int monsize; int monsize;
char *buffer; char *buffer;
...@@ -139,10 +131,10 @@ monstartup(lowpc, highpc) ...@@ -139,10 +131,10 @@ monstartup(lowpc, highpc)
* so the rest of the scaling (here and in gprof) stays in ints. * so the rest of the scaling (here and in gprof) stays in ints.
*/ */
lowpc = (char *) lowpc = (char *)
ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER)); ROUNDDOWN((unsigned long)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
s_lowpc = lowpc; s_lowpc = lowpc;
highpc = (char *) highpc = (char *)
ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER)); ROUNDUP((unsigned long)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
s_highpc = highpc; s_highpc = highpc;
s_textsize = highpc - lowpc; s_textsize = highpc - lowpc;
monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr); monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
...@@ -203,7 +195,8 @@ monstartup(lowpc, highpc) ...@@ -203,7 +195,8 @@ monstartup(lowpc, highpc)
moncontrol(1); moncontrol(1);
} }
_mcleanup() void
_mcleanup (void)
{ {
int fd; int fd;
int fromindex; int fromindex;
...@@ -220,7 +213,7 @@ _mcleanup() ...@@ -220,7 +213,7 @@ _mcleanup()
} }
# ifdef DEBUG # ifdef DEBUG
fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz ); fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
# endif DEBUG # endif /* DEBUG */
write( fd , sbuf , ssiz ); write( fd , sbuf , ssiz );
endfrom = s_textsize / (HASHFRACTION * sizeof(*froms)); endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
...@@ -234,7 +227,7 @@ _mcleanup() ...@@ -234,7 +227,7 @@ _mcleanup()
fprintf( stderr , fprintf( stderr ,
"[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" , "[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
frompc , tos[toindex].selfpc , tos[toindex].count ); frompc , tos[toindex].selfpc , tos[toindex].count );
# endif DEBUG # endif /* DEBUG */
rawarc.raw_frompc = (unsigned long) frompc; rawarc.raw_frompc = (unsigned long) frompc;
rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc; rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
rawarc.raw_count = tos[toindex].count; rawarc.raw_count = tos[toindex].count;
...@@ -249,7 +242,8 @@ asm(".globl _mcount; _mcount: jmp internal_mcount"); ...@@ -249,7 +242,8 @@ asm(".globl _mcount; _mcount: jmp internal_mcount");
/* This is for compatibility with old versions of gcc which used mcount. */ /* This is for compatibility with old versions of gcc which used mcount. */
asm(".globl mcount; mcount: jmp internal_mcount"); asm(".globl mcount; mcount: jmp internal_mcount");
internal_mcount() void
internal_mcount (void)
{ {
register char *selfpc; register char *selfpc;
register unsigned short *frompcindex; register unsigned short *frompcindex;
...@@ -271,10 +265,10 @@ internal_mcount() ...@@ -271,10 +265,10 @@ internal_mcount()
frompcindex = (void *) __builtin_return_address (1); frompcindex = (void *) __builtin_return_address (1);
if(!already_setup) { if(!already_setup) {
extern etext(); extern char etext[];
already_setup = 1; already_setup = 1;
/* monstartup(0, etext); */ /* monstartup(0, etext); */
monstartup(0x08040000, etext); monstartup((char*)0x08040000, etext);
#ifdef USE_ONEXIT #ifdef USE_ONEXIT
on_exit(_mcleanup, 0); on_exit(_mcleanup, 0);
#else #else
...@@ -387,15 +381,15 @@ overflow: ...@@ -387,15 +381,15 @@ overflow:
* profiling is what mcount checks to see if * profiling is what mcount checks to see if
* all the data structures are ready. * all the data structures are ready.
*/ */
moncontrol(mode) static void
int mode; moncontrol(int mode)
{ {
if (mode) if (mode)
{ {
/* start */ /* start */
profil((unsigned short *)(sbuf + sizeof(struct phdr)), profil((unsigned short *)(sbuf + sizeof(struct phdr)),
ssiz - sizeof(struct phdr), ssiz - sizeof(struct phdr),
(int)s_lowpc, s_scale); (long)s_lowpc, s_scale);
profiling = 0; profiling = 0;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment