Clean up definition of _LIBC_REENTRANT and _IO_MTSAFE_IO.

This commit is contained in:
Roland McGrath 2012-08-17 09:35:15 -07:00
parent d9195db871
commit c75ccd4c3a
18 changed files with 111 additions and 61 deletions

View File

@ -1,3 +1,43 @@
2012-08-17 Roland McGrath <roland@hack.frob.com>
* Makeconfig [$(libc-reentrant) = yes] (libio-mtsafe): New variable.
* libio/Makefile (CPPFLAGS): Append $(libio-mtsafe) unconditionally
rather than -D_IO_MTSAFE_IO conditionally.
* stdio-common/Makefile (CPPFLAGS): Likewise.
* wcsmbs/Makefile (CPPFLAGS): Likewise.
* stdlib/Makefile (CFLAGS-strfmon.c, CFLAGS-strfmon_l.c):
Use $(libio-mtsafe).
* debug/Makefile (CFLAGS-sprintf_chk.c): Use $(libio-mtsafe) instead
of -D_IO_MTSAFE_IO.
(CFLAGS-snprintf_chk.c, CFLAGS-vsprintf_chk.c): Likewise.
(CFLAGS-vsnprintf_chk.c, CFLAGS-asprintf_chk.c): Likewise.
(CFLAGS-vasprintf_chk.c, CFLAGS-obprintf_chk.c): Likewise.
(CFLAGS-dprintf_chk.c, CFLAGS-vdprintf_chk.c): Likewise.
(CFLAGS-printf_chk.c, CFLAGS-fprintf_chk.c): Likewise.
(CFLAGS-vprintf_chk.c, CFLAGS-vfprintf_chk.c): Likewise.
(CFLAGS-gets_chk.c, CFLAGS-fgets_chk.c): Likewise.
(CFLAGS-fgets_u_chk.c, CFLAGS-fread_chk.c): Likewise.
(CFLAGS-fread_u_chk.c): Likewise.
(CFLAGS-swprintf_chk.c, CFLAGS-vswprintf_chk.c): Likewise.
(CFLAGS-wprintf_chk.c, CFLAGS-fwprintf_chk.c): Likewise.
(CFLAGS-vwprintf_chk.c, CFLAGS-vfwprintf_chk.c): Likewise.
(CFLAGS-fgetws_chk.c, CFLAGS-fgetws_u_chk.c): Likewise.
* grp/Makefile (CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c): Likewise.
* gshadow/Makefile (CFLAGS-fgetsgent_r.c, CFLAGS-putsgent.c): Likewise.
* misc/Makefile (CFLAGS-mntent_r.c): Likewise.
* pwd/Makefile (CFLAGS-fgetpwent_r.c): Likewise.
* shadow/Makefile (CFLAGS-fgetspent_r.c, CFLAGS-putspent.c): Likewise.
* libio/Makefile: Test [$(libc-reentrant) = yes]
instead of [$(filter %REENTRANT, $(defines)) nonempty].
* Makeconfig
[$(libc-reentrant) = yes] (defines): Append -D_LIBC_REENTRANT.
* sysdeps/pthread/configure: File removed.
* sysdeps/pthread/Makeconfig: New file.
* sysdeps/mach/hurd/Makeconfig (libc-reentrant): New variable.
* sysdeps/mach/hurd/configure.in: Don't touch DEFINES here.
2012-08-16 Gary Benson <gbenson@redhat.com>
* elf/dl-close.c (_dl_close_worker): Also set r->r_map when

View File

@ -1005,6 +1005,13 @@ endif
sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
$(firstword $(subst :, ,$p))))
# A sysdeps Makeconfig fragment may set libc-reentrant to yes.
ifeq (yes,$(libc-reentrant))
defines += -D_LIBC_REENTRANT
libio-mtsafe = -D_IO_MTSAFE_IO
endif
endif # Makeconfig not yet included
# Local Variables:

View File

