Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #define LOSE asm volatile ("1: b 1b")
00020 
00021 #define START_MACHDEP asm ("\
00022        .text\n\
00023        .globl _start\n\
00024        .ent _start\n\
00025 _start:\n\
00026        # Put initial SP in a0.\n\
00027        move $4, $29\n\
00028        # Jump to _start0; don't return.\n\
00029        j _start0\n\
00030        .end _start\n\
00031 ");
00032 #define START_ARGS   int *entry_sp
00033 #define SNARF_ARGS(argc, argv, envp)                                        \
00034   do                                                                 \
00035     {                                                                \
00036       register char **p;                                             \
00037                                                                      \
00038       argc = *entry_sp;                                                     \
00039       argv = (char **) (entry_sp + 1);                                      \
00040       p = argv;                                                             \
00041       while (*p++ != NULL)                                           \
00042        ;                                                             \
00043       if (p >= (char **) argv[0])                                    \
00044        --p;                                                          \
00045       envp = p;                                                      \
00046     } while (0)
00047 
00048 #define CALL_WITH_SP(fn, sp) \
00049   ({ register int __fn = fn, __sp = (int) sp; \
00050      asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));})
00051 
00052 #define RETURN_TO(sp, pc, retval) \
00053   asm volatile ("move $29, %0; move $2, %2; move $25, %1; jr $25" \
00054               : : "r" (sp), "r" (pc), "r" (retval))
00055 
00056 #define STACK_GROWTH_DOWN
00057 
00058 #include <syscall.h>
00059 
00060 #if defined (__ASSEMBLER__)
00061 
00062 #define ALIGN 2
00063 
00064 #define MOVE(x,y)    move y , x
00065 
00066 #define SYSCALL(name, args) \
00067   .globl syscall_error;     \
00068   kernel_trap(name,SYS_##name,args);      \
00069   beq $1,$0,1f;      \
00070   j syscall_error;   \
00071 1:
00072 
00073 #define SYSCALL__(name, args)      \
00074   .globl syscall_error;     \
00075   kernel_trap(__##name,SYS_##name,args);  \
00076   beq $1,$0,1f;      \
00077   j syscall_error;   \
00078 1:
00079 
00080 #define ret   j ra; nop
00081 #endif
00082 
00083 #include <sysdeps/mach/sysdep.h>