readdir64_r.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Read a directory in reentrant mode. Linux LFS version.
  2. Copyright (C) 1997-2019 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. <http://www.gnu.org/licenses/>. */
  15. /* When _DIRENT_MATCHES_DIRENT64 is defined we can alias 'readdir64' to
  16. 'readdir'. However the function signatures are not equal due
  17. different return types, so we need to suppress {__}readdir so weak
  18. and strong alias do not throw conflicting types errors. */
  19. #define readdir_r __no_readdir_r_decl
  20. #define __readdir_r __no___readdir_r_decl
  21. #include <dirent.h>
  22. #define __READDIR_R __readdir64_r
  23. #define __GETDENTS __getdents64
  24. #define DIRENT_TYPE struct dirent64
  25. #include <sysdeps/posix/readdir_r.c>
  26. #undef __readdir_r
  27. #undef readdir_r
  28. #if _DIRENT_MATCHES_DIRENT64
  29. strong_alias (__readdir64_r, __readdir_r)
  30. weak_alias (__readdir64_r, readdir_r)
  31. weak_alias (__readdir64_r, readdir64_r)
  32. #else
  33. /* The compat code expects the 'struct direct' with d_ino being a __ino_t
  34. instead of __ino64_t. */
  35. # include <shlib-compat.h>
  36. versioned_symbol (libc, __readdir64_r, readdir64_r, GLIBC_2_2);
  37. # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
  38. # include <olddirent.h>
  39. # define __READDIR_R attribute_compat_text_section __old_readdir64_r
  40. # define __GETDENTS __old_getdents64
  41. # define DIRENT_TYPE struct __old_dirent64
  42. # include <sysdeps/posix/readdir_r.c>
  43. compat_symbol (libc, __old_readdir64_r, readdir64_r, GLIBC_2_1);
  44. # endif /* SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) */
  45. #endif /* _DIRENT_MATCHES_DIRENT64 */