1 | /* vDSO common definition for Linux. |
2 | Copyright (C) 2015-2020 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #ifndef SYSDEP_VDSO_LINUX_H |
20 | # define SYSDEP_VDSO_LINUX_H |
21 | |
22 | #include <ldsodefs.h> |
23 | |
24 | #ifndef INTERNAL_VSYSCALL_CALL |
25 | # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ |
26 | funcptr (args) |
27 | #endif |
28 | |
29 | #define INLINE_VSYSCALL(name, nr, args...) \ |
30 | ({ \ |
31 | __label__ out; \ |
32 | __label__ iserr; \ |
33 | INTERNAL_SYSCALL_DECL (sc_err); \ |
34 | long int sc_ret; \ |
35 | \ |
36 | __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ |
37 | if (vdsop != NULL) \ |
38 | { \ |
39 | sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, sc_err, nr, ##args); \ |
40 | if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ |
41 | goto out; \ |
42 | if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ |
43 | goto iserr; \ |
44 | } \ |
45 | \ |
46 | sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ |
47 | if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ |
48 | { \ |
49 | iserr: \ |
50 | __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ |
51 | sc_ret = -1L; \ |
52 | } \ |
53 | out: \ |
54 | sc_ret; \ |
55 | }) |
56 | |
57 | #endif /* SYSDEP_VDSO_LINUX_H */ |
58 | |