mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-14 01:00:07 +00:00
Optimize fdopendir a bit.
Don't call fcntl(F_SETFD) unnecessarily.
This commit is contained in:
parent
66bdbaa452
commit
28377d1bf5
@ -1,3 +1,12 @@
|
|||||||
|
2011-05-08 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* include/dirent.h (__alloc_dir): Add flags parameter.
|
||||||
|
* sysdeps/unix/fdopendir.c (__fdopendir): Pass flags to __alloc_dir.
|
||||||
|
* sysdeps/unix/opendir.c (__opendir): Pass 0 in new parameter to
|
||||||
|
__alloc_dir.
|
||||||
|
(__alloc_dir): Take new parameter. Don't call fcntl for invocations
|
||||||
|
from fdopendir if O_CLOEXEC is already set.
|
||||||
|
|
||||||
2011-03-15 Alan Modra <amodra@gmail.com>
|
2011-03-15 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf/dl-reloc.c (_dl_try_allocate_static_tls <TLS_DTV_AT_TP>): Handle
|
* elf/dl-reloc.c (_dl_try_allocate_static_tls <TLS_DTV_AT_TP>): Handle
|
||||||
|
@ -28,7 +28,8 @@ extern int __alphasort64 (const struct dirent64 **a, const struct dirent64 **b)
|
|||||||
extern int __versionsort64 (const struct dirent64 **a,
|
extern int __versionsort64 (const struct dirent64 **a,
|
||||||
const struct dirent64 **b)
|
const struct dirent64 **b)
|
||||||
__attribute_pure__;
|
__attribute_pure__;
|
||||||
extern DIR *__alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
|
extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
|
||||||
|
const struct stat64 *statp)
|
||||||
internal_function;
|
internal_function;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
/* Copyright (C) 2005, 2006, 2011 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -47,6 +47,6 @@ __fdopendir (int fd)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __alloc_dir (fd, false, &statbuf);
|
return __alloc_dir (fd, false, flags, &statbuf);
|
||||||
}
|
}
|
||||||
weak_alias (__fdopendir, fdopendir)
|
weak_alias (__fdopendir, fdopendir)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991-1996,98,2000-2003,2005,2007,2009
|
/* Copyright (C) 1991-1996,98,2000-2003,2005,2007,2009,2011
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ __opendir (const char *name)
|
|||||||
statp = &statbuf;
|
statp = &statbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __alloc_dir (fd, true, statp);
|
return __alloc_dir (fd, true, 0, statp);
|
||||||
}
|
}
|
||||||
weak_alias (__opendir, opendir)
|
weak_alias (__opendir, opendir)
|
||||||
|
|
||||||
@ -158,13 +158,14 @@ check_have_o_cloexec (int fd)
|
|||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
internal_function
|
internal_function
|
||||||
__alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
|
__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
|
||||||
{
|
{
|
||||||
/* We always have to set the close-on-exit flag if the user provided
|
/* We always have to set the close-on-exit flag if the user provided
|
||||||
the file descriptor. Otherwise only if we have no working
|
the file descriptor. Otherwise only if we have no working
|
||||||
O_CLOEXEC support. */
|
O_CLOEXEC support. */
|
||||||
#ifdef O_CLOEXEC
|
#ifdef O_CLOEXEC
|
||||||
if (! close_fd || ! check_have_o_cloexec (fd))
|
if ((! close_fd && (flags & O_CLOEXEC) == 0)
|
||||||
|
|| ! check_have_o_cloexec (fd))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)
|
if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user