sysdep.h 2.7 KB

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