aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-11 16:27:38 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-11 16:27:38 +0000
commite7c036b39ef12abc7ff131982df75e3ec35c0f31 (patch)
tree0f5115adbee001941fd8fdf8dac6ea2200f35d60
parent094f72c6a57bf36e70726c1827d93d1d85ed0154 (diff)
downloadglibc-e7c036b39ef12abc7ff131982df75e3ec35c0f31.zip
glibc-e7c036b39ef12abc7ff131982df75e3ec35c0f31.tar.gz
glibc-e7c036b39ef12abc7ff131982df75e3ec35c0f31.tar.bz2
Update.
2000-04-11 Ulrich Drepper <drepper@redhat.com> * posix/globtest.sh: Fix last change. 2000-04-10 Philip Blundell <philb@gnu.org> * sysdeps/unix/sysv/linux/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP): New names for IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP. * sysdeps/generic/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP): Likewise. 2000-04-11 Ulrich Drepper <drepper@redhat.com> * elf/readlib (process_file): Close streams in case of an error. 2000-04-09 Andreas Jaeger <aj@suse.de> * elf/readlib.c (process_file): Check if file is big enough to contain aout and ELF headers. Reported by Reinhard Moosauer <RMoosauer@steinecker.com>. 2000-04-10 Jes Sorensen <Jes.Sorensen@cern.ch> * elf/dl-fini.c: Include alloca.h to get proper prototype for alloca(). 2000-04-11 Ulrich Drepper <drepper@redhat.com> * test-skeleton.c (main): If STDOUT_UNBUFFERED is defined, make stdout stream unbuffered. * rt/Makefile (tests): Add tst-clock. Add rules to build tst-clock. * rt/tst-clock.c: New file. * sysdeps/unix/i386/i586/clock_getres.c: Correct expression to decide about initialization of nsec. * sysdeps/unix/i386/i586/clock_gettime.c: Correct expression to decide about initialization of freq. Set retval to zero if successful. * sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Cache result.
-rw-r--r--ChangeLog39
-rw-r--r--bits/in.h8
-rw-r--r--elf/dl-fini.c1
-rw-r--r--elf/readlib.c18
-rwxr-xr-xposix/globtest.sh10
-rw-r--r--rt/Makefile4
-rw-r--r--rt/tst-clock.c121
-rw-r--r--sysdeps/generic/bits/in.h8
-rw-r--r--sysdeps/unix/i386/i586/clock_getres.c2
-rw-r--r--sysdeps/unix/i386/i586/clock_gettime.c6
-rw-r--r--sysdeps/unix/sysv/linux/bits/in.h12
-rw-r--r--sysdeps/unix/sysv/linux/i386/get_clockfreq.c6
-rw-r--r--test-skeleton.c4
13 files changed, 218 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 33b152a..53bcae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2000-04-11 Ulrich Drepper <drepper@redhat.com>
+
+ * posix/globtest.sh: Fix last change.
+
+2000-04-10 Philip Blundell <philb@gnu.org>
+
+ * sysdeps/unix/sysv/linux/bits/in.h (IPV6_JOIN_GROUP,
+ IPV6_LEAVE_GROUP): New names for IPV6_ADD_MEMBERSHIP,
+ IPV6_DROP_MEMBERSHIP.
+ * sysdeps/generic/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP):
+ Likewise.
+
+2000-04-11 Ulrich Drepper <drepper@redhat.com>
+
+ * elf/readlib (process_file): Close streams in case of an error.
+
+2000-04-09 Andreas Jaeger <aj@suse.de>
+
+ * elf/readlib.c (process_file): Check if file is big enough to
+ contain aout and ELF headers.
+ Reported by Reinhard Moosauer <RMoosauer@steinecker.com>.
+
+2000-04-10 Jes Sorensen <Jes.Sorensen@cern.ch>
+
+ * elf/dl-fini.c: Include alloca.h to get proper prototype for alloca().
+
+2000-04-11 Ulrich Drepper <drepper@redhat.com>
+
+ * test-skeleton.c (main): If STDOUT_UNBUFFERED is defined, make stdout
+ stream unbuffered.
+ * rt/Makefile (tests): Add tst-clock.
+ Add rules to build tst-clock.
+ * rt/tst-clock.c: New file.
+ * sysdeps/unix/i386/i586/clock_getres.c: Correct expression to decide
+ about initialization of nsec.
+ * sysdeps/unix/i386/i586/clock_gettime.c: Correct expression to decide
+ about initialization of freq. Set retval to zero if successful.
+ * sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Cache result.
+
2000-04-10 Ulrich Drepper <drepper@redhat.com>
* Versions.def (librt): Add GLIBC_2.2.
diff --git a/bits/in.h b/bits/in.h
index 8cafffc..36f6705 100644
--- a/bits/in.h
+++ b/bits/in.h
@@ -79,8 +79,12 @@ struct ip_mreq
#define IPV6_MULTICAST_IF 17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
-#define IPV6_ADD_MEMBERSHIP 20
-#define IPV6_DROP_MEMBERSHIP 21
+#define IPV6_JOIN_GROUP 20
+#define IPV6_LEAVE_GROUP 21
+
+/* Obsolete synonyms for the above. */
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
/* Routing header options for IPv6. */
#define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
index fd22bc0..a285c77 100644
--- a/elf/dl-fini.c
+++ b/elf/dl-fini.c
@@ -17,6 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <alloca.h>
#include <assert.h>
#include <string.h>
#include <ldsodefs.h>
diff --git a/elf/readlib.c b/elf/readlib.c
index abd380b..580d802 100644
--- a/elf/readlib.c
+++ b/elf/readlib.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 1999 and
Jakub Jelinek <jakub@redhat.com>, 1999.
@@ -92,10 +92,22 @@ process_file (const char *file_name, const char *lib, int *flag, char **soname,
if (fstat (fileno (file), &statbuf) < 0)
{
error (0, 0, _("Cannot fstat file %s.\n"), file_name);
+ fclose (file);
+ return 1;
+ }
+
+ /* Check that the file is large enough so that we can access the
+ information. We're only checking the size of the headers here. */
+ if (statbuf.st_size < sizeof (struct exec)
+ || statbuf.st_size < sizeof (ElfW(Ehdr)))
+ {
+ error (0, 0, _("File %s is too small, not checked."), file_name);
+ fclose (file);
return 1;
}
- file_contents = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fileno (file), 0);
+ file_contents = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED,
+ fileno (file), 0);
if (file_contents == MAP_FAILED)
{
error (0, 0, _("Cannot mmap file %s.\n"), file_name);
@@ -108,7 +120,7 @@ process_file (const char *file_name, const char *lib, int *flag, char **soname,
if (N_MAGIC (*aout_header) == ZMAGIC
|| N_MAGIC (*aout_header) == QMAGIC)
{
- /* Aout files don't have a soname, just return the the name
+ /* Aout files don't have a soname, just return the name
including the major number. */
char *copy, *major, *dot;
copy = xstrdup (lib);
diff --git a/posix/globtest.sh b/posix/globtest.sh
index 60f1bf8..6c08830 100755
--- a/posix/globtest.sh
+++ b/posix/globtest.sh
@@ -319,14 +319,14 @@ if test "$user" != root; then
cat <<"EOF" | cmp - $testout || result=1
GLOB_ABORTED
EOF
-fi # not run as root
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
-${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
-sort > $testout
-cat <<"EOF" | cmp - $testout || result=1
+ ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+ ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
+ sort > $testout
+ cat <<"EOF" | cmp - $testout || result=1
GLOB_ABORTED
EOF
+fi # not run as root
# Try multiple patterns (GLOB_APPEND)
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
diff --git a/rt/Makefile b/rt/Makefile
index b2688f9..b661edd 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -38,7 +38,7 @@ include ../Makeconfig
ifeq ($(have-thread-library),yes)
-tests := tst-aio tst-aio64
+tests := tst-aio tst-aio64 tst-clock
extra-libs := librt
extra-libs-others := $(extra-libs)
@@ -55,7 +55,9 @@ $(objpfx)librt.so: $(common-objpfx)libc.so $(shared-thread-library)
ifeq (yes,$(build-shared))
$(objpfx)tst-aio: $(objpfx)librt.so $(shared-thread-library)
$(objpfx)tst-aio64: $(objpfx)librt.so $(shared-thread-library)
+$(objpfx)tst-clock: $(objpfx)librt.so $(shared-thread-library)
else
$(objpfx)tst-aio: $(objpfx)librt.a $(static-thread-library)
$(objpfx)tst-aio64: $(objpfx)librt.a $(static-thread-library)
+$(objpfx)tst-clock: $(objpfx)librt.a $(static-thread-library)
endif
diff --git a/rt/tst-clock.c b/rt/tst-clock.c
new file mode 100644
index 0000000..d9a41e0
--- /dev/null
+++ b/rt/tst-clock.c
@@ -0,0 +1,121 @@
+/* Test program for POSIX clock_* functions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+
+/* We want to see output immediately. */
+#define STDOUT_UNBUFFERED
+
+/* We expect to run at least 10 seconds. */
+#define TIMEOUT 15
+
+int
+clock_test (clockid_t cl)
+{
+ struct timespec old_ts;
+ struct timespec ts;
+ struct timespec waitit;
+ int result = 0;
+ int i;
+
+ memset (&ts, '\0', sizeof ts);
+
+ waitit.tv_sec = 0;
+ waitit.tv_nsec = 500000000;
+
+ /* Get and print resolution of the clock. */
+ if (clock_getres (cl, &ts) == 0)
+ {
+ if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+ {
+ printf ("clock %d: nanosecond value of resolution wrong\n", cl);
+ result = 1;
+ }
+ else
+ printf ("clock %d: resolution = %ld.%09ld secs\n",
+ cl, ts.tv_sec, ts.tv_nsec);
+ }
+ else
+ {
+ printf ("clock %d: cannot get resolution\n", cl);
+ result = 1;
+ }
+
+ memset (&ts, '\0', sizeof ts);
+ memset (&old_ts, '\0', sizeof old_ts);
+
+ /* Next get the current time value a few times. */
+ for (i = 0; i < 10; ++i)
+ {
+ if (clock_gettime (cl, &ts) == 0)
+ {
+ if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+ {
+ printf ("clock %d: nanosecond value of time wrong (try %d)\n",
+ cl, i);
+ result = 1;
+ }
+ else
+ {
+ printf ("clock %d: time = %ld.%09ld secs\n",
+ cl, ts.tv_sec, ts.tv_nsec);
+
+ if (memcmp (&ts, &old_ts, sizeof ts) == 0)
+ {
+ printf ("clock %d: time hasn't changed (try %d)\n", cl, i);
+ result = 1;
+
+ old_ts = ts;
+ }
+ }
+ }
+ else
+ {
+ printf ("clock %d: cannot get time (try %d)\n", cl, i);
+ result = 1;
+ }
+
+ /* Wait a bit before the next iteration. */
+ nanosleep (&waitit, NULL);
+ }
+
+ return result;
+}
+
+int
+do_test (void)
+{
+ clockid_t cl;
+ int result;
+
+ result = clock_test (CLOCK_REALTIME);
+
+ if (clock_getcpuclockid (0, &cl) == 0)
+ /* XXX It's not yet a bug when this fails. */
+ clock_test (cl);
+
+ return result;
+}
+#define TEST_FUNCTION do_test ()
+
+
+#include "../test-skeleton.c"
diff --git a/sysdeps/generic/bits/in.h b/sysdeps/generic/bits/in.h
index 8cafffc..36f6705 100644
--- a/sysdeps/generic/bits/in.h
+++ b/sysdeps/generic/bits/in.h
@@ -79,8 +79,12 @@ struct ip_mreq
#define IPV6_MULTICAST_IF 17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
-#define IPV6_ADD_MEMBERSHIP 20
-#define IPV6_DROP_MEMBERSHIP 21
+#define IPV6_JOIN_GROUP 20
+#define IPV6_LEAVE_GROUP 21
+
+/* Obsolete synonyms for the above. */
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
/* Routing header options for IPv6. */
#define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */
diff --git a/sysdeps/unix/i386/i586/clock_getres.c b/sysdeps/unix/i386/i586/clock_getres.c
index abafcc0..dacf7f4 100644
--- a/sysdeps/unix/i386/i586/clock_getres.c
+++ b/sysdeps/unix/i386/i586/clock_getres.c
@@ -43,7 +43,7 @@ static long int nsec;
#define EXTRA_CLOCK_CASES \
case __CLOCK_HIGHRES: \
{ \
- if (__builtin_expect (nsec != 0, 0)) \
+ if (__builtin_expect (nsec == 0, 0)) \
{ \
unsigned long long int freq; \
\
diff --git a/sysdeps/unix/i386/i586/clock_gettime.c b/sysdeps/unix/i386/i586/clock_gettime.c
index f623cec..bb63874 100644
--- a/sysdeps/unix/i386/i586/clock_gettime.c
+++ b/sysdeps/unix/i386/i586/clock_gettime.c
@@ -44,7 +44,7 @@ static unsigned long long int freq;
{ \
unsigned long long int tsc; \
\
- if (__builtin_expect (freq != 0, 0)) \
+ if (__builtin_expect (freq == 0, 0)) \
{ \
/* This can only happen if we haven't initialized the `freq' \
variable yet. Do this now. We don't have to protect this \
@@ -64,7 +64,9 @@ static unsigned long long int freq;
\
/* And the nanoseconds. This computation should be stable until \
we get machines with about 16GHz frequency. */ \
- tp->tv_nsec = ((tsc % freq) * 1000000000ULL) / freq; \
+ tp->tv_nsec = ((tsc % freq) * 1000000000ull) / freq; \
+ \
+ retval = 0; \
} \
break;
diff --git a/sysdeps/unix/sysv/linux/bits/in.h b/sysdeps/unix/sysv/linux/bits/in.h
index 8efe242..6778d3f 100644
--- a/sysdeps/unix/sysv/linux/bits/in.h
+++ b/sysdeps/unix/sysv/linux/bits/in.h
@@ -109,8 +109,8 @@ struct in_pktinfo
#define IPV6_MULTICAST_IF 17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
-#define IPV6_ADD_MEMBERSHIP 20
-#define IPV6_DROP_MEMBERSHIP 21
+#define IPV6_JOIN_GROUP 20
+#define IPV6_LEAVE_GROUP 21
#define IPV6_ROUTER_ALERT 22
#define IPV6_MTU_DISCOVER 23
#define IPV6_MTU 24
@@ -118,8 +118,12 @@ struct in_pktinfo
#define SCM_SRCRT IPV6_RXSRCRT
-#define IPV6_RXHOPOPTS IPV6_HOPOPTS /* obsolete name */
-#define IPV6_RXDSTOPTS IPV6_DSTOPTS /* obsolete name */
+/* Obsolete synonyms for the above. */
+#define IPV6_RXHOPOPTS IPV6_HOPOPTS
+#define IPV6_RXDSTOPTS IPV6_DSTOPTS
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+
/* IPV6_MTU_DISCOVER values. */
#define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */
diff --git a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
index 28f56c8..65b7bb2 100644
--- a/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/i386/get_clockfreq.c
@@ -29,9 +29,13 @@ __get_clockfreq (void)
least one line like
cpu MHz : 497.840237
We search for this line and convert the number in an integer. */
- unsigned long long int result = 0ull;
+ static unsigned long long int result;
int fd;
+ /* If this function was called before, we know the result. */
+ if (result != 0)
+ return result;
+
fd = open ("/proc/cpuinfo", O_RDONLY);
if (__builtin_expect (fd != -1, 1))
{
diff --git a/test-skeleton.c b/test-skeleton.c
index 729d55f..db04b11 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -122,6 +122,10 @@ main (int argc, char *argv[])
int status;
int opt;
+#ifdef STDOUT_UNBUFFERED
+ setbuf (stdout, NULL);
+#endif
+
while ((opt = getopt_long (argc, argv, "", options, NULL)) != -1)
switch (opt)
{