aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-26 08:11:19 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-26 08:11:19 +0000
commit726b7b0f5cce9df5dd406a6a38a3e104fac9a070 (patch)
tree51be27a039af937051a2ee45d7765c024b6c83c8 /sysdeps
parent1267f93e167d951907e335bed5cbf1fa56f7357b (diff)
downloadglibc-726b7b0f5cce9df5dd406a6a38a3e104fac9a070.zip
glibc-726b7b0f5cce9df5dd406a6a38a3e104fac9a070.tar.gz
glibc-726b7b0f5cce9df5dd406a6a38a3e104fac9a070.tar.bz2
Update.
2000-10-26 Ulrich Drepper <drepper@redhat.com> * posix/Makefile (tests): Add tst-chmod. (tst-chmod-ARGS): Define. * posix/tst-chmod.c: New file. * test-skeleton.c: Before calling user-defined function remove parameters from argument list. * posix/tst-exec.c: Adjust to this change. * posix/tst-spawn.c: Likewise. * sysdeps/unix/opendir.c (__opendir): Optimize a bit. Add __builtin_expect.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/opendir.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index ad91931..cf83847 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -81,7 +81,7 @@ __opendir (const char *name)
size_t allocation;
int save_errno;
- if (name[0] == '\0')
+ if (__builtin_expect (name[0], '\1') == '\0')
{
/* POSIX.1-1990 says an empty name gets ENOENT;
but `open' might like it fine. */
@@ -101,9 +101,9 @@ __opendir (const char *name)
/* We first have to check whether the name is for a directory. We
cannot do this after the open() call since the open/close operation
performed on, say, a tape device might have undesirable effects. */
- if (__xstat64 (_STAT_VER, name, &statbuf) < 0)
+ if (__builtin_expect (__xstat64 (_STAT_VER, name, &statbuf), 0) < 0)
return NULL;
- if (! S_ISDIR (statbuf.st_mode))
+ if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
{
__set_errno (ENOTDIR);
return NULL;
@@ -111,24 +111,27 @@ __opendir (const char *name)
}
fd = __open (name, O_RDONLY|O_NDELAY|EXTRA_FLAGS);
- if (fd < 0)
+ if (__builtin_expect (fd, 0) < 0)
return NULL;
/* Now make sure this really is a directory and nothing changed since
- the `stat' call. */
- if (__fxstat64 (_STAT_VER, fd, &statbuf) < 0)
+ the `stat' call. We do not have to perform the test for the
+ descriptor being associated with a directory if we know the
+ O_DIRECTORY flag is honored by the kernel. */
+ if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
goto lose;
- if (! S_ISDIR (statbuf.st_mode))
+ if (o_directory_works <= 0
+ && __builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
{
save_errno = ENOTDIR;
goto lose;
}
- if (__fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
+ if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)
goto lose;
#ifdef _STATBUF_ST_BLKSIZE
- if (statbuf.st_blksize < sizeof (struct dirent))
+ if (__builtin_expect (statbuf.st_blksize < sizeof (struct dirent), 0))
allocation = sizeof (struct dirent);
else
allocation = statbuf.st_blksize;