temp files should be protected; bug report 4.3BSD/usr.bin/186
[unix-history] / usr / src / usr.bin / gprof / arcs.c
index 92c5df5..6c135c7 100644 (file)
@@ -1,6 +1,23 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)arcs.c      1.14 (Berkeley) %G%";
-#endif lint
+static char sccsid[] = "@(#)arcs.c     5.5 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "gprof.h"
 
 
 #include "gprof.h"
 
@@ -68,9 +85,10 @@ topcmp( npp1 , npp2 )
     return (*npp1) -> toporder - (*npp2) -> toporder;
 }
 
     return (*npp1) -> toporder - (*npp2) -> toporder;
 }
 
+nltype **
 doarcs()
 {
 doarcs()
 {
-    nltype     *parentp;
+    nltype     *parentp, **timesortnlp;
     arctype    *arcp;
     long       index;
 
     arctype    *arcp;
     long       index;
 
@@ -98,7 +116,7 @@ doarcs()
        parentp -> cyclehead = parentp;
        parentp -> cnext = 0;
        if ( cflag ) {
        parentp -> cyclehead = parentp;
        parentp -> cnext = 0;
        if ( cflag ) {
-           findcalls( parentp , parentp -> value , (parentp+1) -> value );
+           findcall( parentp , parentp -> value , (parentp+1) -> value );
        }
     }
        /*
        }
     }
        /*
@@ -150,7 +168,26 @@ doarcs()
         *      propogate children times up to parents.
         */
     dotime();
         *      propogate children times up to parents.
         */
     dotime();
-    printgprof();
+       /*
+        *      Now, sort by propself + propchild.
+        *      sorting both the regular function names
+        *      and cycle headers.
+        */
+    timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
+    if ( timesortnlp == (nltype **) 0 ) {
+       fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
+    }
+    for ( index = 0 ; index < nname ; index++ ) {
+       timesortnlp[index] = &nl[index];
+    }
+    for ( index = 1 ; index <= ncycle ; index++ ) {
+       timesortnlp[nname+index-1] = &cyclenl[index];
+    }
+    qsort( timesortnlp , nname + ncycle , sizeof(nltype *) , totalcmp );
+    for ( index = 0 ; index < nname + ncycle ; index++ ) {
+       timesortnlp[ index ] -> index = index + 1;
+    }
+    return( timesortnlp );
 }
 
 dotime()
 }
 
 dotime()