sysdep.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2026 Waldemar Brodkorb <wbx@uclibc-ng.org>
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. /* syscall error handlers
  6. Copyright (C) 2022-2026 Free Software Foundation, Inc.
  7. This file is part of the GNU C Library.
  8. The GNU C Library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 2.1 of the License, or (at your option) any later version.
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with the GNU C Library. If not, see
  18. <https://www.gnu.org/licenses/>. */
  19. #include <sys/asm.h>
  20. #define L(label) .L##label
  21. ENTRY (__syscall_error)
  22. /* Fall through to __syscall_set_errno */
  23. END (__syscall_error)
  24. /* Non-standard calling convention: argument in a0, return address in t0,
  25. and clobber only t1.
  26. */
  27. ENTRY (__syscall_set_errno)
  28. /* We got here because a0 < 0, but only codes in the range [-4095, -1]
  29. represent errors. Otherwise, just return the result normally.
  30. */
  31. LI t1, -4096
  32. bgeu t1, a0, L (out)
  33. sub.w a0, zero, a0
  34. st.w a0, t1, 0
  35. LI a0, -1
  36. L (out):
  37. ret
  38. END (__syscall_set_errno)