1/* $NetBSD: SYS.h,v 1.19 2009/12/14 01:07:41 matt Exp $ */ 2/* $FreeBSD: head/lib/libc/mips/SYS.h 209231 2010-06-16 12:55:14Z jchandra $ */ |
3 4/*- 5 * Copyright (c) 1996 Jonathan Stone 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 63 unchanged lines hidden (view full) --- 74 * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops. 75 * 76 * i) Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after. 77 * ii) Do interprocedure jumps indirectly via t9, with the side-effect of 78 * preserving the callee's entry address in t9. 79 */ 80#ifdef __ABICALLS__ 81 .abicalls |
82# if defined(__mips_o32) || defined(__mips_o64) 83# define PIC_PROLOGUE(x) SETUP_GP 84# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); jr t9 85# define PIC_RETURN() j ra 86# else 87# define PIC_PROLOGUE(x) SETUP_GP64(t3, x) 88# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); RESTORE_GP64; jr t9 89# define PIC_RETURN() RESTORE_GP64; j ra 90# endif |
91#else |
92# define PIC_PROLOGUE(x) 93# define PIC_TAILCALL(l) j _C_LABEL(l) 94# define PIC_RETURN() 95#endif /* __ABICALLS__ */ |
96 |
97# define SYSTRAP(x) li v0,SYS_ ## x; syscall; |
98 99/* 100 * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id) 101 */ 102#define RSYSCALL_NOERROR(x) \ 103 PSEUDO_NOERROR(x) 104 105/* 106 * Do a normal syscall. 107 */ 108#define RSYSCALL(x) \ 109 PSEUDO(x) 110 111/* 112 * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint 113 * and syscall name are not the same. 114 */ 115#define PSEUDO_NOERROR(x) \ 116LEAF(__sys_ ## x); \ |
117 .weak _C_LABEL(x); \ |
118 _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ 119 .weak _C_LABEL(__CONCAT(_,x)); \ 120 _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ 121 SYSTRAP(x); \ 122 j ra; \ 123 END(__sys_ ## x) 124 125#define PSEUDO(x) \ 126LEAF(__sys_ ## x); \ |
127 .weak _C_LABEL(x); \ |
128 _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ 129 .weak _C_LABEL(__CONCAT(_,x)); \ 130 _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ |
131 PIC_PROLOGUE(__sys_ ## x); \ |
132 SYSTRAP(x); \ 133 bne a3,zero,err; \ |
134 PIC_RETURN(); \ |
135err: \ |
136 PIC_TAILCALL(__cerror); \ 137END(__sys_ ## x) |