Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembly macros for 32-bit PowerPC.
00002    Copyright (C) 1999, 2001, 2002, 2003, 2006 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., 51 Franklin Street, Fifth Floor, Boston MA
00018    02110-1301 USA.  */
00019 
00020 #include <sysdeps/powerpc/sysdep.h>
00021 
00022 #ifdef __ASSEMBLER__
00023 
00024 #ifdef __ELF__
00025 
00026 /* If compiled for profiling, call `_mcount' at the start of each
00027    function.  */
00028 #ifdef PROF
00029 /* The mcount code relies on a the return address being on the stack
00030    to locate our caller and so it can restore it; so store one just
00031    for its benefit.  */
00032 # define CALL_MCOUNT                                                 \
00033   mflr  r0;                                                          \
00034   stw   r0,4(r1);                                                    \
00035   cfi_offset (lr, 4);                                                              \
00036   bl    JUMPTARGET(_mcount);
00037 #else  /* PROF */
00038 # define CALL_MCOUNT        /* Do nothing.  */
00039 #endif /* PROF */
00040 
00041 #define       ENTRY(name)                                                   \
00042   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                 \
00043   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                        \
00044   .align ALIGNARG(2);                                                       \
00045   C_LABEL(name)                                                             \
00046   cfi_startproc;                                                     \
00047   CALL_MCOUNT
00048 
00049 #define EALIGN_W_0  /* No words to insert.  */
00050 #define EALIGN_W_1  nop
00051 #define EALIGN_W_2  nop;nop
00052 #define EALIGN_W_3  nop;nop;nop
00053 #define EALIGN_W_4  EALIGN_W_3;nop
00054 #define EALIGN_W_5  EALIGN_W_4;nop
00055 #define EALIGN_W_6  EALIGN_W_5;nop
00056 #define EALIGN_W_7  EALIGN_W_6;nop
00057 
00058 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
00059    past a 2^align boundary.  */
00060 #ifdef PROF
00061 # define EALIGN(name, alignt, words)                                        \
00062   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                 \
00063   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                        \
00064   .align ALIGNARG(2);                                                       \
00065   C_LABEL(name)                                                             \
00066   cfi_startproc;                                                     \
00067   CALL_MCOUNT                                                        \
00068   b 0f;                                                                     \
00069   .align ALIGNARG(alignt);                                           \
00070   EALIGN_W_##words;                                                  \
00071   0:
00072 #else /* PROF */
00073 # define EALIGN(name, alignt, words)                                        \
00074   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                 \
00075   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                        \
00076   .align ALIGNARG(alignt);                                           \
00077   EALIGN_W_##words;                                                  \
00078   C_LABEL(name)                                                             \
00079   cfi_startproc;
00080 #endif
00081 
00082 #undef END
00083 #define END(name)                                                    \
00084   cfi_endproc;                                                              \
00085   ASM_SIZE_DIRECTIVE(name)
00086 
00087 #define DO_CALL(syscall)                                             \
00088     li 0,syscall;                                                     \
00089     sc
00090 
00091 #undef JUMPTARGET
00092 #ifdef PIC
00093 # define JUMPTARGET(name) name##@plt
00094 #else
00095 # define JUMPTARGET(name) name
00096 #endif
00097 
00098 #if defined SHARED && defined DO_VERSIONING && defined PIC \
00099     && !defined NO_HIDDEN
00100 # undef HIDDEN_JUMPTARGET
00101 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
00102 #endif
00103 
00104 #define PSEUDO(name, syscall_name, args)                             \
00105   .section ".text";                                                  \
00106   ENTRY (name)                                                              \
00107     DO_CALL (SYS_ify (syscall_name));
00108 
00109 #define PSEUDO_RET                                                   \
00110     bnslr+;                                                          \
00111     b __syscall_error@local
00112 #define ret PSEUDO_RET
00113 
00114 #undef PSEUDO_END
00115 #define       PSEUDO_END(name)                                              \
00116   END (name)
00117 
00118 #define PSEUDO_NOERRNO(name, syscall_name, args)                     \
00119   .section ".text";                                                  \
00120   ENTRY (name)                                                              \
00121     DO_CALL (SYS_ify (syscall_name));
00122 
00123 #define PSEUDO_RET_NOERRNO                                           \
00124     blr
00125 #define ret_NOERRNO PSEUDO_RET_NOERRNO
00126 
00127 #undef PSEUDO_END_NOERRNO
00128 #define       PSEUDO_END_NOERRNO(name)                                      \
00129   END (name)
00130 
00131 #define PSEUDO_ERRVAL(name, syscall_name, args)                             \
00132   .section ".text";                                                  \
00133   ENTRY (name)                                                              \
00134     DO_CALL (SYS_ify (syscall_name));
00135 
00136 #define PSEUDO_RET_ERRVAL                                            \
00137     blr
00138 #define ret_ERRVAL PSEUDO_RET_ERRVAL
00139 
00140 #undef PSEUDO_END_ERRVAL
00141 #define       PSEUDO_END_ERRVAL(name)                                              \
00142   END (name)
00143 
00144 /* Local labels stripped out by the linker.  */
00145 #undef L
00146 #define L(x) .L##x
00147 
00148 /* Label in text section.  */
00149 #define C_TEXT(name) name
00150 
00151 #endif /* __ELF__ */
00152 
00153 #endif /* __ASSEMBLER__ */