Skip to content

Commit

Permalink
[BZ #3252, BZ #3253]
Browse files Browse the repository at this point in the history
2006-09-25  Jakub Jelinek  <jakub@redhat.com>
	[BZ #3252]
	* sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Handle only
	fchownat syscall and __ASSUME_LCHOWN_SYSCALL case inline, call
	__{,l}chown to handle the rest.
	* sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Handle only
	fchownat syscall and __ASSUME_32BITUIDS case inline, call
	__{,l}chown to handle the rest.
	* sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c: Include
	i386/fchownat.c.
	* sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/fchownat.c: Likewise.

	[BZ #3253]
	* posix/glob.c (glob_in_dir): Don't alloca one struct globlink at a
	time, rather allocate increasingly bigger arrays of pointers, if
	possible with alloca, if too large with malloc.

2006-09-24  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/powerpc/fpu/libm-test-ulps: Updated.

	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Fix 2 typos.
  • Loading branch information
Ulrich Drepper committed Sep 25, 2006
1 parent 457b559 commit f1122ec
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 589 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
2006-09-25 Jakub Jelinek <jakub@redhat.com>

[BZ #3252]
* sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Handle only
fchownat syscall and __ASSUME_LCHOWN_SYSCALL case inline, call
__{,l}chown to handle the rest.
* sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Handle only
fchownat syscall and __ASSUME_32BITUIDS case inline, call
__{,l}chown to handle the rest.
* sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c: Include
i386/fchownat.c.
* sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c: Likewise.
* sysdeps/unix/sysv/linux/sh/fchownat.c: Likewise.

[BZ #3253]
* posix/glob.c (glob_in_dir): Don't alloca one struct globlink at a
time, rather allocate increasingly bigger arrays of pointers, if
possible with alloca, if too large with malloc.

2006-09-24 Jakub Jelinek <jakub@redhat.com>

* sysdeps/powerpc/fpu/libm-test-ulps: Updated.

* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Fix 2 typos.

2006-09-24 Ulrich Drepper <drepper@redhat.com>

* sysdeps/posix/getaddrinfo.c (rfc3484_sort): Implement rule 4,
Expand Down
142 changes: 88 additions & 54 deletions posix/glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,24 +1090,32 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
{
size_t dirlen = strlen (directory);
void *stream = NULL;
struct globlink
struct globnames
{
struct globlink *next;
char *name;
struct globnames *next;
size_t count;
char *name[64];
};
struct globlink *names = NULL;
size_t nfound;
#define INITIAL_COUNT sizeof (init_names.name) / sizeof (init_names.name[0])
struct globnames init_names;
struct globnames *names = &init_names;
struct globnames *names_alloca = &init_names;
size_t nfound = 0;
size_t allocasize = sizeof (init_names);
size_t cur = 0;
int meta;
int save;

init_names.next = NULL;
init_names.count = INITIAL_COUNT;

meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
{
/* We need not do any tests. The PATTERN contains no meta
characters and we must not return an error therefore the
result will always contain exactly one name. */
flags |= GLOB_NOCHECK;
nfound = 0;
}
else if (meta == 0 &&
((flags & GLOB_NOESCAPE) || strchr (pattern, '\\') == NULL))
Expand All @@ -1128,21 +1136,17 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
/* We found this file to be existing. Now tell the rest
of the function to copy this name into the result. */
flags |= GLOB_NOCHECK;

nfound = 0;
}
else
{
if (pattern[0] == '\0')
{
/* This is a special case for matching directories like in
"*a/". */
names = (struct globlink *) __alloca (sizeof (struct globlink));
names->name = (char *) malloc (1);
if (names->name == NULL)
names->name[cur] = (char *) malloc (1);
if (names->name[cur] == NULL)
goto memory_error;
names->name[0] = '\0';
names->next = NULL;
*names->name[cur++] = '\0';
nfound = 1;
meta = 0;
}
Expand All @@ -1157,7 +1161,6 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
&& ((errfunc != NULL && (*errfunc) (directory, errno))
|| (flags & GLOB_ERR)))
return GLOB_ABORTED;
nfound = 0;
meta = 0;
}
else
Expand All @@ -1168,7 +1171,6 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
| FNM_CASEFOLD
#endif
);
nfound = 0;
flags |= GLOB_MAGCHAR;

while (1)
Expand Down Expand Up @@ -1224,15 +1226,30 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
|| link_exists_p (directory, dirlen, name, pglob,
flags))
{
struct globlink *new = (struct globlink *)
__alloca (sizeof (struct globlink));
if (cur == names->count)
{
struct globnames *newnames;
size_t count = names->count * 2;
size_t size = (sizeof (struct globnames)
+ ((count - INITIAL_COUNT)
* sizeof (char *)));
allocasize += size;
if (__libc_use_alloca (allocasize))
newnames = names_alloca = __alloca (size);
else if ((newnames = malloc (size))
== NULL)
goto memory_error;
newnames->count = count;
newnames->next = names;
names = newnames;
cur = 0;
}
len = NAMLEN (d);
new->name = (char *) malloc (len + 1);
if (new->name == NULL)
names->name[cur] = (char *) malloc (len + 1);
if (names->name[cur] == NULL)
goto memory_error;
*((char *) mempcpy (new->name, name, len)) = '\0';
new->next = names;
names = new;
*((char *) mempcpy (names->name[cur++], name, len))
= '\0';
++nfound;
}
}
Expand All @@ -1245,59 +1262,76 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
{
size_t len = strlen (pattern);
nfound = 1;
names = (struct globlink *) __alloca (sizeof (struct globlink));
names->next = NULL;
names->name = (char *) malloc (len + 1);
if (names->name == NULL)
names->name[cur] = (char *) malloc (len + 1);
if (names->name[cur] == NULL)
goto memory_error;
*((char *) mempcpy (names->name, pattern, len)) = '\0';
*((char *) mempcpy (names->name[cur++], pattern, len)) = '\0';
}

int result = GLOB_NOMATCH;
if (nfound != 0)
{
char **new_gl_pathv;
result = 0;

char **new_gl_pathv;
new_gl_pathv
= (char **) realloc (pglob->gl_pathv,
(pglob->gl_pathc + pglob->gl_offs + nfound + 1)
* sizeof (char *));
if (new_gl_pathv == NULL)
goto memory_error;
pglob->gl_pathv = new_gl_pathv;
{
memory_error:
while (1)
{
struct globnames *old = names;
for (size_t i = 0; i < cur; ++i)
free (names->name[i]);
names = names->next;
if (names == NULL)
break;
cur = names->count;
if (old == names_alloca)
names_alloca = names;
else
free (old);
}
result = GLOB_NOSPACE;
}
else
{
while (1)
{
struct globnames *old = names;
for (size_t i = 0; i < cur; ++i)
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
= names->name[i];
names = names->next;
if (names == NULL)
break;
cur = names->count;
if (old == names_alloca)
names_alloca = names;
else
free (old);
}

pglob->gl_pathv = new_gl_pathv;

for (; names != NULL; names = names->next)
pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc++] = names->name;
pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;

pglob->gl_flags = flags;
pglob->gl_flags = flags;
}
}

