Back to index

glibc  2.9
bb_init_func.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by David Mosberger (davidm@cs.arizona.edu).
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* __bb_init_func is invoked at the beginning of each function, before
00021    any registers have been saved.  This generic routine should work
00022    provided that calling this function doesn't mangle the arguments
00023    passed to the function being called.  If that's not the case, a
00024    system specific routine must be provided.  */
00025 
00026 #include <sys/types.h>
00027 #include <sys/gmon.h>
00028 
00029 #include <stdlib.h>
00030 
00031 void
00032 __bb_init_func (struct __bb *bb)
00033 {
00034   struct gmonparam *p = &_gmonparam;
00035 
00036   if (bb->zero_word != 0)
00037     {
00038       return; /* handle common case quickly */
00039     }
00040 
00041   /* insert this basic-block into basic-block list: */
00042   bb->zero_word = 1;
00043   bb->next = __bb_head;
00044   __bb_head = bb;
00045 
00046   if (bb->next == 0 && p->state != GMON_PROF_ON)
00047     {
00048       /* we didn't register _mcleanup yet and pc profiling doesn't seem
00049         to be active, so let's register it now: */
00050       extern void *__dso_handle __attribute__ ((__weak__));
00051       __cxa_atexit ((void (*) (void *)) _mcleanup, NULL,
00052                   &__dso_handle ? __dso_handle : NULL);
00053     }
00054 }