Skip to content

Commit

Permalink
* stdlib/strtol_l.c (__strtol_ul_max_tab, __strtol_ul_rem_tab,
Browse files Browse the repository at this point in the history
	__strtol_ull_max_tab, __strtol_ull_rem_tab): Declare.
	(DEF): Don't put the var into .gnu.linkonce.r.* section.
	Only provide var definitions in strtol_l (or for *ull*
	in strtoll_l).

	* stdio-common/bug16.c (tests): New array.
	(do_tests): Allow the first hexadecimal digit
	to be 1, 2, 4 or 8.  Do 3 additional tests.

	* sysdeps/s390/fpu/libm-test-ulps: Update.

	* sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c (fchownat): Use
	fchownat syscall if available.
	* sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Likewise.
	* sysdeps/unix/sysv/linux/sh/fchownat.c (fchownat): Likewise.
	* sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Likewise.

	(rec_dirsearch) [case HIGHER_NAME]: Correctly size ndomain array.
  • Loading branch information
Ulrich Drepper committed Aug 8, 2006
1 parent d0ccde2 commit 2d1e627
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 74 deletions.
22 changes: 21 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2006-08-08 Jakub Jelinek <jakub@redhat.com>

* stdlib/strtol_l.c (__strtol_ul_max_tab, __strtol_ul_rem_tab,
__strtol_ull_max_tab, __strtol_ull_rem_tab): Declare.
(DEF): Don't put the var into .gnu.linkonce.r.* section.
Only provide var definitions in strtol_l (or for *ull*
in strtoll_l).

* stdio-common/bug16.c (tests): New array.
(do_tests): Allow the first hexadecimal digit
to be 1, 2, 4 or 8. Do 3 additional tests.

* sysdeps/s390/fpu/libm-test-ulps: Update.

* sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c (fchownat): Use
fchownat syscall if available.
* sysdeps/unix/sysv/linux/powerpc/fchownat.c (fchownat): Likewise.
* sysdeps/unix/sysv/linux/sh/fchownat.c (fchownat): Likewise.
* sysdeps/unix/sysv/linux/i386/fchownat.c (fchownat): Likewise.

2006-08-07 Ulrich Drepper <drepper@redhat.com>

* nis/nis_xdr.c: Avoid some function calls.
Expand All @@ -11,7 +31,7 @@
2006-08-07 Ulrich Drepper <drepper@redhat.com>

* nis/nis_call.c: Minor cleanups throughout.
(rec_dirsearch) [HIGHER_NAME]: Correctly size ndomain array.
(rec_dirsearch) [case HIGHER_NAME]: Correctly size ndomain array.
(first_shoot): Add search_parent_first parameter. Only if it is set
search parent server first.
If directory for table found through cold start cache is not the same
Expand Down
35 changes: 29 additions & 6 deletions stdio-common/bug16.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
#include <stdio.h>
#include <string.h>