@ -1,4 +1,4 @@
# Copyright (C) 1998-2001,2004-2008, 2009, 2011, 2012 Free Software Foundation, Inc.
# Copyright (C) 1998-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -48,32 +48,32 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
static-only-routines := warning-nop stack_chk_fail_local
CFLAGS-backtrace.c = -fno-omit-frame-pointer
CFLAGS-sprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-snprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-vsprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-vsnprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-asprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-vasprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-obprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-dprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-vdprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-printf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-vprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-vfprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-gets_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fgets_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fgets_u_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fread_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fread_u_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-swprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-vswprintf_chk.c = -D_IO_MTSAFE_IO
CFLAGS-wprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fwprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-vwprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-vfwprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fgetws_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-fgetws_u_chk.c = -D_IO_MTSAFE_IO $(exceptions)
CFLAGS-sprintf_chk.c = $(libio-mtsafe)
CFLAGS-snprintf_chk.c = $(libio-mtsafe)
CFLAGS-vsprintf_chk.c = $(libio-mtsafe)
CFLAGS-vsnprintf_chk.c = $(libio-mtsafe)
CFLAGS-asprintf_chk.c = $(libio-mtsafe)
CFLAGS-vasprintf_chk.c = $(libio-mtsafe)
CFLAGS-obprintf_chk.c = $(libio-mtsafe)
CFLAGS-dprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-vdprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-printf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-vprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-vfprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-gets_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fgets_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fgets_u_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fread_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fread_u_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-swprintf_chk.c = $(libio-mtsafe)
CFLAGS-vswprintf_chk.c = $(libio-mtsafe)
CFLAGS-wprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fwprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-vwprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-vfwprintf_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fgetws_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-fgetws_u_chk.c = $(libio-mtsafe) $(exceptions)
CFLAGS-read_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread64_chk.c = -fexceptions -fasynchronous-unwind-tables

View File

@ -1,5 +1,4 @@
# Copyright (C) 1991,1992,1996-2000,2003,2004,2012
# Free Software Foundation, Inc.
# Copyright (C) 1991-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -44,8 +43,8 @@ CFLAGS-getgrnam_r.c = -DUSE_NSCD=1 -fexceptions
CFLAGS-getgrent_r.c = -fexceptions
CFLAGS-getgrent.c = -fexceptions
CFLAGS-fgetgrent.c = -fexceptions
CFLAGS-fgetgrent_r.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-putgrent.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-fgetgrent_r.c = -fexceptions $(libio-mtsafe)
CFLAGS-putgrent.c = -fexceptions $(libio-mtsafe)
CFLAGS-initgroups.c = -DUSE_NSCD=1 -fexceptions
CFLAGS-getgrgid.c = -fexceptions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2009 Free Software Foundation, Inc.
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -29,8 +29,8 @@ tests = tst-gshadow
CFLAGS-getsgent_r.c = -fexceptions
CFLAGS-getsgent.c = -fexceptions
CFLAGS-fgetsgent.c = -fexceptions
CFLAGS-fgetsgent_r.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-putsgent.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-fgetsgent_r.c = -fexceptions $(libio-mtsafe)
CFLAGS-putsgent.c = -fexceptions $(libio-mtsafe)
CFLAGS-getsgnam.c = -fexceptions
CFLAGS-getsgnam_r.c = -fexceptions

View File

@ -70,14 +70,14 @@ routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
oldiofsetpos64
endif
ifneq (,$(filter %REENTRANT, $(defines)))
ifeq (yes,$(libc-reentrant))
routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \
iofputs_u
CPPFLAGS += -D_IO_MTSAFE_IO
endif
CPPFLAGS += $(libio-mtsafe)
# Support for exception handling.
CFLAGS-fileops.c = $(exceptions)
CFLAGS-fputc.c = $(exceptions)

View File

@ -1,3 +1,9 @@
2012-08-15 Roland McGrath <roland@hack.frob.com>
* Makefile (CFLAGS-flockfile.c): Use $(libio-mtsafe) instead
of -D_IO_MTSAFE_IO.
(CFLAGS-ftrylockfile.c, CFLAGS-funlockfile.c): Likewise.
2012-08-16 Joseph Myers <joseph@codesourcery.com>
* pthread_cond_timedwait.c (__pthread_cond_timedwait)

View File

@ -341,9 +341,9 @@ extra-objs += $(crti-objs) $(crtn-objs)
extra-objs += pt-crti.o
endif
CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
CFLAGS-ftrylockfile.c = -D_IO_MTSAFE_IO
CFLAGS-funlockfile.c = -D_IO_MTSAFE_IO
CFLAGS-flockfile.c = $(libio-mtsafe)
CFLAGS-ftrylockfile.c = $(libio-mtsafe)
CFLAGS-funlockfile.c = $(libio-mtsafe)
link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
$(common-objpfx)libc.a

View File

