1/* Copyright (C) 2015-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#include <bits/wordsize.h>
19#include <kernel-features.h>
20
21/* By default only shared builds use vdso. */
22#ifndef ALWAYS_USE_VSYSCALL
23#define ALWAYS_USE_VSYSCALL 0
24#endif
25
26#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL)
27
28/* Set error number and return -1. A target may choose to return the
29 internal function, __syscall_error, which sets errno and returns -1.
30 We use -1l, instead of -1, so that it can be casted to (void *). */
31#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \
32 ({ \
33 __set_errno (err); \
34 -1l; \
35 })
36
37/* Provide a dummy argument that can be used to force register
38 alignment for register pairs if required by the syscall ABI. */
39#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
40#define __ALIGNMENT_ARG 0,
41#define __ALIGNMENT_COUNT(a,b) b
42#else
43#define __ALIGNMENT_ARG
44#define __ALIGNMENT_COUNT(a,b) a
45#endif
46
47/* Provide a common macro to pass 64-bit value on syscalls. */
48#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
49# define SYSCALL_LL(val) (val)
50# define SYSCALL_LL64(val) (val)
51#else
52#define SYSCALL_LL(val) \
53 __LONG_LONG_PAIR ((val) >> 31, (val))
54#define SYSCALL_LL64(val) \
55 __LONG_LONG_PAIR ((long) ((val) >> 32), (long) ((val) & 0xffffffff))
56#endif
57
58/* Provide a common macro to pass 64-bit value on pread and pwrite
59 syscalls. */
60#ifdef __ASSUME_PRW_DUMMY_ARG
61# define SYSCALL_LL_PRW(val) 0, SYSCALL_LL (val)
62# define SYSCALL_LL64_PRW(val) 0, SYSCALL_LL64 (val)
63#else
64# define SYSCALL_LL_PRW(val) __ALIGNMENT_ARG SYSCALL_LL (val)
65# define SYSCALL_LL64_PRW(val) __ALIGNMENT_ARG SYSCALL_LL64 (val)
66#endif
67
68/* Provide a macro to pass the off{64}_t argument on p{readv,writev}{64}. */
69#define LO_HI_LONG(val) \
70 (long) (val), \
71 (long) (((uint64_t) (val)) >> 32)
72
73/* Exports the __send symbol on send.c linux implementation (some ABI have
74 it missing due the usage of a old generic version without it). */
75#define HAVE_INTERNAL_SEND_SYMBOL 1
76