struct
{
long double val;
const char str[4][7];
} tests[] =
{
{ 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
{ 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
{ 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
{ 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
};

static int
do_test (void)
{
char buf[100];
snprintf (buf, sizeof (buf), "%.0LA", 0x0.FFFFp+0L);
int ret = 0;

for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);

size_t j;
for (j = 0; j < 4; ++j)
if (strcmp (buf, tests[i].str[j]) == 0)
break;

if (strcmp (buf, "0X1P+0") != 0)
{
printf ("got \"%s\", expected \"0X1P+0\"\n", buf);
return 1;
if (j == 4)
{
printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
i, buf, tests[i].str[0]);
ret = 1;
}
}

return 0;
return ret;
}

#define TEST_FUNCTION do_test ()
Expand Down
27 changes: 17 additions & 10 deletions stdlib/strtol_l.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Convert string representing a number to integer value, using given locale.
Copyright (C) 1997, 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 1997, 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand Down Expand Up @@ -168,31 +168,38 @@
/* Define tables of maximum values and remainders in order to detect
overflow. Do this at compile-time in order to avoid the runtime
overhead of the division. */
extern const unsigned long __strtol_ul_max_tab[] attribute_hidden;
extern const unsigned char __strtol_ul_rem_tab[] attribute_hidden;
#if defined(QUAD) && __WORDSIZE == 32
extern const unsigned long long __strtol_ull_max_tab[] attribute_hidden;
extern const unsigned char __strtol_ull_rem_tab[] attribute_hidden;
#endif

#define DEF(TYPE, NAME) \
const TYPE NAME[] attribute_hidden \
__attribute__((section(".gnu.linkonce.r." #NAME))) = \
const TYPE NAME[] attribute_hidden = \
{ \
F(2), F(3), F(4), F(5), F(6), F(7), F(8), F(9), F(10), \
F(11), F(12), F(13), F(14), F(15), F(16), F(17), F(18), F(19), F(20), \
F(21), F(22), F(23), F(24), F(25), F(26), F(27), F(28), F(29), F(30), \
F(31), F(32), F(33), F(34), F(35), F(36) \
}

#define F(X) ULONG_MAX / X
#if !UNSIGNED && !defined (USE_WIDE_CHAR) && !defined (QUAD)
# define F(X) ULONG_MAX / X
DEF (unsigned long, __strtol_ul_max_tab);
#undef F
#if defined(QUAD) && __WORDSIZE == 32
# undef F
# define F(X) ULONG_MAX % X
DEF (unsigned char, __strtol_ul_rem_tab);
# undef F
#endif
#if !UNSIGNED && !defined (USE_WIDE_CHAR) && defined (QUAD) \
&& __WORDSIZE == 32
# define F(X) ULONG_LONG_MAX / X
DEF (unsigned long long, __strtol_ull_max_tab);
# undef F
# define F(X) ULONG_LONG_MAX % X
DEF (unsigned char, __strtol_ull_rem_tab);
# undef F
#else
# define F(X) ULONG_MAX % X
DEF (unsigned char, __strtol_ul_rem_tab);
# undef F
#endif
#undef DEF

Expand Down
36 changes: 18 additions & 18 deletions sysdeps/s390/fpu/libm-test-ulps
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,16 @@ ifloat: 1
# j0
Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
double: 1
float: 1
float: 2
idouble: 1
ifloat: 1
ifloat: 2
Test "j0 (0.75) == 0.864242275166648623555731103820923211":
float: 1
ifloat: 1
Test "j0 (10.0) == -0.245935764451348335197760862485328754":
double: 2
double: 3
float: 1
idouble: 2
idouble: 3
ifloat: 1
ildouble: 2
ldouble: 2
Expand All @@ -533,9 +533,9 @@ ildouble: 2
ldouble: 2
Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
double: 1
float: 1
float: 2
idouble: 1
ifloat: 1
ifloat: 2
Test "j0 (8.0) == 0.171650807137553906090869407851972001":
float: 1
ifloat: 1
Expand Down Expand Up @@ -569,16 +569,16 @@ ldouble: 4
# jn
Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
double: 1
float: 1
float: 2
idouble: 1
ifloat: 1
ifloat: 2
Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
float: 1
ifloat: 1
Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
double: 2
double: 3
float: 1
idouble: 2
idouble: 3
ifloat: 1
ildouble: 2
ldouble: 2
Expand All @@ -589,9 +589,9 @@ ildouble: 2
ldouble: 2
Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
double: 1
float: 1
float: 2
idouble: 1
ifloat: 1
ifloat: 2
Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
float: 1
ifloat: 1
Expand Down Expand Up @@ -661,9 +661,9 @@ idouble: 1
ifloat: 1
Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
double: 3
float: 1
float: 2
idouble: 3
ifloat: 1
ifloat: 2
ildouble: 2
ldouble: 2
Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
Expand Down Expand Up @@ -925,9 +925,9 @@ ildouble: 1
ldouble: 1
Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
double: 2
float: 1
float: 2
idouble: 2
ifloat: 1
ifloat: 2
ildouble: 2
ldouble: 2
Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
Expand Down Expand Up @@ -1228,9 +1228,9 @@ float: 1
ifloat: 1

Function: "j0":
double: 2
double: 3
float: 2
idouble: 2
idouble: 3
ifloat: 2
ildouble: 2
ldouble: 2
Expand Down
42 changes: 30 additions & 12 deletions sysdeps/unix/sysv/linux/i386/fchownat.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ extern int __libc_missing_32bit_uids;
int
fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
{
int result;

#ifdef __NR_fchownat
# ifndef __ASSUME_ATFCTS
if (__have_atfcts >= 0)
# endif
{
result = INLINE_SYSCALL (fchownat, 5, fd, file, owner, group, flag);
# ifndef __ASSUME_ATFCTS
if (result == -1 && errno == ENOSYS)
__have_atfcts = -1;
else
# endif
return result;
}
#endif

#ifndef __ASSUME_ATFCTS
if (flag & ~AT_SYMLINK_NOFOLLOW)
{
__set_errno (EINVAL);
Expand All @@ -87,14 +105,13 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
file = buf;
}

int result;
INTERNAL_SYSCALL_DECL (err);

#if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0
# if __ASSUME_LCHOWN_SYSCALL == 0
# if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0
# if __ASSUME_LCHOWN_SYSCALL == 0
static int __libc_old_chown;

# ifdef __NR_chown32
# ifdef __NR_chown32
if (__libc_missing_32bit_uids <= 0)
{
if (flag & AT_SYMLINK_NOFOLLOW)
Expand All @@ -111,7 +128,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)

__libc_missing_32bit_uids = 1;
}
# endif /* __NR_chown32 */
# endif /* __NR_chown32 */

if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U))
|| ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
Expand All @@ -135,13 +152,13 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)

result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner,
group);
# elif __ASSUME_32BITUIDS
# elif __ASSUME_32BITUIDS
/* This implies __ASSUME_LCHOWN_SYSCALL. */
result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner,
group);
# else
# else
/* !__ASSUME_32BITUIDS && ASSUME_LCHOWN_SYSCALL */
# ifdef __NR_chown32
# ifdef __NR_chown32
if (__libc_missing_32bit_uids <= 0)
{
result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner,
Expand All @@ -153,7 +170,7 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)

__libc_missing_32bit_uids = 1;
}
# endif /* __NR_chown32 */
# endif /* __NR_chown32 */
if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U))
|| ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
{
Expand All @@ -162,10 +179,10 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
}

result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, group);
# endif
#else
# endif
# else
result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, group);
#endif
# endif

if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0))
goto fail;
Expand All @@ -175,4 +192,5 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
fail:
__atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf);
return -1;
#endif
}
Loading

0 comments on commit 2d1e627

Please sign in to comment.