Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ulrich Drepper committed Aug 27, 2002
1 parent 3832592 commit b50f387
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 12 deletions.
12 changes: 12 additions & 0 deletions 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
Expand Down
11 changes: 7 additions & 4 deletions bits/libc-tsd.h
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion libio/Makefile
Expand Up @@ -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.
Expand Down
100 changes: 100 additions & 0 deletions 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;
}
2 changes: 1 addition & 1 deletion locale/xlocale.c
Expand Up @@ -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
4 changes: 2 additions & 2 deletions stdio-common/tst-swprintf.c
Expand Up @@ -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; \
}

Expand Down
11 changes: 7 additions & 4 deletions sysdeps/generic/bits/libc-tsd.h
Expand Up @@ -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 */

0 comments on commit b50f387

Please sign in to comment.