Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembler macros for 64 bit S/390.
00002    Copyright (C) 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   lgr 0,14 ; larl 1,0f ; brasl 14,_mcount@PLT ; lgr 14,0 ; \
00067   .data ; .align 4 ; 0: .long 0 ; .text ;
00068 #else
00069 #define CALL_MCOUNT \
00070   lgr 0,14 ; larl 1,0f ; brasl 14,_mcount ; lgr 14,0 ; \
00071   .data ; .align 4 ; 0: .long 0 ; .text ;
00072 #endif
00073 #else
00074 #define CALL_MCOUNT         /* Do nothing.  */
00075 #endif
00076 
00077 #ifdef NO_UNDERSCORES
00078 /* Since C identifiers are not normally prefixed with an underscore
00079    on this system, the asm identifier `syscall_error' intrudes on the
00080    C name space.  Make sure we use an innocuous name.  */
00081 #define       syscall_error __syscall_error
00082 #define mcount              _mcount
00083 #endif
00084 
00085 #define       PSEUDO(name, syscall_name, args) \
00086 lose: SYSCALL_PIC_SETUP                   \
00087   jg JUMPTARGET(syscall_error);           \
00088   .globl syscall_error;                   \
00089   ENTRY (name)                            \
00090   DO_CALL (syscall_name, args);           \
00091   jm lose
00092 
00093 #undef PSEUDO_END
00094 #define       PSEUDO_END(name)                                              \
00095   END (name)
00096 
00097 #undef JUMPTARGET
00098 #ifdef PIC
00099 #define JUMPTARGET(name)    name##@PLT
00100 #define SYSCALL_PIC_SETUP \
00101     larl  %r12,_GLOBAL_OFFSET_TABLE_
00102 #else
00103 #define JUMPTARGET(name)    name
00104 #define SYSCALL_PIC_SETUP   /* Nothing.  */
00105 #endif
00106 
00107 /* Local label name for asm code. */
00108 #ifndef L
00109 #define L(name)             .L##name
00110 #endif
00111 
00112 #endif /* __ASSEMBLER__ */