aio_error.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Return error status of asynchronous I/O request.
  2. Copyright (C) 1997-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. /* We use an UGLY hack to prevent gcc from finding us cheating. The
  16. implementation of aio_error and aio_error64 are identical and so
  17. we want to avoid code duplication by using aliases. But gcc sees
  18. the different parameter lists and prints a warning. We define here
  19. a function so that aio_error64 has no prototype. */
  20. #define aio_error64 XXX
  21. #include <aio.h>
  22. /* And undo the hack. */
  23. #undef aio_error64
  24. #include <aio_misc.h>
  25. #include <pthreadP.h>
  26. #include <shlib-compat.h>
  27. int
  28. __aio_error (const struct aiocb *aiocbp)
  29. {
  30. int ret;
  31. /* Acquire the mutex to make sure all operations for this request are
  32. complete. */
  33. __pthread_mutex_lock (&__aio_requests_mutex);
  34. ret = aiocbp->__error_code;
  35. __pthread_mutex_unlock (&__aio_requests_mutex);
  36. return ret;
  37. }
  38. #if PTHREAD_IN_LIBC
  39. versioned_symbol (libc, __aio_error, aio_error, GLIBC_2_34);
  40. versioned_symbol (libc, __aio_error, aio_error64, GLIBC_2_34);
  41. # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_34)
  42. compat_symbol (librt, __aio_error, aio_error, GLIBC_2_1);
  43. compat_symbol (librt, __aio_error, aio_error64, GLIBC_2_1);
  44. # endif
  45. #else /* !PTHREAD_IN_LIBC */
  46. strong_alias (__aio_error, aio_error)
  47. weak_alias (__aio_error, aio_error64)
  48. #endif /* !PTHREAD_IN_LIBC */