save = errno;
if (stream != NULL)
{
save = errno;
if (flags & GLOB_ALTDIRFUNC)
(*pglob->gl_closedir) (stream);
else
closedir (stream);
__set_errno (save);
}
__set_errno (save);

return nfound == 0 ? GLOB_NOMATCH : 0;

memory_error:
{
int save = errno;
if (flags & GLOB_ALTDIRFUNC)
(*pglob->gl_closedir) (stream);
else
closedir (stream);
__set_errno (save);
}
while (names != NULL)
{
if (names->name != NULL)
free (names->name);
names = names->next;
}
return GLOB_NOSPACE;
return result;
}
4 changes: 2 additions & 2 deletions sysdeps/ieee754/ldbl-128/s_lrintl.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ __lrintl (long double x)
{
w = two112[sx] + x;
t = w - two112[sx];
GET_LDOUBLE_WORDS64 (i0, i1, x);
GET_LDOUBLE_WORDS64 (i0, i1, t);
j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
i0 &= 0x0000ffffffffffffLL;
i0 |= 0x0001000000000000LL;
Expand All @@ -65,7 +65,7 @@ __lrintl (long double x)
{
w = two112[sx] + x;
t = w - two112[sx];
GET_LDOUBLE_WORDS64 (i0, i1, x);
GET_LDOUBLE_WORDS64 (i0, i1, t);
j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
i0 &= 0x0000ffffffffffffLL;
i0 |= 0x0001000000000000LL;
Expand Down
16 changes: 12 additions & 4 deletions sysdeps/powerpc/fpu/libm-test-ulps
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ ldouble: 1
Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
float: 1
ifloat: 1
ildouble: 2
ldouble: 2
ildouble: 3
ldouble: 3
Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
double: 1
float: 1
Expand Down Expand Up @@ -364,6 +364,8 @@ ldouble: 2
Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
double: 1
idouble: 1
ildouble: 1
ldouble: 1
Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
float: 1
ifloat: 1
Expand Down Expand Up @@ -739,6 +741,9 @@ idouble: 1
ifloat: 1

# y0
Test "y0 (0.125) == -1.38968062514384052915582277745018693":
ildouble: 1
ldouble: 1
Test "y0 (0.75) == -0.137172769385772397522814379396581855":
ildouble: 1
ldouble: 1
Expand Down Expand Up @@ -800,6 +805,9 @@ ildouble: 2
ldouble: 2

# yn
Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
ildouble: 1
ldouble: 1
Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
ildouble: 1
ldouble: 1
Expand Down Expand Up @@ -1066,8 +1074,8 @@ ldouble: 1
Function: Real part of "clog10":
float: 1
ifloat: 1
ildouble: 2
ldouble: 2
ildouble: 3
ldouble: 3

Function: Imaginary part of "clog10":
double: 1
Expand Down
Loading

0 comments on commit f1122ec

Please sign in to comment.