Back to index

glibc  2.9
Defines | Functions | Variables
bb_exit_func.c File Reference
#include <sys/gmon.h>
#include <sys/gmon_out.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <string.h>

Go to the source code of this file.

Defines

#define OUT_NAME   "gmon.out"

Functions

void __bb_exit_func (void)

Variables

struct __bb *__bb_head attribute_hidden

Define Documentation

#define OUT_NAME   "gmon.out"

Definition at line 31 of file bb_exit_func.c.


Function Documentation

void __bb_exit_func ( void  )

Definition at line 38 of file bb_exit_func.c.

{
  const int version = GMON_VERSION;
  struct gmon_hdr ghdr;
  struct __bb *ptr;
  FILE *fp;
  fp = fopen (OUT_NAME, "wb");
  if (!fp)
    {
      perror (OUT_NAME);
      return;
    }
  /* No threads use this stream.  */
  __fsetlocking (fp, FSETLOCKING_BYCALLER);

  memcpy (&ghdr.cookie[0], GMON_MAGIC, 4);
  memcpy (&ghdr.version, &version, sizeof (version));
  fwrite_unlocked (&ghdr, sizeof (ghdr), 1, fp);

  for (ptr = __bb_head; ptr != 0; ptr = ptr->next)
    {
      u_int ncounts = ptr->ncounts;
      u_char tag;
      u_int i;

      tag = GMON_TAG_BB_COUNT;
      fwrite_unlocked (&tag, sizeof (tag), 1, fp);
      fwrite_unlocked (&ncounts, sizeof (ncounts), 1, fp);

      for (i = 0; i < ncounts; ++i)
       {
         fwrite_unlocked (&ptr->addresses[i], sizeof (ptr->addresses[0]), 1,
                        fp);
         fwrite_unlocked (&ptr->counts[i], sizeof (ptr->counts[0]), 1, fp);
       }
    }
  fclose (fp);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 25 of file init-first.c.