Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

negated_errno.h 730B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2017-2018 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #ifndef STRACE_NEGATED_ERRNO_H
  9. # define STRACE_NEGATED_ERRNO_H
  10. /*
  11. * Check the syscall return value register value for whether it is
  12. * a negated errno code indicating an error, or a success return value.
  13. */
  14. static inline bool
  15. is_negated_errno(kernel_ulong_t val)
  16. {
  17. kernel_ulong_t max = -(kernel_long_t) MAX_ERRNO_VALUE;
  18. # ifndef current_klongsize
  19. if (current_klongsize < sizeof(val)) {
  20. val = (uint32_t) val;
  21. max = (uint32_t) max;
  22. }
  23. # endif /* !current_klongsize */
  24. return val >= max;
  25. }
  26. #endif /* !STRACE_NEGATED_ERRNO_H */