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.
This commit is contained in:
Ulrich Drepper 2002-08-27 06:41:29 +00:00
parent 3832592395
commit b50f38778c
7 changed files with 130 additions and 12 deletions

View File

@ -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> 2002-08-26 Roland McGrath <roland@redhat.com>
* sysdeps/generic/sigset-cvt-mask.h (sigset_set_old_mask): Replace * sysdeps/generic/sigset-cvt-mask.h (sigset_set_old_mask): Replace

View File

@ -51,11 +51,14 @@
#if USE_TLS && HAVE___THREAD #if USE_TLS && HAVE___THREAD
# define __libc_tsd_define(CLASS, KEY) CLASS __thread void *__libc_tsd_##KEY; # 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 #else
# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY; # define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
# define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data)
# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE))
#endif #endif
#define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
#define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
#endif /* bits/libc-tsd.h */ #endif /* bits/libc-tsd.h */

View File

@ -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-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ 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 test-srcs = test-freopen
all: # Make this the default target; it will be defined in Rules. all: # Make this the default target; it will be defined in Rules.

100
libio/bug-fopena+.c Normal file
View File

@ -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;
}

View File

@ -66,7 +66,7 @@ __thread void *__libc_tsd_LOCALE = &_nl_global_locale;
__libc_tsd_define (, LOCALE) __libc_tsd_define (, LOCALE)
/* This is a bad kludge presuming the variable name used by the macros. /* 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. */ 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
#endif #endif

View File

@ -31,14 +31,14 @@ main (void)
if (n != nexp) \ if (n != nexp) \
{ \ { \
printf ("swprintf (.., .., L\"%ls\", \"%ls\") return %d, not %d\n", \ 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; \ result = 1; \
} \ } \
else if (wcscmp (buf, exp) != 0) \ else if (wcscmp (buf, exp) != 0) \
{ \ { \
printf ("\ printf ("\
swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n", \ swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n", \
fmt, input, buf, exp ); \ fmt, (wchar_t *) input, buf, exp ); \
result = 1; \ result = 1; \
} }

View File

@ -51,11 +51,14 @@
#if USE_TLS && HAVE___THREAD #if USE_TLS && HAVE___THREAD
# define __libc_tsd_define(CLASS, KEY) CLASS __thread void *__libc_tsd_##KEY; # 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 #else
# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY; # define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
# define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data)
# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE))
#endif #endif
#define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
#define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
#endif /* bits/libc-tsd.h */ #endif /* bits/libc-tsd.h */