xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame^] | 1 | /* Copyright (C) 1996-2016 Free Software Foundation, Inc. |
| 2 | This file is part of the GNU C Library. |
| 3 | Contributed by David Mosberger (davidm@cs.arizona.edu). |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | /* __bb_init_func is invoked at the beginning of each function, before |
| 20 | any registers have been saved. This generic routine should work |
| 21 | provided that calling this function doesn't mangle the arguments |
| 22 | passed to the function being called. If that's not the case, a |
| 23 | system specific routine must be provided. */ |
| 24 | |
| 25 | #include <sys/types.h> |
| 26 | #include <sys/gmon.h> |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | void |
| 31 | __bb_init_func (struct __bb *bb) |
| 32 | { |
| 33 | struct gmonparam *p = &_gmonparam; |
| 34 | |
| 35 | if (bb->zero_word != 0) |
| 36 | { |
| 37 | return; /* handle common case quickly */ |
| 38 | } |
| 39 | |
| 40 | /* insert this basic-block into basic-block list: */ |
| 41 | bb->zero_word = 1; |
| 42 | bb->next = __bb_head; |
| 43 | __bb_head = bb; |
| 44 | |
| 45 | if (bb->next == 0 && p->state != GMON_PROF_ON) |
| 46 | { |
| 47 | /* we didn't register _mcleanup yet and pc profiling doesn't seem |
| 48 | to be active, so let's register it now: */ |
| 49 | extern void *__dso_handle __attribute__ ((__weak__)); |
| 50 | __cxa_atexit ((void (*) (void *)) _mcleanup, NULL, |
| 51 | &__dso_handle ? __dso_handle : NULL); |
| 52 | } |
| 53 | } |