1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00
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.
This commit is contained in:
Ulrich Drepper
2000-10-26 08:11:19 +00:00
parent 1267f93e16
commit 726b7b0f5c
7 changed files with 422 additions and 31 deletions

View File

@@ -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;