Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

bbexit.c File Reference

#include <stdio.h>
#include <stdlib.h>

Include dependency graph for bbexit.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  _bbdata
struct  _bbdata::func
struct  _bbdata::func::caller
struct  callsite
union  callsite::coordinate

Functions

void _epilogue (struct func *callee)
void _prologue (struct func *callee, struct _bbdata *yylink)
void bbexit (void)
void profout (struct _bbdata *p, FILE *fp)
void unpack (unsigned int coord, int *index, int *x, int *y)

Variables

_bbdata_bblist
callsite_caller
_bbdata tail


Function Documentation

void _epilogue struct func callee  ) 
 

Definition at line 95 of file bbexit.c.

References _caller.

00095                                     {
00096     _caller = 0;
00097 }

void _prologue struct func callee,
struct _bbdata yylink
 

Definition at line 99 of file bbexit.c.

References _bblist, _caller, atexit(), bbexit(), func::callers, func::link, _bbdata::link, next, and p.

00099                                                             {
00100     static struct caller callers[4096];
00101     static int next;
00102     struct caller *p;
00103 
00104     if (!yylink->link) {
00105         yylink->link = _bblist;
00106         _bblist = yylink;
00107         if (next == 0)
00108             atexit(bbexit);
00109     }
00110     for (p = callee->callers; p; p = p->link)
00111         if (p->caller == _caller) {
00112             p->count++;
00113             break;
00114         }
00115     if (!p && next < sizeof callers/sizeof callers[0]) {
00116         p = &callers[next++];
00117         p->caller = _caller;
00118         p->count = 1;
00119         p->link = callee->callers;
00120         callee->callers = p;
00121     }
00122     _caller = 0;
00123 }

Here is the call graph for this function:

void bbexit void   )  [static]
 

Definition at line 85 of file bbexit.c.

References _bblist, fclose(), fopen(), fp, _bbdata::link, profout(), and tail.

Referenced by _prologue().

00085                          {
00086     FILE *fp;
00087 
00088     if (_bblist != &tail && (fp = fopen("prof.out", "a"))) {
00089         for ( ; _bblist != &tail; _bblist = _bblist->link)
00090             profout(_bblist, fp);
00091         fclose(fp);
00092     }
00093 }

Here is the call graph for this function:

void profout struct _bbdata p,
FILE fp
[static]
 

Definition at line 47 of file bbexit.c.

References _bbdata::coords, _bbdata::counts, f, _bbdata::files, fp, fprintf(), _bbdata::funcs, i, _bbdata::func::link, func::link, n, _bbdata::npoints, p, q, unpack(), x, and y.

Referenced by bbexit().

00047                                                  {
00048     int i, index, x, y;
00049     struct func *f;
00050     struct caller *q;
00051 
00052     for (i = 0; p->files[i]; i++)
00053         ;
00054     fprintf(fp, "%d\n", i);
00055     for (i = 0; p->files[i]; i++)
00056         fprintf(fp, "%s\n", p->files[i]);
00057     for (i = 0, f = p->funcs; f; i++, f = f->link)
00058         if (q = f->callers)
00059             for (i--; q; q = q->link)
00060                 i++;
00061     fprintf(fp, "%d\n", i);
00062     for (f = p->funcs; f; f = f->link) {
00063         int n = 0;
00064         for (q = f->callers; q; n += q->count, q = q->link) {
00065             unpack(f->src.coord, &index, &x, &y);
00066             fprintf(fp, "%s %d %d %d %d", f->name, index, x, y, q->count);
00067             if (q->caller) {
00068                 unpack(q->caller->u.coord, &index, &x, &y);
00069                 fprintf(fp, " %s %s %d %d\n", q->caller->name, q->caller->file, x, y);
00070             } else
00071                 fprintf(fp, " ? ? 0 0\n");
00072         }
00073         if (n == 0) {
00074             unpack(f->src.coord, &index, &x, &y);
00075             fprintf(fp, "%s %d %d %d 0 ? ? 0 0\n", f->name, index, x, y);
00076         }
00077     }       
00078     fprintf(fp, "%d\n", p->npoints);
00079     for (i = 0; i < p->npoints; i++) {
00080         unpack(p->coords[i].coord, &index, &x, &y);
00081         fprintf(fp, "%d %d %d %d\n", index, x, y, p->counts[i]);
00082     }
00083 }

Here is the call graph for this function:

void unpack unsigned int  coord,
int *  index,
int *  x,
int *  y
[static]
 

Definition at line 31 of file bbexit.c.

References x, and y.

Referenced by profout().

00031                                                                    {
00032     static union { int x; char endian; } little = { 1 };
00033     union coordinate u;
00034 
00035     u.coord = coord;
00036     if (little.endian) {
00037         *index = u.le.index;
00038         *x = u.le.x;
00039         *y = u.le.y;
00040     } else {
00041         *index = u.be.index;
00042         *x = u.be.x;
00043         *y = u.be.y;
00044     }
00045 }               


Variable Documentation

struct _bbdata * _bblist [static]
 

Referenced by _prologue(), and bbexit().

struct callsite * _caller
 

Referenced by _epilogue(), and _prologue().

struct _bbdata tail [static]
 

Referenced by bbexit().


Generated on Thu Aug 25 15:49:29 2005 for Quake III Arena by  doxygen 1.3.9.1