Assembler version of gmon handling.
[glibc/history.git] / sysdeps / arm / machine-gmon.h
blob27643df884350a47242d4d0d8a75491c40754ff3
1 /* Machine-dependent definitions for profiling support. ARM version.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* GCC for the ARM cannot compile __builtin_return_address(N) for N != 0,
21 so we must use an assembly stub. */
23 #include <sysdep.h>
24 #ifndef NO_UNDERSCORES
25 /* The asm symbols for C functions are `_function'.
26 The canonical name for the counter function is `mcount', no _. */
27 void _mcount (void) asm ("mcount");
28 #else
29 /* The canonical name for the function is `_mcount' in both C and asm,
30 but some old asm code might assume it's `mcount'. */
31 void _mcount (void);
32 weak_alias (_mcount, mcount)
33 #endif
35 static void mcount_internal (u_long frompc, u_long selfpc);
37 #define _MCOUNT_DECL(frompc, selfpc) \
38 static void mcount_internal (u_long frompc, u_long selfpc)
40 #define MCOUNT \
41 void _mcount (void) \
42 { \
43 register unsigned long int frompc, selfpc; \
44 __asm__("movs fp, fp; " \
45 "moveq %0, $0; " \
46 "ldrne %0, [fp, $-4]; " \
47 "ldrne %1, [fp, $-12]; " \
48 "movnes %1, %1; " \
49 "ldrne %1, [%1, $-4]; " \
50 : "=g" (selfpc), "=g" (frompc) \
51 : : "cc" \
52 ); \
53 if (selfpc) \
54 mcount_internal(frompc, selfpc); \