* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#include <stdio.h>
+#include "libiberty.h"
#include "gprof.h"
+#include "search_list.h"
+#include "source.h"
+#include "symtab.h"
#include "cg_arcs.h"
#include "cg_dfn.h"
-#include "symtab.h"
#include "utils.h"
-#define DFN_DEPTH 100
+#define DFN_INCR_DEPTH (128)
typedef struct
{
}
DFN_Stack;
-DFN_Stack dfn_stack[DFN_DEPTH];
+static boolean is_numbered PARAMS ((Sym *));
+static boolean is_busy PARAMS ((Sym *));
+static void find_cycle PARAMS ((Sym *));
+static void pre_visit PARAMS ((Sym *));
+static void post_visit PARAMS ((Sym *));
+
+DFN_Stack *dfn_stack = NULL;
+int dfn_maxdepth = 0;
int dfn_depth = 0;
int dfn_counter = DFN_NAN;
/*
* Is CHILD already numbered?
*/
-static bool
-DEFUN (is_numbered, (child), Sym * child)
+static boolean
+is_numbered (child)
+ Sym *child;
{
return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY;
}
/*
* Is CHILD already busy?
*/
-static bool
-DEFUN (is_busy, (child), Sym * child)
+static boolean
+is_busy (child)
+ Sym *child;
{
if (child->cg.top_order == DFN_NAN)
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
* depth-first number).
*/
static void
-DEFUN (find_cycle, (child), Sym * child)
+find_cycle (child)
+ Sym *child;
{
Sym *head = 0;
Sym *tail;
* the stack and mark it busy.
*/
static void
-DEFUN (pre_visit, (parent), Sym * parent)
+pre_visit (parent)
+ Sym *parent;
{
++dfn_depth;
- if (dfn_depth >= DFN_DEPTH)
+
+ if (dfn_depth >= dfn_maxdepth)
{
- fprintf (stderr, "[pre_visit] dfn_stack overflow\n");
- done (1);
+ dfn_maxdepth += DFN_INCR_DEPTH;
+ dfn_stack = xrealloc (dfn_stack, dfn_maxdepth * sizeof *dfn_stack);
}
+
dfn_stack[dfn_depth].sym = parent;
dfn_stack[dfn_depth].cycle_top = dfn_depth;
parent->cg.top_order = DFN_BUSY;
* and number functions if PARENT is head of a cycle.
*/
static void
-DEFUN (post_visit, (parent), Sym * parent)
+post_visit (parent)
+ Sym *parent;
{
Sym *member;
* Given this PARENT, depth first number its children.
*/
void
-DEFUN (cg_dfn, (parent), Sym * parent)
+cg_dfn (parent)
+ Sym *parent;
{
Arc *arc;