glibc/include/dirent.h
Adhemerval Zanella c0123b3b11 Consolidate scandir{at}{64} implementation
This patch consolidates scandir{at}{64} implementation on just
the default dirent/scandir{at}{64}{_r}.c ones.  It changes the logic
to follow the conventions used on other code consolidation:

  * scandir{at} is only built for _DIRENT_MATCHES_DIRENT64 being 0.

  * scandir{at}{64} is always built and aliased to getdents for ABIs
    that define _DIRENT_MATCHES_DIRENT64 to 1.

Also on Linux the compat symbol for old non-LFS dirent64 definition
requires a platform-specific scandir64.c.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and
powerpc64le-linux-gnu.

	* dirent/scandir-tail-common.c: New file.
	* dirent/scandir-tail.c: Use scandir-tail-common.c.
	(__scandir_tail): Build iff _DIRENT_MATCHES_DIRENT64 is not defined.
	* dirent/scandir.c: Use scandir-tail-common.c.
	* dirent/scandirat.c: Likewise.
	* dirent/scandir64-tail.c: Use scandir-tail-common.c.
	* dirent/scandir64.c (scandir64): Always build and alias to scandir
	if _DIRENT_MATCHES_DIRENT64 is defined.
	* dirent/scandirat64.c (scandirat64): Likewise.
	* include/dirent.h (__scandir_tail): Only define iff
	_DIRENT_MATCHES_DIRENT64 is not defined.
	(__scandir64_tail): Define regardless.
	(__scandirat, scandirat64): Remove libc_hidden_proto.
	* sysdeps/unix/sysv/linux/arm/scandir64.c: Remove file.
	* sysdeps/unix/sysv/linux/m68k/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/scandir64.c: Likewise.
	* sysdeps/unix/sysv/linux/scandir64.c: New file.
2018-04-20 13:57:12 -03:00

85 lines
2.8 KiB
C

#ifndef _DIRENT_H
# ifndef _ISOMAC
# include <dirstream.h>
# endif
# include <dirent/dirent.h>
# ifndef _ISOMAC
# include <sys/stat.h>
# include <stdbool.h>
struct scandir_cancel_struct
{
DIR *dp;
void *v;
size_t cnt;
};
/* Now define the internal interfaces. */
extern DIR *__opendir (const char *__name) attribute_hidden;
extern DIR *__opendirat (int dfd, const char *__name) attribute_hidden;
extern DIR *__fdopendir (int __fd) attribute_hidden;
extern int __closedir (DIR *__dirp) attribute_hidden;
extern struct dirent *__readdir (DIR *__dirp) attribute_hidden;
extern struct dirent64 *__readdir64 (DIR *__dirp);
libc_hidden_proto (__readdir64)
extern int __readdir_r (DIR *__dirp, struct dirent *__entry,
struct dirent **__result);
extern int __readdir64_r (DIR *__dirp, struct dirent64 *__entry,
struct dirent64 **__result);
extern int __scandir64 (const char * __dir,
struct dirent64 *** __namelist,
int (*__selector) (const struct dirent64 *),
int (*__cmp) (const struct dirent64 **,
const struct dirent64 **));
extern __ssize_t __getdirentries (int __fd, char *__restrict __buf,
size_t __nbytes,
__off_t *__restrict __basep)
__THROW __nonnull ((2, 4));
extern __ssize_t __getdents (int __fd, char *__buf, size_t __nbytes)
attribute_hidden;
extern __ssize_t __getdents64 (int __fd, char *__buf, size_t __nbytes)
attribute_hidden;
extern int __alphasort64 (const struct dirent64 **a, const struct dirent64 **b)
__attribute_pure__;
extern int __versionsort64 (const struct dirent64 **a,
const struct dirent64 **b)
__attribute_pure__;
extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
const struct stat64 *statp) attribute_hidden;
extern __typeof (rewinddir) __rewinddir;
extern __typeof (seekdir) __seekdir;
extern __typeof (dirfd) __dirfd;
libc_hidden_proto (dirfd);
extern void __scandir_cancel_handler (void *arg) attribute_hidden;
extern int __scandir_tail (DIR *dp,
struct dirent ***namelist,
int (*select) (const struct dirent *),
int (*cmp) (const struct dirent **,
const struct dirent **))
attribute_hidden;
# if !_DIRENT_MATCHES_DIRENT64
extern int __scandir_tail (DIR *dp,
struct dirent ***namelist,
int (*select) (const struct dirent *),
int (*cmp) (const struct dirent **,
const struct dirent **))
attribute_hidden;
# endif
extern int __scandir64_tail (DIR *dp,
struct dirent64 ***namelist,
int (*select) (const struct dirent64 *),
int (*cmp) (const struct dirent64 **,
const struct dirent64 **))
attribute_hidden;
libc_hidden_proto (__rewinddir)
extern __typeof (scandirat) __scandirat;
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
extern __typeof (__rewinddir) __rewinddir attribute_hidden;
# endif
# endif
#endif