Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / arm / sysdep.h
blob7800456f64e8016320154d1e1be7ab63aed0a041
1 /* Assembler macros for ARM.
2 Copyright (C) 1997, 1998, 2003, 2009, 2010, 2012
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sysdeps/generic/sysdep.h>
21 #include <features.h>
23 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
24 && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
25 # define __USE_BX__
26 #endif
28 #ifdef __ASSEMBLER__
30 /* Syntactic details of assembler. */
32 #define ALIGNARG(log2) log2
33 /* For ELF we need the `.type' directive to make shared libs work right. */
34 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
35 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
37 #define PLTJMP(_x) _x##(PLT)
39 /* APCS-32 doesn't preserve the condition codes across function call. */
40 #ifdef __APCS_32__
41 #define LOADREGS(cond, base, reglist...)\
42 ldm##cond base,reglist
43 #ifdef __USE_BX__
44 #define RETINSTR(cond, reg) \
45 bx##cond reg
46 #define DO_RET(_reg) \
47 bx _reg
48 #else
49 #define RETINSTR(cond, reg) \
50 mov##cond pc, reg
51 #define DO_RET(_reg) \
52 mov pc, _reg
53 #endif
54 #else /* APCS-26 */
55 #define LOADREGS(cond, base, reglist...)\
56 ldm##cond base,reglist^
57 #define RETINSTR(cond, reg) \
58 mov##cond##s pc, reg
59 #define DO_RET(_reg) \
60 movs pc, _reg
61 #endif
63 /* Define an entry point visible from C. */
64 #define ENTRY(name) \
65 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
66 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
67 .align ALIGNARG(4); \
68 C_LABEL(name) \
69 .cfi_sections .debug_frame; \
70 cfi_startproc; \
71 CALL_MCOUNT
73 #undef END
74 #define END(name) \
75 cfi_endproc; \
76 ASM_SIZE_DIRECTIVE(name)
78 /* If compiled for profiling, call `mcount' at the start of each function. */
79 #ifdef PROF
80 /* Call __gnu_mcount_nc if GCC >= 4.4. */
81 #if __GNUC_PREREQ(4,4)
82 #define CALL_MCOUNT \
83 str lr,[sp, #-4]!; \
84 cfi_adjust_cfa_offset (4); \
85 cfi_rel_offset (lr, 0); \
86 bl PLTJMP(mcount); \
87 cfi_adjust_cfa_offset (-4); \
88 cfi_restore (lr)
89 #else /* else call _mcount */
90 #define CALL_MCOUNT \
91 str lr,[sp, #-4]!; \
92 cfi_adjust_cfa_offset (4); \
93 cfi_rel_offset (lr, 0); \
94 bl PLTJMP(mcount); \
95 ldr lr, [sp], #4; \
96 cfi_adjust_cfa_offset (-4); \
97 cfi_restore (lr)
98 #endif
99 #else
100 #define CALL_MCOUNT /* Do nothing. */
101 #endif
103 /* Since C identifiers are not normally prefixed with an underscore
104 on this system, the asm identifier `syscall_error' intrudes on the
105 C name space. Make sure we use an innocuous name. */
106 #define syscall_error __syscall_error
107 #if __GNUC_PREREQ(4,4)
108 #define mcount __gnu_mcount_nc
109 #else
110 #define mcount _mcount
111 #endif
113 /* Tag_ABI_align8_preserved: This code preserves 8-byte
114 alignment in any callee. */
115 .eabi_attribute 25, 1
116 /* Tag_ABI_align8_needed: This code may require 8-byte alignment from
117 the caller. */
118 .eabi_attribute 24, 1
120 #endif /* __ASSEMBLER__ */