From 22bb992d51903bc8cd5f67a207d00e3a6aa8e1a9 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 2 Sep 2009 19:43:04 -0700 Subject: [PATCH 1/5] Fix strstr/strcasestr/fma/fmaf on x86_64. --- ChangeLog | 11 +++++++++++ sysdeps/x86_64/multiarch/s_fma.c | 4 ++-- sysdeps/x86_64/multiarch/s_fmaf.c | 4 ++-- sysdeps/x86_64/multiarch/strcasestr-c.c | 3 ++- sysdeps/x86_64/multiarch/strstr-c.c | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0812312f3f..ef087c7944 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-09-02 Jakub Jelinek + + * sysdeps/x86_64/multiarch/strstr-c.c (__strstr_sse42, __strstr_sse2): + Add attribute_hidden. + * sysdeps/x86_64/multiarch/strcasestr-c.c (__strcasestr_sse42, + __strcasestr_sse2): Likewise. + * sysdeps/x86_64/multiarch/s_fma.c (__fma_sse2): Add attribute_hidden. + (__fma_fma): Make static. + * sysdeps/x86_64/multiarch/s_fmaf.c (__fmaf_sse2): Add attribute_hidden. + (__fmaf_fma): Make static. + 2009-08-31 Andreas Schwab * libio/wfileops.c (_IO_wfile_seekoff): Remove dead code and diff --git a/sysdeps/x86_64/multiarch/s_fma.c b/sysdeps/x86_64/multiarch/s_fma.c index 40601e9a68..cfecf9b41d 100644 --- a/sysdeps/x86_64/multiarch/s_fma.c +++ b/sysdeps/x86_64/multiarch/s_fma.c @@ -24,10 +24,10 @@ #ifdef HAVE_AVX_SUPPORT -extern double __fma_sse2 (double x, double y, double z); +extern double __fma_sse2 (double x, double y, double z) attribute_hidden; -double +static double __fma_fma (double x, double y, double z) { asm ("vfmadd213sd %3, %2, %0" : "=x" (x) : "0" (x), "x" (y), "xm" (z)); diff --git a/sysdeps/x86_64/multiarch/s_fmaf.c b/sysdeps/x86_64/multiarch/s_fmaf.c index f3d37f8f4a..de1c4b6f41 100644 --- a/sysdeps/x86_64/multiarch/s_fmaf.c +++ b/sysdeps/x86_64/multiarch/s_fmaf.c @@ -23,10 +23,10 @@ #ifdef HAVE_AVX_SUPPORT -extern float __fmaf_sse2 (float x, float y, float z); +extern float __fmaf_sse2 (float x, float y, float z) attribute_hidden; -float +static float __fmaf_fma (float x, float y, float z) { asm ("vfmadd213ss %3, %2, %0" : "=x" (x) : "0" (x), "x" (y), "xm" (z)); diff --git a/sysdeps/x86_64/multiarch/strcasestr-c.c b/sysdeps/x86_64/multiarch/strcasestr-c.c index e6879531bc..3cb5557b67 100644 --- a/sysdeps/x86_64/multiarch/strcasestr-c.c +++ b/sysdeps/x86_64/multiarch/strcasestr-c.c @@ -7,7 +7,8 @@ #include "string/strcasestr.c" -extern char *__strcasestr_sse42 (const char *, const char *); +extern char *__strcasestr_sse42 (const char *, const char *) attribute_hidden; +extern __typeof (__strcasestr_sse2) __strcasestr_sse2 attribute_hidden; #if 1 libc_ifunc (__strcasestr, diff --git a/sysdeps/x86_64/multiarch/strstr-c.c b/sysdeps/x86_64/multiarch/strstr-c.c index cff99b71ef..d593089a87 100644 --- a/sysdeps/x86_64/multiarch/strstr-c.c +++ b/sysdeps/x86_64/multiarch/strstr-c.c @@ -7,6 +7,7 @@ #include "string/strstr.c" -extern char *__strstr_sse42 (const char *, const char *); +extern char *__strstr_sse42 (const char *, const char *) attribute_hidden; +extern __typeof (__strstr_sse2) __strstr_sse2 attribute_hidden; libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2); From 5d2e69766a8faba5bae37702094c36113365a6ca Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 2 Sep 2009 19:45:33 -0700 Subject: [PATCH 2/5] Fix fsetpos on wide stream. --- ChangeLog | 7 +++++ libio/Makefile | 2 +- libio/bug-wsetpos.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ libio/wfileops.c | 49 +++++++++-------------------- 4 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 libio/bug-wsetpos.c diff --git a/ChangeLog b/ChangeLog index ef087c7944..23cf69eae4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-09-02 Andreas Schwab + + * libio/wfileops.c (_IO_wfile_seekoff): Account for readahead in + external buffer. Always discard readahead in internal buffer. + * libio/Makefile (tests): Add bug-wsetpos. + * libio/bug-wsetpos.c: New file. + 2009-09-02 Jakub Jelinek * sysdeps/x86_64/multiarch/strstr-c.c (__strstr_sse42, __strstr_sse2): diff --git a/libio/Makefile b/libio/Makefile index 501e80c2ee..83b9458dc2 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -58,7 +58,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-memstream1 tst-memstream2 \ tst-wmemstream1 tst-wmemstream2 \ bug-memstream1 bug-wmemstream1 \ - tst-setvbuf1 tst-popen1 tst-fgetwc + tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos test-srcs = test-freopen all: # Make this the default target; it will be defined in Rules. diff --git a/libio/bug-wsetpos.c b/libio/bug-wsetpos.c new file mode 100644 index 0000000000..ccb22a4b62 --- /dev/null +++ b/libio/bug-wsetpos.c @@ -0,0 +1,75 @@ +/* Test program for fsetpos on a wide character stream. */ + +#include +#include +#include + +static void do_prepare (void); +#define PREPARE(argc, argv) do_prepare () +static int do_test (void); +#define TEST_FUNCTION do_test () +#include + +static const char pattern[] = "12345"; +static char *temp_file; + +static void +do_prepare (void) +{ + int fd = create_temp_file ("bug-wsetpos.", &temp_file); + if (fd == -1) + { + printf ("cannot create temporary file: %m\n"); + exit (1); + } + write (fd, pattern, sizeof (pattern)); + close (fd); +} + +static int +do_test (void) +{ + FILE *fp = fopen (temp_file, "r"); + fpos_t pos; + wchar_t c; + + if (fp == NULL) + { + printf ("fdopen: %m\n"); + return 1; + } + + c = fgetwc (fp); assert (c == L'1'); + c = fgetwc (fp); assert (c == L'2'); + + if (fgetpos (fp, &pos) == EOF) + { + printf ("fgetpos: %m\n"); + return 1; + } + + rewind (fp); + if (ferror (fp)) + { + printf ("rewind: %m\n"); + return 1; + } + + c = fgetwc (fp); assert (c == L'1'); + + if (fsetpos (fp, &pos) == EOF) + { + printf ("fsetpos: %m\n"); + return 1; + } + + c = fgetwc (fp); + if (c != L'3') + { + puts ("fsetpos failed"); + return 1; + } + + puts ("Test succeeded."); + return 0; +} diff --git a/libio/wfileops.c b/libio/wfileops.c index be8ae78bfb..5bc08bedfb 100644 --- a/libio/wfileops.c +++ b/libio/wfileops.c @@ -631,8 +631,12 @@ _IO_wfile_seekoff (fp, offset, dir, mode) clen = (*cv->__codecvt_do_encoding) (cv); if (clen > 0) - offset -= (fp->_wide_data->_IO_read_end - - fp->_wide_data->_IO_read_ptr) * clen; + { + offset -= (fp->_wide_data->_IO_read_end + - fp->_wide_data->_IO_read_ptr) * clen; + /* Adjust by readahead in external buffer. */ + offset -= fp->_IO_read_end - fp->_IO_read_ptr; + } else { int nread; @@ -690,39 +694,11 @@ _IO_wfile_seekoff (fp, offset, dir, mode) fp->_IO_buf_base + (offset - start_offset), fp->_IO_read_end); _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base); - - /* Now set the pointer for the internal buffer. This - might be an iterative process. Though the read - pointer is somewhere in the current external buffer - this does not mean we can convert this whole buffer - at once fitting in the internal buffer. */ - fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state; - read_ptr_copy = fp->_IO_read_base; - fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base; - do - { - wchar_t buffer[1024]; - wchar_t *ignore; - status = (*cd->__codecvt_do_in) (cd, - &fp->_wide_data->_IO_state, - read_ptr_copy, - fp->_IO_read_ptr, - &read_ptr_copy, - buffer, - buffer - + (sizeof (buffer) - / sizeof (buffer[0])), - &ignore); - if (status != __codecvt_ok && status != __codecvt_partial) - { - fp->_flags |= _IO_ERR_SEEN; - goto dumb; - } - } - while (read_ptr_copy != fp->_IO_read_ptr); - - fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base; - + _IO_wsetg (fp, fp->_wide_data->_IO_buf_base, + fp->_wide_data->_IO_buf_base, + fp->_wide_data->_IO_buf_base); + _IO_wsetp (fp, fp->_wide_data->_IO_buf_base, + fp->_wide_data->_IO_buf_base); _IO_mask_flags (fp, 0, _IO_EOF_SEEN); goto resync; } @@ -760,6 +736,9 @@ _IO_wfile_seekoff (fp, offset, dir, mode) _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + delta, fp->_IO_buf_base + count); _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base); + _IO_wsetg (fp, fp->_wide_data->_IO_buf_base, + fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base); + _IO_wsetp (fp, fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base); fp->_offset = result + count; _IO_mask_flags (fp, 0, _IO_EOF_SEEN); return offset; From 2eeb9a5d73bd86261b69e61955741e3ce86c28f6 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 2 Sep 2009 19:48:39 -0700 Subject: [PATCH 3/5] Fix lookup of group names in hesiod initgroups. Resolving names from a grplist entry actually never worked. --- ChangeLog | 5 +++++ hesiod/nss_hesiod/hesiod-grp.c | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23cf69eae4..01e7c91f81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-01 Andreas Schwab + + * hesiod/nss_hesiod/hesiod-grp.c (internal_gid_from_group): Fix + parsing of group entry. + 2009-09-02 Andreas Schwab * libio/wfileops.c (_IO_wfile_seekoff): Account for readahead in diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c index 50c53f7893..f0c8c31e06 100644 --- a/hesiod/nss_hesiod/hesiod-grp.c +++ b/hesiod/nss_hesiod/hesiod-grp.c @@ -139,21 +139,19 @@ internal_gid_from_group (void *context, const char *groupname, gid_t *group) { char *p = *grp_res; + /* Skip to third field. */ while (*p != '\0' && *p != ':') ++p; - while (*p != '\0' && *p == ':') + if (*p != '\0') ++p; while (*p != '\0' && *p != ':') ++p; - while (*p != '\0' && *p == ':') - ++p; - if (*p == ':') + if (*p != '\0') { char *endp; char *q = ++p; long int val; - q = p; while (*q != '\0' && *q != ':') ++q; From 38eb61366303c2857f1b00785757bc21da983d70 Mon Sep 17 00:00:00 2001 From: Suzuki Poulose Date: Wed, 2 Sep 2009 19:58:50 -0700 Subject: [PATCH 4/5] Fix timer_create to initialize timer_t properly. --- nptl/ChangeLog | 8 ++++++++ nptl/sysdeps/unix/sysv/linux/timer_create.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 911312ffc4..422172267b 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,11 @@ +2009-09-02 Suzuki K P + Joseph Myers + + [BZ #7094] + * sysdeps/unix/sysv/linux/timer_create.c (timer_create): + Initialize the sigev_notify field for newly created timer to make sure + the timer gets deleted from the active timer's list upon timer_delete. + 2009-08-27 Andrew Stubbs * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_timedlock_wait): diff --git a/nptl/sysdeps/unix/sysv/linux/timer_create.c b/nptl/sysdeps/unix/sysv/linux/timer_create.c index a07234d7d1..cdf127cb44 100644 --- a/nptl/sysdeps/unix/sysv/linux/timer_create.c +++ b/nptl/sysdeps/unix/sysv/linux/timer_create.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003,2004, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2003. @@ -167,6 +167,7 @@ timer_create (clock_id, evp, timerid) /* Copy the thread parameters the user provided. */ newp->sival = evp->sigev_value; newp->thrfunc = evp->sigev_notify_function; + newp->sigev_notify = SIGEV_THREAD; /* We cannot simply copy the thread attributes since the implementation might keep internal information for From 01034d7590f0db29a689d0037cf9b837e38e7482 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 2 Sep 2009 19:59:43 -0700 Subject: [PATCH 5/5] Fix whitespaces. --- nptl/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 422172267b..b73ab9cd18 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -4,7 +4,7 @@ [BZ #7094] * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Initialize the sigev_notify field for newly created timer to make sure - the timer gets deleted from the active timer's list upon timer_delete. + the timer gets deleted from the active timer's list upon timer_delete. 2009-08-27 Andrew Stubbs