1 | /* vDSO common definition for Linux. |
2 | Copyright (C) 2015-2019 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 | <http://www.gnu.org/licenses/>. */ |
18 | |
19 | #ifndef SYSDEP_VDSO_LINUX_H |
20 | # define SYSDEP_VDSO_LINUX_H |
21 | |
22 | #define VDSO_SYMBOL(__name) __vdso_##__name |
23 | |
24 | #ifndef INTERNAL_VSYSCALL_CALL |
25 | # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ |
26 | funcptr (args) |
27 | #endif |
28 | |
29 | #if USE_VSYSCALL && defined HAVE_VSYSCALL |
30 | |
31 | # include <libc-vdso.h> |
32 | |
33 | # define INLINE_VSYSCALL(name, nr, args...) \ |
34 | ({ \ |
35 | __label__ out; \ |
36 | __label__ iserr; \ |
37 | INTERNAL_SYSCALL_DECL (sc_err); \ |
38 | long int sc_ret; \ |
39 | \ |
40 | __typeof (__vdso_##name) vdsop = __vdso_##name; \ |
41 | PTR_DEMANGLE (vdsop); \ |
42 | if (vdsop != NULL) \ |
43 | { \ |
44 | sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, sc_err, nr, ##args); \ |
45 | if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ |
46 | goto out; \ |
47 | if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ |
48 | goto iserr; \ |
49 | } \ |
50 | \ |
51 | sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ |
52 | if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ |
53 | { \ |
54 | iserr: \ |
55 | __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ |
56 | sc_ret = -1L; \ |
57 | } \ |
58 | out: \ |
59 | sc_ret; \ |
60 | }) |
61 | |
62 | # define INTERNAL_VSYSCALL(name, err, nr, args...) \ |
63 | ({ \ |
64 | __label__ out; \ |
65 | long v_ret; \ |
66 | \ |
67 | __typeof (__vdso_##name) vdsop = __vdso_##name; \ |
68 | PTR_DEMANGLE (vdsop); \ |
69 | if (vdsop != NULL) \ |
70 | { \ |
71 | v_ret = INTERNAL_VSYSCALL_CALL (vdsop, err, nr, ##args); \ |
72 | if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ |
73 | || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ |
74 | goto out; \ |
75 | } \ |
76 | v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ |
77 | out: \ |
78 | v_ret; \ |
79 | }) |
80 | #else |
81 | |
82 | # define INLINE_VSYSCALL(name, nr, args...) \ |
83 | INLINE_SYSCALL (name, nr, ##args) |
84 | # define INTERNAL_VSYSCALL(name, err, nr, args...) \ |
85 | INTERNAL_SYSCALL (name, err, nr, ##args) |
86 | |
87 | #endif /* USE_VSYSCALL && defined HAVE_VSYSCALL */ |
88 | |
89 | #endif /* SYSDEP_VDSO_LINUX_H */ |
90 | |