More NEWS entries / fixes for float_t / double_t changes.
[glibc.git] / sysdeps / aarch64 / sysdep.h
blobe0457593fc7690733a3a0f32bbb59a1377102942
1 /* Copyright (C) 1997-2016 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 Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
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/>. */
19 #include <sysdeps/generic/sysdep.h>
21 #ifdef __ASSEMBLER__
23 /* Syntactic details of assembler. */
25 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
27 /* Define an entry point visible from C. */
28 #define ENTRY(name) \
29 .globl C_SYMBOL_NAME(name); \
30 .type C_SYMBOL_NAME(name),%function; \
31 .align 4; \
32 C_LABEL(name) \
33 cfi_startproc; \
34 CALL_MCOUNT
36 /* Define an entry point visible from C. */
37 #define ENTRY_ALIGN(name, align) \
38 .globl C_SYMBOL_NAME(name); \
39 .type C_SYMBOL_NAME(name),%function; \
40 .p2align align; \
41 C_LABEL(name) \
42 cfi_startproc; \
43 CALL_MCOUNT
45 /* Define an entry point visible from C with a specified alignment and
46 pre-padding with NOPs. This can be used to ensure that a critical
47 loop within a function is cache line aligned. Note this version
48 does not adjust the padding if CALL_MCOUNT is defined. */
50 #define ENTRY_ALIGN_AND_PAD(name, align, padding) \
51 .globl C_SYMBOL_NAME(name); \
52 .type C_SYMBOL_NAME(name),%function; \
53 .p2align align; \
54 .rep padding; \
55 nop; \
56 .endr; \
57 C_LABEL(name) \
58 cfi_startproc; \
59 CALL_MCOUNT
61 #undef END
62 #define END(name) \
63 cfi_endproc; \
64 ASM_SIZE_DIRECTIVE(name)
66 /* If compiled for profiling, call `mcount' at the start of each function. */
67 #ifdef PROF
68 # define CALL_MCOUNT \
69 str x30, [sp, #-80]!; \
70 cfi_adjust_cfa_offset (80); \
71 cfi_rel_offset (x30, 0); \
72 stp x0, x1, [sp, #16]; \
73 cfi_rel_offset (x0, 16); \
74 cfi_rel_offset (x1, 24); \
75 stp x2, x3, [sp, #32]; \
76 cfi_rel_offset (x2, 32); \
77 cfi_rel_offset (x3, 40); \
78 stp x4, x5, [sp, #48]; \
79 cfi_rel_offset (x4, 48); \
80 cfi_rel_offset (x5, 56); \
81 stp x6, x7, [sp, #64]; \
82 cfi_rel_offset (x6, 64); \
83 cfi_rel_offset (x7, 72); \
84 mov x0, x30; \
85 bl mcount; \
86 ldp x0, x1, [sp, #16]; \
87 cfi_restore (x0); \
88 cfi_restore (x1); \
89 ldp x2, x3, [sp, #32]; \
90 cfi_restore (x2); \
91 cfi_restore (x3); \
92 ldp x4, x5, [sp, #48]; \
93 cfi_restore (x4); \
94 cfi_restore (x5); \
95 ldp x6, x7, [sp, #64]; \
96 cfi_restore (x6); \
97 cfi_restore (x7); \
98 ldr x30, [sp], #80; \
99 cfi_adjust_cfa_offset (-80); \
100 cfi_restore (x30);
101 #else
102 # define CALL_MCOUNT /* Do nothing. */
103 #endif
105 /* Local label name for asm code. */
106 #ifndef L
107 # define L(name) .L##name
108 #endif
110 /* Load or store to/from a pc-relative EXPR into/from R, using T. */
111 #define LDST_PCREL(OP, R, T, EXPR) \
112 adrp T, EXPR; \
113 OP R, [T, #:lo12:EXPR];\
115 /* Load or store to/from a got-relative EXPR into/from R, using T. */
116 #define LDST_GLOBAL(OP, R, T, EXPR) \
117 adrp T, :got:EXPR; \
118 ldr T, [T, #:got_lo12:EXPR];\
119 OP R, [T];
121 /* Since C identifiers are not normally prefixed with an underscore
122 on this system, the asm identifier `syscall_error' intrudes on the
123 C name space. Make sure we use an innocuous name. */
124 #define syscall_error __syscall_error
125 #define mcount _mcount
127 #endif /* __ASSEMBLER__ */