Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembler macros for m68k.
00002    Copyright (C) 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 #ifdef __ASSEMBLER__
00023 
00024 /* Syntactic details of assembler.  */
00025 
00026 # ifdef HAVE_ELF
00027 
00028 /* ELF uses byte-counts for .align, most others use log2 of count of bytes.  */
00029 #  define ALIGNARG(log2) 1<<log2
00030 /* For ELF we need the `.type' directive to make shared libs work right.  */
00031 #  define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
00032 #  define ASM_SIZE_DIRECTIVE(name) .size name,.-name
00033 
00034 /* In ELF C symbols are asm symbols.  */
00035 #  undef NO_UNDERSCORES
00036 #  define NO_UNDERSCORES
00037 
00038 # else
00039 
00040 #  define ALIGNARG(log2) log2
00041 #  define ASM_TYPE_DIRECTIVE(name,type)   /* Nothing is specified.  */
00042 #  define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified.  */
00043 
00044 # endif
00045 
00046 
00047 /* Define an entry point visible from C.
00048 
00049    There is currently a bug in gdb which prevents us from specifying
00050    incomplete stabs information.  Fake some entries here which specify
00051    the current source file.  */
00052 # define ENTRY(name)                                                 \
00053   .globl C_SYMBOL_NAME(name);                                               \
00054   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function);                       \
00055   .align ALIGNARG(2);                                                       \
00056   C_LABEL(name)                                                             \
00057   CALL_MCOUNT
00058 
00059 # undef END
00060 # define END(name) ASM_SIZE_DIRECTIVE(name)
00061 
00062 
00063 /* If compiled for profiling, call `_mcount' at the start of each function.  */
00064 # ifdef       PROF
00065 /* The mcount code relies on a normal frame pointer being on the stack
00066    to locate our caller, so push one just for its benefit.  */
00067 #  define CALL_MCOUNT \
00068   move.l %fp, -(%sp); move.l %sp, %fp;                                      \
00069   jbsr JUMPTARGET (mcount);                                          \
00070   move.l (%sp)+, %fp;
00071 # else
00072 #  define CALL_MCOUNT              /* Do nothing.  */
00073 # endif
00074 
00075 # ifdef       NO_UNDERSCORES
00076 /* Since C identifiers are not normally prefixed with an underscore
00077    on this system, the asm identifier `syscall_error' intrudes on the
00078    C name space.  Make sure we use an innocuous name.  */
00079 #  define syscall_error     __syscall_error
00080 #  define mcount     _mcount
00081 # endif
00082 
00083 # define PSEUDO(name, syscall_name, args)                            \
00084   .globl syscall_error;                                                     \
00085   ENTRY (name)                                                              \
00086     DO_CALL (syscall_name, args);                                    \
00087     jcc JUMPTARGET(syscall_error)
00088 
00089 # undef PSEUDO_END
00090 # define PSEUDO_END(name)                                            \
00091   END (name)
00092 
00093 # undef JUMPTARGET
00094 # ifdef PIC
00095 #  define JUMPTARGET(name)  name##@PLTPC
00096 # else
00097 #  define JUMPTARGET(name)  name
00098 # endif
00099 
00100 /* Perform operation OP with PC-relative SRC as the first operand and
00101    DST as the second.  TMP is available as a temporary if needed.  */
00102 #ifdef __mcoldfire__
00103 #define PCREL_OP(OP, SRC, DST, TMP) \
00104   move.l &SRC - ., TMP; OP (-8, %pc, TMP), DST
00105 #else
00106 #define PCREL_OP(OP, SRC, DST, TMP) \
00107   OP SRC(%pc), DST
00108 #endif
00109 
00110 #else
00111 
00112 /* As above, but PC is the spelling of the PC register.  We need this
00113    so that the macro can be used in both normal and extended asms.  */
00114 #ifdef __mcoldfire__
00115 #define PCREL_OP(OP, SRC, DST, TMP, PC) \
00116   "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
00117 #else
00118 #define PCREL_OP(OP, SRC, DST, TMP, PC) \
00119   OP " " SRC "(" PC "), " DST
00120 #endif
00121 
00122 #endif /* __ASSEMBLER__ */