Back to index

glibc  2.9
Functions | Variables
pcprofile.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <libc-internal.h>

Go to the source code of this file.


static void __attribute__ ((constructor))
static void __attribute__ ((destructor))
void __cyg_profile_func_enter (void *this_fn, void *call_site)


static int active
static int fd

Function Documentation

static void __attribute__ ( (constructor)  ) [static]

Definition at line 36 of file pcprofile.c.

  /* See whether the environment variable `PCPROFILE_OUTPUT' is defined.
     If yes, it should name a FIFO.  We open it and mark ourself as active.  */
  const char *outfile = getenv ("PCPROFILE_OUTPUT");

  if (outfile != NULL && *outfile != '\0')
      fd = open (outfile, O_RDWR | O_CREAT, 0666);

      if (fd != -1)
         uint32_t word;

         active = 1;

         /* Write a magic word which tells the reader about the byte
            order and the size of the following entries.  */
         word = 0xdeb00000 | sizeof (void *);
         if (TEMP_FAILURE_RETRY (write (fd, &word, 4)) != 4)
             /* If even this fails we shouldn't try further.  */
             close (fd);
             fd = -1;
             active = 0;

Here is the call graph for this function:

static void __attribute__ ( (destructor)  ) [static]

Definition at line 69 of file pcprofile.c.

  if (active)
    close (fd);

Here is the call graph for this function:

void __cyg_profile_func_enter ( void *  this_fn,
void *  call_site 

Definition at line 78 of file pcprofile.c.

  void *buf[2];

  if (! active)

  /* Now write out the current position and that of the caller.  We do
     this now, and don't cache the because we want real-time output.  */
  buf[0] = this_fn;
  buf[1] = call_site;

  write (fd, buf, sizeof buf);

Here is the call graph for this function:

Variable Documentation

int active [static]

Definition at line 29 of file pcprofile.c.

int fd [static]

Definition at line 32 of file pcprofile.c.