SYS.h (178580) | SYS.h (209231) |
---|---|
1/* $NetBSD: SYS.h,v 1.18 2003/10/29 12:28:33 pooka Exp $ */ 2/* $FreeBSD: head/lib/libc/mips/SYS.h 178580 2008-04-26 12:08:02Z imp $ */ | 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 | 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# define PIC_PROLOGUE(x,sr) .set noreorder; .cpload sr; .set reorder 83# define PIC_CALL(l,sr) la sr, _C_LABEL(l); jr sr | 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 |
84#else | 91#else |
85# define PIC_PROLOGUE(x,sr) 86# define PIC_CALL(l,sr) j _C_LABEL(l) 87#endif | 92# define PIC_PROLOGUE(x) 93# define PIC_TAILCALL(l) j _C_LABEL(l) 94# define PIC_RETURN() 95#endif /* __ABICALLS__ */ |
88 | 96 |
89# define SYSTRAP(x) li v0, SYS_ ## x; syscall; | 97# define SYSTRAP(x) li v0,SYS_ ## x; syscall; |
90 91/* 92 * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id) 93 */ 94#define RSYSCALL_NOERROR(x) \ 95 PSEUDO_NOERROR(x) 96 97/* 98 * Do a normal syscall. 99 */ 100#define RSYSCALL(x) \ 101 PSEUDO(x) 102 103/* 104 * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint 105 * and syscall name are not the same. 106 */ 107#define PSEUDO_NOERROR(x) \ 108LEAF(__sys_ ## x); \ | 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); \ |
109 .weak _C_LABEL(x); \ | 117 .weak _C_LABEL(x); \ |
110 _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ 111 .weak _C_LABEL(__CONCAT(_,x)); \ 112 _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \ 113 SYSTRAP(x); \ 114 j ra; \ 115 END(__sys_ ## x) 116 117#define PSEUDO(x) \ 118LEAF(__sys_ ## 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); \ |
119 .weak _C_LABEL(x); \ | 127 .weak _C_LABEL(x); \ |
120 _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \ 121 .weak _C_LABEL(__CONCAT(_,x)); \ 122 _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,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)); \ |
123 PIC_PROLOGUE(x,t9); \ | 131 PIC_PROLOGUE(__sys_ ## x); \ |
124 SYSTRAP(x); \ 125 bne a3,zero,err; \ | 132 SYSTRAP(x); \ 133 bne a3,zero,err; \ |
126 j ra; \ | 134 PIC_RETURN(); \ |
127err: \ | 135err: \ |
128 PIC_CALL(__cerror,t9); \ 129 END(__sys_ ## x) | 136 PIC_TAILCALL(__cerror); \ 137END(__sys_ ## x) |