try to make display narrower
[unix-history] / usr / src / lib / libc / gmon / gmon.c
index d098de7..76a6d61 100644 (file)
@@ -1,4 +1,12 @@
-static char *sccsid = "@(#)gmon.c      4.12 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gmon.c     5.4 (Berkeley) %G%";
+#endif LIBC_SCCS and not lint
 
 #ifdef DEBUG
 #include <stdio.h>
 
 #ifdef DEBUG
 #include <stdio.h>
@@ -16,7 +24,6 @@ static long           tolimit = 0;
 static char            *s_lowpc = 0;
 static char            *s_highpc = 0;
 static unsigned long   s_textsize = 0;
 static char            *s_lowpc = 0;
 static char            *s_highpc = 0;
 static unsigned long   s_textsize = 0;
-static char            *minsbrk = 0;
 
 static int     ssiz;
 static char    *sbuf;
 
 static int     ssiz;
 static char    *sbuf;
@@ -33,6 +40,7 @@ monstartup(lowpc, highpc)
     int                        monsize;
     char               *buffer;
     char               *sbrk();
     int                        monsize;
     char               *buffer;
     char               *sbrk();
+    extern char                *minbrk;
 
        /*
         *      round lowpc and highpc to multiples of the density we're using
 
        /*
         *      round lowpc and highpc to multiples of the density we're using
@@ -48,12 +56,12 @@ monstartup(lowpc, highpc)
     monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
     buffer = sbrk( monsize );
     if ( buffer == (char *) -1 ) {
     monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
     buffer = sbrk( monsize );
     if ( buffer == (char *) -1 ) {
-       write( 2 , MSG , sizeof(MSG) );
+       write( 2 , MSG , sizeof(MSG) - 1 );
        return;
     }
     froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
     if ( froms == (unsigned short *) -1 ) {
        return;
     }
     froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
     if ( froms == (unsigned short *) -1 ) {
-       write( 2 , MSG , sizeof(MSG) );
+       write( 2 , MSG , sizeof(MSG) - 1 );
        froms = 0;
        return;
     }
        froms = 0;
        return;
     }
@@ -65,12 +73,12 @@ monstartup(lowpc, highpc)
     }
     tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) );
     if ( tos == (struct tostruct *) -1 ) {
     }
     tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) );
     if ( tos == (struct tostruct *) -1 ) {
-       write( 2 , MSG , sizeof(MSG) );
+       write( 2 , MSG , sizeof(MSG) - 1 );
        froms = 0;
        tos = 0;
        return;
     }
        froms = 0;
        tos = 0;
        return;
     }
-    minsbrk = sbrk(0);
+    minbrk = sbrk(0);
     tos[0].link = 0;
     monitor( lowpc , highpc , buffer , monsize , tolimit );
 }
     tos[0].link = 0;
     monitor( lowpc , highpc , buffer , monsize , tolimit );
 }
@@ -126,10 +134,6 @@ mcount()
        register struct tostruct        *prevtop;       /* r8  => r2 */
        register long                   toindex;        /* r7  => r1 */
 
        register struct tostruct        *prevtop;       /* r8  => r2 */
        register long                   toindex;        /* r7  => r1 */
 
-#ifdef lint
-       selfpc = (char *)0;
-       frompcindex = 0;
-#else not lint
        /*
         *      find the return address for mcount,
         *      and the return address for mcount's caller.
        /*
         *      find the return address for mcount,
         *      and the return address for mcount's caller.
@@ -137,7 +141,6 @@ mcount()
        asm("   .text");                /* make sure we're in text space */
        asm("   movl (sp), r11");       /* selfpc = ... (jsb frame) */
        asm("   movl 16(fp), r10");     /* frompcindex =     (calls frame) */
        asm("   .text");                /* make sure we're in text space */
        asm("   movl (sp), r11");       /* selfpc = ... (jsb frame) */
        asm("   movl 16(fp), r10");     /* frompcindex =     (calls frame) */
-#endif not lint
        /*
         *      check that we are profiling
         *      and that we aren't recursively invoked.
        /*
         *      check that we are profiling
         *      and that we aren't recursively invoked.
@@ -235,7 +238,7 @@ out:
 overflow:
        profiling++; /* halt further profiling */
 #   define     TOLIMIT "mcount: tos overflow\n"
 overflow:
        profiling++; /* halt further profiling */
 #   define     TOLIMIT "mcount: tos overflow\n"
-       write(2, TOLIMIT, sizeof(TOLIMIT));
+       write(2, TOLIMIT, sizeof(TOLIMIT) - 1);
        goto out;
 }
 asm(".text");
        goto out;
 }
 asm(".text");
@@ -292,24 +295,3 @@ moncontrol(mode)
        profiling = 3;
     }
 }
        profiling = 3;
     }
 }
-
-/*
- * This is a stub for the "brk" system call, which we want to
- * catch so that it will not deallocate our data space.
- * (of which the program is not aware)
- */
-extern char *curbrk;
-
-brk(addr)
-       char *addr;
-{
-
-       if (addr < minsbrk)
-               addr = minsbrk;
-       asm("   chmk    $17");
-       asm("   jcc     1f");
-       asm("   jmp     cerror");
-asm("1:");
-       curbrk = addr;
-       return (0);
-}