1/* Copyright (C) 2015-2018 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/* Set error number and return -1. A target may choose to return the
22 internal function, __syscall_error, which sets errno and returns -1.
23 We use -1l, instead of -1, so that it can be casted to (void *). */
24#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \
25 ({ \
26 __set_errno (err); \
27 -1l; \
28 })
29
30/* Provide a dummy argument that can be used to force register
31 alignment for register pairs if required by the syscall ABI. */
32#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
33#define __ALIGNMENT_ARG 0,
34#define __ALIGNMENT_COUNT(a,b) b
35#else
36#define __ALIGNMENT_ARG
37#define __ALIGNMENT_COUNT(a,b) a
38#endif
39
40/* Provide a common macro to pass 64-bit value on syscalls. */
41#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
42# define SYSCALL_LL(val) (val)
43# define SYSCALL_LL64(val) (val)
44#else
45#define SYSCALL_LL(val) \
46 __LONG_LONG_PAIR ((val) >> 31, (val))
47#define SYSCALL_LL64(val) \
48 __LONG_LONG_PAIR ((long) ((val) >> 32), (long) ((val) & 0xffffffff))
49#endif
50
51/* Provide a common macro to pass 64-bit value on pread and pwrite
52 syscalls. */
53#ifdef __ASSUME_PRW_DUMMY_ARG
54# define SYSCALL_LL_PRW(val) 0, SYSCALL_LL (val)
55# define SYSCALL_LL64_PRW(val) 0, SYSCALL_LL64 (val)
56#else
57# define SYSCALL_LL_PRW(val) __ALIGNMENT_ARG SYSCALL_LL (val)
58# define SYSCALL_LL64_PRW(val) __ALIGNMENT_ARG SYSCALL_LL64 (val)
59#endif
60
61/* Provide a macro to pass the off{64}_t argument on p{readv,writev}{64}. */
62#define LO_HI_LONG(val) \
63 (long) (val), \
64 (long) (((uint64_t) (val)) >> 32)
65
66/* Exports the __send symbol on send.c linux implementation (some ABI have
67 it missing due the usage of a old generic version without it). */
68#define HAVE_INTERNAL_SEND_SYMBOL 1
69