diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-08-27 06:41:29 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-08-27 06:41:29 +0000 |
commit | b50f38778c306b3f0ec0c3ed05acf9ce10508aa4 (patch) | |
tree | fb5b26cc02ec01c04f8573a2103b11c412aab6fc | |
parent | 38325923950d9dbdad735aa4bc8ce54977ef572c (diff) | |
download | glibc-b50f38778c306b3f0ec0c3ed05acf9ce10508aa4.tar.gz glibc-b50f38778c306b3f0ec0c3ed05acf9ce10508aa4.tar.xz glibc-b50f38778c306b3f0ec0c3ed05acf9ce10508aa4.zip |
Update.
2002-08-26 Ulrich Drepper <drepper@redhat.com> * libio/Makefile (tests): Add bug-fopena+. * libio/bug-fopena+.c: New file. * stdio-common/tst-swprintf.c (main): Add casts to avoid warnings. * locale/xlocale.c: Fix the last change. The variable still has to end in _data. * sysdeps/generic/bits/libc-tsd.h [!(USE_TLS && HAVE___THREAD)] (__libc_tsd_set): Add _data prefix to variable name.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | bits/libc-tsd.h | 11 | ||||
-rw-r--r-- | libio/Makefile | 2 | ||||
-rw-r--r-- | libio/bug-fopena+.c | 100 | ||||
-rw-r--r-- | locale/xlocale.c | 2 | ||||
-rw-r--r-- | stdio-common/tst-swprintf.c | 4 | ||||
-rw-r--r-- | sysdeps/generic/bits/libc-tsd.h | 11 |
7 files changed, 130 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog index ba25039d03..56fc0dfd59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-08-26 Ulrich Drepper <drepper@redhat.com> + + * libio/Makefile (tests): Add bug-fopena+. + * libio/bug-fopena+.c: New file. + + * stdio-common/tst-swprintf.c (main): Add casts to avoid warnings. + + * locale/xlocale.c: Fix the last change. The variable still has + to end in _data. + * sysdeps/generic/bits/libc-tsd.h [!(USE_TLS && HAVE___THREAD)] + (__libc_tsd_set): Add _data prefix to variable name. + 2002-08-26 Roland McGrath <roland@redhat.com> * sysdeps/generic/sigset-cvt-mask.h (sigset_set_old_mask): Replace diff --git a/bits/libc-tsd.h b/bits/libc-tsd.h index fc17be108e..3c77e1519f 100644 --- a/bits/libc-tsd.h +++ b/bits/libc-tsd.h @@ -51,11 +51,14 @@ #if USE_TLS && HAVE___THREAD # define __libc_tsd_define(CLASS, KEY) CLASS __thread void *__libc_tsd_##KEY; + +# define __libc_tsd_get(KEY) (__libc_tsd_##KEY) +# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) #else -# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY; -#endif +# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data; -#define __libc_tsd_get(KEY) (__libc_tsd_##KEY) -#define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) +# define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data) +# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE)) +#endif #endif /* bits/libc-tsd.h */ diff --git a/libio/Makefile b/libio/Makefile index a6d3a24cc1..72a6badabd 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -53,7 +53,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \ tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ - tst-mmap2-eofsync tst-mmap-offend + tst-mmap2-eofsync tst-mmap-offend bug-fopena+ test-srcs = test-freopen all: # Make this the default target; it will be defined in Rules. diff --git a/libio/bug-fopena+.c b/libio/bug-fopena+.c new file mode 100644 index 0000000000..5446de1592 --- /dev/null +++ b/libio/bug-fopena+.c @@ -0,0 +1,100 @@ +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +static int fd; +static char *fname; + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + + +#define TEST_FUNCTION do_test () +static int do_test (void); +#include "../test-skeleton.c" + + +static void +prepare (void) +{ + fd = create_temp_file ("wrewind.", &fname); + if (fd == -1) + exit (3); +} + + +static int +do_test (void) +{ + char buf[100]; + FILE *fp; + int result = 0; + + fp = fdopen (fd, "w"); + if (fp == NULL) + { + puts ("cannot create file"); + exit (1); + } + + if (fputs ("one\n", fp) == EOF || fputs ("two\n", fp) == EOF) + { + puts ("cannot create filec content"); + exit (1); + } + + fclose (fp); + + fp = fopen (fname, "a+"); + if (fp == NULL) + { + puts ("cannot fopen a+"); + exit (1); + } + + if (fgets (buf, sizeof (buf), fp) == NULL) + { + puts ("cannot read after fopen a+"); + exit (1); + } + + if (strcmp (buf, "one\n") != 0) + { + puts ("read after fopen a+ produced wrong result"); + result = 1; + } + + fclose (fp); + + fd = open (fname, O_RDWR); + if (fd == -1) + { + puts ("open failed"); + exit (1); + } + + fp = fdopen (fd, "a+"); + if (fp == NULL) + { + puts ("fopen after open failed"); + exit (1); + } + + if (fgets (buf, sizeof (buf), fp) == NULL) + { + puts ("cannot read after fdopen a+"); + exit (1); + } + + if (strcmp (buf, "one\n") != 0) + { + puts ("read after fdopen a+ produced wrong result"); + result = 1; + } + + fclose (fp); + + return result; +} diff --git a/locale/xlocale.c b/locale/xlocale.c index d90437e1f9..854584cca4 100644 --- a/locale/xlocale.c +++ b/locale/xlocale.c @@ -66,7 +66,7 @@ __thread void *__libc_tsd_LOCALE = &_nl_global_locale; __libc_tsd_define (, LOCALE) /* This is a bad kludge presuming the variable name used by the macros. Using typeof makes sure to barf if we do not match the macro definition. */ -__typeof (__libc_tsd_LOCALE) __libc_tsd_LOCALE_data = &_nl_global_locale; +__typeof (__libc_tsd_LOCALE_data) __libc_tsd_LOCALE_data = &_nl_global_locale; # endif #endif diff --git a/stdio-common/tst-swprintf.c b/stdio-common/tst-swprintf.c index a7e232dd4f..e65234b1c2 100644 --- a/stdio-common/tst-swprintf.c +++ b/stdio-common/tst-swprintf.c @@ -31,14 +31,14 @@ main (void) if (n != nexp) \ { \ printf ("swprintf (.., .., L\"%ls\", \"%ls\") return %d, not %d\n", \ - fmt, input, (int) n, (int) nexp); \ + fmt, (wchar_t*) input, (int) n, (int) nexp); \ result = 1; \ } \ else if (wcscmp (buf, exp) != 0) \ { \ printf ("\ swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n", \ - fmt, input, buf, exp ); \ + fmt, (wchar_t *) input, buf, exp ); \ result = 1; \ } diff --git a/sysdeps/generic/bits/libc-tsd.h b/sysdeps/generic/bits/libc-tsd.h index fc17be108e..3c77e1519f 100644 --- a/sysdeps/generic/bits/libc-tsd.h +++ b/sysdeps/generic/bits/libc-tsd.h @@ -51,11 +51,14 @@ #if USE_TLS && HAVE___THREAD # define __libc_tsd_define(CLASS, KEY) CLASS __thread void *__libc_tsd_##KEY; + +# define __libc_tsd_get(KEY) (__libc_tsd_##KEY) +# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) #else -# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY; -#endif +# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data; -#define __libc_tsd_get(KEY) (__libc_tsd_##KEY) -#define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) +# define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data) +# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE)) +#endif #endif /* bits/libc-tsd.h */ |