OSDN Git Service

* config/arc/arc-protos.h arc_select_cc_mode, gen_compare_reg):
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / gmon-sol2.c
index f629bc8..aeead89 100644 (file)
  * 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"
@@ -85,13 +88,11 @@ static int  s_scale;
 
 #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;
@@ -102,10 +103,10 @@ void monstartup(lowpc, highpc)
         *      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);
@@ -167,7 +168,7 @@ void monstartup(lowpc, highpc)
 }
 
 void
-_mcleanup()
+_mcleanup(void)
 {
     int                        fd;
     int                        fromindex;
@@ -195,7 +196,7 @@ _mcleanup()
        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";
@@ -208,7 +209,7 @@ _mcleanup()
     }
 #   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++ ) {
@@ -221,7 +222,7 @@ _mcleanup()
                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;
@@ -232,7 +233,7 @@ _mcleanup()
 }
 
 /*
- * 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
@@ -266,7 +267,7 @@ _mcleanup()
  * -- [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 */
@@ -275,9 +276,7 @@ asm(".global _mcount; _mcount: mov %i7,%o1; mov %o7,%o0;b,a internal_mcount");
 /* 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;
@@ -291,8 +290,10 @@ static void internal_mcount(selfpc, frompcindex)
 
        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
@@ -405,14 +406,13 @@ overflow:
  *     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 */