Back to index

glibc  2.9
machine-gmon.h
Go to the documentation of this file.
00001 /* Machine-dependent definitions for profiling support.  Generic GCC 2 version.
00002    Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
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 /* GCC version 2 gives us a perfect magical function to get
00021    just the information we need:
00022      void *__builtin_return_address (unsigned int N)
00023    returns the return address of the frame N frames up.  */
00024 
00025 /* Be warned that GCC cannot usefully compile __builtin_return_address(N)
00026    for N != 0 on all machines.  In this case, you may have to write
00027    your own version of _mcount().  */
00028 
00029 #if __GNUC__ < 2
00030  #error "This file uses __builtin_return_address, a GCC 2 extension."
00031 #endif
00032 
00033 #include <sysdep.h>
00034 #ifndef NO_UNDERSCORES
00035 /* The asm symbols for C functions are `_function'.
00036    The canonical name for the counter function is `mcount', no _.  */
00037 void _mcount (void) asm ("mcount");
00038 #else
00039 /* The canonical name for the function is `_mcount' in both C and asm,
00040    but some old asm code might assume it's `mcount'.  */
00041 void _mcount (void);
00042 weak_alias (_mcount, mcount)
00043 #endif
00044 
00045 static void mcount_internal (u_long frompc, u_long selfpc);
00046 
00047 #define _MCOUNT_DECL(frompc, selfpc) \
00048 static inline void mcount_internal (u_long frompc, u_long selfpc)
00049 
00050 #define MCOUNT \
00051 void _mcount (void)                                                  \
00052 {                                                                    \
00053   mcount_internal ((u_long) RETURN_ADDRESS (1), (u_long) RETURN_ADDRESS (0)); \
00054 }