@ -1,4 +1,4 @@
# Copyright (C) 1991,1996-1999,2003,2004 Free Software Foundation, Inc.
# Copyright (C) 1991-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -36,6 +36,6 @@ CFLAGS-getpwnam_r.c = -DUSE_NSCD=1
CFLAGS-getpwent_r.c = -fexceptions
CFLAGS-getpwent.c = -fexceptions
CFLAGS-getpw.c = -fexceptions
CFLAGS-fgetpwent_r.c = -D_IO_MTSAFE_IO
CFLAGS-fgetpwent_r.c = $(libio-mtsafe)
endif

View File

@ -1,4 +1,4 @@
# Copyright (C) 1996, 2003, 2004, 2009 Free Software Foundation, Inc.
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -30,8 +30,8 @@ tests = tst-shadow
CFLAGS-getspent_r.c = -fexceptions
CFLAGS-getspent.c = -fexceptions
CFLAGS-fgetspent.c = -fexceptions
CFLAGS-fgetspent_r.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-putspent.c = -fexceptions -D_IO_MTSAFE_IO
CFLAGS-fgetspent_r.c = -fexceptions $(libio-mtsafe)
CFLAGS-putspent.c = -fexceptions $(libio-mtsafe)
CFLAGS-getspnam.c = -fexceptions
CFLAGS-getspnam_r.c = -fexceptions

View File

@ -123,9 +123,7 @@ scanf13-ENV = LOCPATH=$(common-objpfx)localedata
bug14-ENV = LOCPATH=$(common-objpfx)localedata
tst-grouping-ENV = LOCPATH=$(common-objpfx)localedata
ifneq (,$(filter %REENTRANT, $(defines)))
CPPFLAGS += -D_IO_MTSAFE_IO
endif
CPPFLAGS += $(libio-mtsafe)
$(objpfx)tst-setvbuf1.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1
$(built-program-cmd) > $@ 2>&1

View File

@ -28,13 +28,17 @@ __isoc99_scanf (const char *format, ...)
va_list arg;
int done;
#ifdef _IO_MTSAFE_IO
_IO_acquire_lock_clear_flags2 (stdin);
#endif
stdin->_flags2 |= _IO_FLAGS2_SCANF_STD;
va_start (arg, format);
done = _IO_vfscanf (stdin, format, arg, NULL);
va_end (arg);
#ifdef _IO_MTSAFE_IO
_IO_release_lock (stdin);
#endif
return done;
}

View File

@ -100,10 +100,8 @@ CFLAGS-system.c = -fexceptions
CFLAGS-system.os = -fomit-frame-pointer
CFLAGS-fmtmsg.c = -fexceptions
ifneq (,$(filter %REENTRANT, $(defines)))
CFLAGS-strfmon.c = -D_IO_MTSAFE_IO
CFLAGS-strfmon_l.c = -D_IO_MTSAFE_IO
endif
CFLAGS-strfmon.c = $(libio-mtsafe)
CFLAGS-strfmon_l.c = $(libio-mtsafe)
CFLAGS-tst-bsearch.c = $(stack-align-test-flags)
CFLAGS-tst-qsort.c = $(stack-align-test-flags)

View File

@ -2,3 +2,6 @@
# See Makefile in this directory for the rule that builds this.
# We must define this variable earlier than sysdeps Makefiles are included.
static-start-installed-name = crt0.o
# GNU libc on the Hurd is always reentrant.
libc-reentrant = yes

View File

@ -1,8 +1,5 @@
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
# GNU libc on the Hurd is always reentrant.
DEFINES="$DEFINES -D_LIBC_REENTRANT"
dnl We need this setting because of the need for PLT calls in ld.so.
AC_DEFINE([NO_HIDDEN])

View File

@ -0,0 +1,2 @@
# Compile libc code to do internal locking.
libc-reentrant = yes

View File

@ -1,3 +0,0 @@
# Local configure fragment for sysdeps/pthread.
DEFINES="$DEFINES -D_LIBC_REENTRANT"

View File

@ -72,9 +72,8 @@ CFLAGS-isoc99_wscanf.c += $(exceptions)
CFLAGS-isoc99_fwscanf.c += $(exceptions)
CFLAGS-isoc99_vwscanf.c += $(exceptions)
CFLAGS-isoc99_vfwscanf.c += $(exceptions)
ifneq (,$(filter %REENTRANT, $(defines)))
CPPFLAGS += -D_IO_MTSAFE_IO
endif
CPPFLAGS += $(libio-mtsafe)
# We need to find the default version of strtold_l in stdlib.
CPPFLAGS-wcstold_l.c = -I../stdlib