Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembler macros for ARM.
00002    Copyright (C) 1997, 1998, 2003 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 #include <sysdeps/generic/sysdep.h>
00021 
00022 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
00023      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
00024 # define __USE_BX__
00025 #endif
00026 
00027 #ifdef __ASSEMBLER__
00028 
00029 /* Syntactic details of assembler.  */
00030 
00031 #ifdef HAVE_ELF
00032 
00033 #define ALIGNARG(log2) log2
00034 /* For ELF we need the `.type' directive to make shared libs work right.  */
00035 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
00036 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
00037 
00038 /* In ELF C symbols are asm symbols.  */
00039 #undef NO_UNDERSCORES
00040 #define NO_UNDERSCORES
00041 
00042 #define PLTJMP(_x)   _x##(PLT)
00043 
00044 #else
00045 
00046 #define ALIGNARG(log2) log2
00047 #define ASM_TYPE_DIRECTIVE(name,type)     /* Nothing is specified.  */
00048 #define ASM_SIZE_DIRECTIVE(name)   /* Nothing is specified.  */
00049 
00050 #define PLTJMP(_x)   _x
00051 
00052 #endif
00053 
00054 /* APCS-32 doesn't preserve the condition codes across function call. */
00055 #ifdef __APCS_32__
00056 #define LOADREGS(cond, base, reglist...)\
00057        ldm##cond     base,reglist
00058 #ifdef __USE_BX__
00059 #define RETINSTR(cond, reg) \
00060        bx##cond      reg
00061 #define DO_RET(_reg)        \
00062        bx _reg
00063 #else
00064 #define RETINSTR(cond, reg) \
00065        mov##cond     pc, reg
00066 #define DO_RET(_reg)        \
00067        mov pc, _reg
00068 #endif
00069 #else  /* APCS-26 */
00070 #define LOADREGS(cond, base, reglist...)\
00071        ldm##cond     base,reglist^
00072 #define RETINSTR(cond, reg) \
00073        mov##cond##s  pc, reg
00074 #define DO_RET(_reg)        \
00075        movs pc, _reg
00076 #endif
00077 
00078 /* Define an entry point visible from C.  */
00079 #define       ENTRY(name)                                                   \
00080   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                 \
00081   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function)                         \
00082   .align ALIGNARG(4);                                                       \
00083   C_LABEL(name)                                                             \
00084   CALL_MCOUNT
00085 
00086 #undef END
00087 #define END(name)                                                    \
00088   ASM_SIZE_DIRECTIVE(name)
00089 
00090 /* If compiled for profiling, call `mcount' at the start of each function.  */
00091 #ifdef PROF
00092 #define CALL_MCOUNT                \
00093        str    lr,[sp, #-4]! ;      \
00094        bl     PLTJMP(mcount)       ;      \
00095        ldr    lr, [sp], #4  ;
00096 #else
00097 #define CALL_MCOUNT         /* Do nothing.  */
00098 #endif
00099 
00100 #ifdef NO_UNDERSCORES
00101 /* Since C identifiers are not normally prefixed with an underscore
00102    on this system, the asm identifier `syscall_error' intrudes on the
00103    C name space.  Make sure we use an innocuous name.  */
00104 #define       syscall_error __syscall_error
00105 #define mcount              _mcount
00106 #endif
00107 
00108 #endif /* __ASSEMBLER__ */