| 1 | /* Read a directory in reentrant mode. Linux LFS version. |
| 2 | Copyright (C) 1997-2020 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <https://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | /* When _DIRENT_MATCHES_DIRENT64 is defined we can alias 'readdir64' to |
| 20 | 'readdir'. However the function signatures are not equal due |
| 21 | different return types, so we need to suppress {__}readdir so weak |
| 22 | and strong alias do not throw conflicting types errors. */ |
| 23 | #define readdir_r __no_readdir_r_decl |
| 24 | #define __readdir_r __no___readdir_r_decl |
| 25 | #include <dirent.h> |
| 26 | |
| 27 | #define __READDIR_R __readdir64_r |
| 28 | #define __GETDENTS __getdents64 |
| 29 | #define DIRENT_TYPE struct dirent64 |
| 30 | |
| 31 | #include <sysdeps/posix/readdir_r.c> |
| 32 | |
| 33 | #undef __readdir_r |
| 34 | #undef readdir_r |
| 35 | |
| 36 | #if _DIRENT_MATCHES_DIRENT64 |
| 37 | strong_alias (__readdir64_r, __readdir_r) |
| 38 | weak_alias (__readdir64_r, readdir_r) |
| 39 | weak_alias (__readdir64_r, readdir64_r) |
| 40 | #else |
| 41 | /* The compat code expects the 'struct direct' with d_ino being a __ino_t |
| 42 | instead of __ino64_t. */ |
| 43 | # include <shlib-compat.h> |
| 44 | versioned_symbol (libc, __readdir64_r, readdir64_r, GLIBC_2_2); |
| 45 | # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) |
| 46 | # include <olddirent.h> |
| 47 | # define __READDIR_R attribute_compat_text_section __old_readdir64_r |
| 48 | # define __GETDENTS __old_getdents64 |
| 49 | # define DIRENT_TYPE struct __old_dirent64 |
| 50 | # include <sysdeps/posix/readdir_r.c> |
| 51 | compat_symbol (libc, __old_readdir64_r, readdir64_r, GLIBC_2_1); |
| 52 | # endif /* SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) */ |
| 53 | #endif /* _DIRENT_MATCHES_DIRENT64 */ |
| 54 | |