Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembler macros for s390.
00002    Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
00003    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <sysdeps/generic/sysdep.h>
00022 
00023 #ifdef __ASSEMBLER__
00024 
00025 /* Syntactic details of assembler.  */
00026 
00027 #ifdef HAVE_ELF
00028 
00029 /* ELF uses byte-counts for .align, most others use log2 of count of bytes.  */
00030 #define ALIGNARG(log2) 1<<log2
00031 /* For ELF we need the `.type' directive to make shared libs work right.  */
00032 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
00033 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
00034 
00035 /* In ELF C symbols are asm symbols.  */
00036 #undef NO_UNDERSCORES
00037 #define NO_UNDERSCORES
00038 
00039 #else
00040 
00041 #define ALIGNARG(log2) log2
00042 #define ASM_TYPE_DIRECTIVE(name,type)     /* Nothing is specified.  */
00043 #define ASM_SIZE_DIRECTIVE(name)   /* Nothing is specified.  */
00044 
00045 #endif
00046 
00047 
00048 /* Define an entry point visible from C. */
00049 #define       ENTRY(name)                                                   \
00050   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                 \
00051   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                        \
00052   .align ALIGNARG(2);                                                       \
00053   C_LABEL(name)                                                             \
00054   cfi_startproc;                                                     \
00055   CALL_MCOUNT
00056 
00057 #undef END
00058 #define END(name)                                                    \
00059   cfi_endproc;                                                              \
00060   ASM_SIZE_DIRECTIVE(name)                                           \
00061 
00062 /* If compiled for profiling, call `mcount' at the start of each function.  */
00063 #ifdef PROF
00064 #ifdef PIC
00065 #define CALL_MCOUNT \
00066   lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \
00067   lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \
00068   basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ;
00069 #else
00070 #define CALL_MCOUNT \
00071   lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \
00072   l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \
00073   .data ; .align 4 ; 0: .long 0 ; .text ;
00074 #endif
00075 #else
00076 #define CALL_MCOUNT         /* Do nothing.  */
00077 #endif
00078 
00079 #ifdef NO_UNDERSCORES
00080 /* Since C identifiers are not normally prefixed with an underscore
00081    on this system, the asm identifier `syscall_error' intrudes on the
00082    C name space.  Make sure we use an innocuous name.  */
00083 #define       syscall_error __syscall_error
00084 #define mcount              _mcount
00085 #endif
00086 
00087 #define       PSEUDO(name, syscall_name, args) \
00088 lose: SYSCALL_PIC_SETUP                          \
00089     basr %r1,0;                                  \
00090 0:  al %r1,1f-0b(%r1);                           \
00091     br %r1;                               \
00092 1:  .long JUMPTARGET(syscall_error) - 0b; \
00093     .globl syscall_error;                 \
00094     ENTRY (name)                          \
00095     DO_CALL (syscall_name, args);         \
00096     jm lose
00097 
00098 #undef PSEUDO_END
00099 #define       PSEUDO_END(name)                                              \
00100   END (name)
00101 
00102 #undef JUMPTARGET
00103 #ifdef PIC
00104 #define JUMPTARGET(name)    name##@PLT
00105 #define SYSCALL_PIC_SETUP             \
00106     bras  %r12,1f                     \
00107 0:  .long _GLOBAL_OFFSET_TABLE_-0b    \
00108 1:  al    %r12,0(%r12)
00109 #else
00110 #define JUMPTARGET(name)    name
00111 #define SYSCALL_PIC_SETUP   /* Nothing.  */
00112 #endif
00113 
00114 /* Local label name for asm code. */
00115 #ifndef L
00116 #define L(name)             .L##name
00117 #endif
00118 
00119 #endif /* __ASSEMBLER__ */