| 1 | /* Copyright (C) 2015-2016 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 macro to pass the off{64}_t argument on p{readv,writev}{64}.  */ | 
|---|
| 52 | #define LO_HI_LONG(val) \ | 
|---|
| 53 | (long) (val), \ | 
|---|
| 54 | (long) (((uint64_t) (val)) >> 32) | 
|---|
| 55 |  | 
|---|