From eb4063467c4ef625c1687b4c158bacf475821363 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 4 May 1998 13:19:20 +0000 Subject: Update. 1998-05-04 12:40 Ulrich Drepper * malloc/malloc.c (ptmalloc_init_all): New function. Similar to ptmalloc_unlock_all, but re-initializes the mutexes instead. (ptmalloc_init): Use new function in thread_at_fork call. (thread_atfork_static): Likewise. Suggested by Wolfram Gloger and Xavier Leroy. --- ChangeLog | 8 +++++++ Makerules | 11 ++++------ bits/sigstack.h | 39 +++++++++++++++++++++++++++++++++ elf/rtld.c | 6 ++--- malloc/malloc.c | 24 +++++++++++++++++--- manual/terminal.texi | 4 ++-- signal/Makefile | 2 +- signal/signal.h | 21 +++++------------- sysdeps/generic/bits/sigstack.h | 39 +++++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/bits/sigstack.h | 39 +++++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/tcgetattr.c | 22 +++++++++++++++---- sysdeps/unix/sysv/linux/tcsetattr.c | 8 +++---- 12 files changed, 182 insertions(+), 41 deletions(-) create mode 100644 bits/sigstack.h create mode 100644 sysdeps/generic/bits/sigstack.h create mode 100644 sysdeps/unix/sysv/linux/bits/sigstack.h diff --git a/ChangeLog b/ChangeLog index ad736aeb87..8aac056300 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1998-05-04 12:40 Ulrich Drepper + + * malloc/malloc.c (ptmalloc_init_all): New function. Similar to + ptmalloc_unlock_all, but re-initializes the mutexes instead. + (ptmalloc_init): Use new function in thread_at_fork call. + (thread_atfork_static): Likewise. + Suggested by Wolfram Gloger and Xavier Leroy. + 1998-05-04 Ulrich Drepper * signal/signal.h: Move definitions of struct sigstack and diff --git a/Makerules b/Makerules index 5302c949f2..76cbe6b1be 100644 --- a/Makerules +++ b/Makerules @@ -451,14 +451,11 @@ extra-libs-left := $(extra-libs) include $(patsubst %,$(..)extra-lib.mk,$(extra-libs)) endif ++depfiles := $(sources:.c=.d) \ + $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ + $(addsuffix .d,$(tests) $(test-srcs) $(tests-static)) ifeq ($(build-programs),yes) -+depfiles := $(strip $(sources:.c=.d) \ - $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ - $(addsuffix .d,$(others) $(tests) $(test-srcs))) -else -+depfiles := $(strip $(sources:.c=.d) \ - $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ - $(addsuffix .d,$(tests) $(test-srcs))) ++depfiles += $(addsuffix .d,$(others)) endif +depfiles := $(addprefix $(objpfx),\ $(filter-out $(addsuffix .d,$(omit-deps)),\ diff --git a/bits/sigstack.h b/bits/sigstack.h new file mode 100644 index 0000000000..3a58e8bb58 --- /dev/null +++ b/bits/sigstack.h @@ -0,0 +1,39 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 1998 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SIGNAL_H +# error "Never include this file directly. Use instead" +#endif + + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + __ptr_t ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + + +/* Alternate, preferred interface. */ +typedef struct sigaltstack + { + __ptr_t ss_sp; + size_t ss_size; + int ss_flags; + } stack_t; diff --git a/elf/rtld.c b/elf/rtld.c index 6b1a5c2b73..868ed2c075 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -485,14 +485,12 @@ of this helper program; chances are you did not intend to run this program.\n\ is specified (i.e., this is no dynamically linked binary. */ if (main_map->l_ld == NULL) _exit (1); - if (!has_interp) - _exit (2); /* We allow here some platform specific code. */ #ifdef DISTINGUISH_LIB_VERSIONS DISTINGUISH_LIB_VERSIONS; #endif - _exit (0); + _exit (has_interp ? 0 : 2); } if (! paths_initialized) @@ -645,7 +643,7 @@ of this helper program; chances are you did not intend to run this program.\n\ if (_dl_rtld_map.l_next) _dl_rtld_map.l_next->l_prev = _dl_rtld_map.l_prev; - if (_dl_rtld_map.l_opencount) + if (_dl_rtld_map.l_opencount > 1) { /* Some DT_NEEDED entry referred to the interpreter object itself, so put it back in the list of visible objects. We insert it into the diff --git a/malloc/malloc.c b/malloc/malloc.c index 3d4933cd7c..4a65f520d7 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger and Doug Lea , 1996. @@ -1579,6 +1579,24 @@ ptmalloc_unlock_all __MALLOC_P((void)) (void)mutex_unlock(&list_lock); } +static void +ptmalloc_init_all __MALLOC_P((void)) +{ + arena *ar_ptr; + +#if defined _LIBC || defined MALLOC_HOOKS + tsd_setspecific(arena_key, save_arena); + __malloc_hook = save_malloc_hook; + __free_hook = save_free_hook; +#endif + for(ar_ptr = &main_arena;;) { + (void)mutex_init(&ar_ptr->mutex); + ar_ptr = ar_ptr->next; + if(ar_ptr == &main_arena) break; + } + (void)mutex_init(&list_lock); +} + /* Initialization routine. */ #if defined(_LIBC) #if 0 @@ -1617,7 +1635,7 @@ ptmalloc_init __MALLOC_P((void)) mutex_init(&list_lock); tsd_key_create(&arena_key, NULL); tsd_setspecific(arena_key, (Void_t *)&main_arena); - thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all); + thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_init_all); #endif #if defined _LIBC || defined MALLOC_HOOKS if((s = getenv("MALLOC_TRIM_THRESHOLD_"))) @@ -1644,7 +1662,7 @@ ptmalloc_init __MALLOC_P((void)) /* There are platforms (e.g. Hurd) with a link-time hook mechanism. */ #ifdef thread_atfork_static thread_atfork_static(ptmalloc_lock_all, ptmalloc_unlock_all, \ - ptmalloc_unlock_all) + ptmalloc_init_all) #endif #if defined _LIBC || defined MALLOC_HOOKS diff --git a/manual/terminal.texi b/manual/terminal.texi index bd897ab06e..f9aeaeee5a 100644 --- a/manual/terminal.texi +++ b/manual/terminal.texi @@ -1135,8 +1135,8 @@ The particular characters used are specified in the @code{c_cc} member of the @code{struct termios} structure. This member is an array; each element specifies the character for a particular role. Each element has a symbolic constant that stands for the index of that element---for -example, @code{INTR} is the index of the element that specifies the INTR -character, so storing @code{'='} in @code{@var{termios}.c_cc[INTR]} +example, @code{VINTR} is the index of the element that specifies the INTR +character, so storing @code{'='} in @code{@var{termios}.c_cc[VINTR]} specifies @samp{=} as the INTR character. @vindex _POSIX_VDISABLE diff --git a/signal/Makefile b/signal/Makefile index 0642f75718..cec0782df3 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -22,7 +22,7 @@ subdir := signal headers := signal.h sys/signal.h bits/signum.h bits/sigcontext.h \ - bits/sigaction.h bits/sigset.h bits/siginfo.h + bits/sigaction.h bits/sigset.h bits/siginfo.h bits/sigstack.h routines := signal raise killpg \ sigaction sigprocmask kill \ diff --git a/signal/signal.h b/signal/signal.h index bbca812b6d..b42d897f8b 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -318,27 +318,16 @@ extern int sigreturn __P ((struct sigcontext *__scp)); calls be restarted after signal SIG. */ extern int siginterrupt __P ((int __sig, int __interrupt)); - -/* Structure describing a signal stack. */ -struct sigstack - { - __ptr_t ss_sp; /* Signal stack pointer. */ - int ss_onstack; /* Nonzero if executing on this stack. */ - }; +# include /* Run signals handlers on the stack specified by SS (if not NULL). - If OSS is not NULL, it is filled in with the old signal stack status. */ + If OSS is not NULL, it is filled in with the old signal stack status. + This interface is obsolete and on many platform not implemented. */ extern int sigstack __P ((__const struct sigstack *__ss, struct sigstack *__oss)); -/* Alternate interface. */ -typedef struct sigaltstack - { - __ptr_t ss_sp; - int ss_flags; - size_t ss_size; - } stack_t; - +/* Alternate signal handler stack interface. + This interface should always be preferred over `sigstack'. */ extern int sigaltstack __P ((__const struct sigaltstack *__ss, struct sigaltstack *__oss)); diff --git a/sysdeps/generic/bits/sigstack.h b/sysdeps/generic/bits/sigstack.h new file mode 100644 index 0000000000..3a58e8bb58 --- /dev/null +++ b/sysdeps/generic/bits/sigstack.h @@ -0,0 +1,39 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 1998 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SIGNAL_H +# error "Never include this file directly. Use instead" +#endif + + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + __ptr_t ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + + +/* Alternate, preferred interface. */ +typedef struct sigaltstack + { + __ptr_t ss_sp; + size_t ss_size; + int ss_flags; + } stack_t; diff --git a/sysdeps/unix/sysv/linux/bits/sigstack.h b/sysdeps/unix/sysv/linux/bits/sigstack.h new file mode 100644 index 0000000000..a86473839c --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/sigstack.h @@ -0,0 +1,39 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 1998 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SIGNAL_H +# error "Never include this file directly. Use instead" +#endif + + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + __ptr_t ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + + +/* Alternate, preferred interface. */ +typedef struct sigaltstack + { + __ptr_t ss_sp; + int ss_flags; + size_t ss_size; + } stack_t; diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c index 7866183abe..cbb372f317 100644 --- a/sysdeps/unix/sysv/linux/tcgetattr.c +++ b/sysdeps/unix/sysv/linux/tcgetattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995, 1997, 1998 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 @@ -16,7 +16,9 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +#include #include #include @@ -33,7 +35,6 @@ __tcgetattr (fd, termios_p) { struct __kernel_termios k_termios; int retval; - size_t cnt; retval = __ioctl (fd, TCGETS, &k_termios); @@ -48,8 +49,21 @@ __tcgetattr (fd, termios_p) #ifdef _HAVE_C_OSPEED termios_p->c_ospeed = k_termios.c_ospeed; #endif - for (cnt = 0; cnt < __KERNEL_NCCS; ++cnt) - termios_p->c_cc[cnt] = k_termios.c_cc[cnt]; + if (sizeof (cc_t) == 1 || _POSIX_VDISABLE == 0 + || (unsigned char) _POSIX_VDISABLE == (unsigned char) -1) + memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], + __KERNEL_NCCS * sizeof (cc_t)), + _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t)); + else + { + size_t cnt; + + memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], + __KERNEL_NCCS * sizeof (cc_t)); + + for (cnt = __KERNEL_NCCS; cnt < NCCS; ++cnt) + termios_p->c_cc[cnt] = _POSIX_VDISABLE; + } return retval; } diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c index 0b9fee2165..dee491564f 100644 --- a/sysdeps/unix/sysv/linux/tcsetattr.c +++ b/sysdeps/unix/sysv/linux/tcsetattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1996, 1997, 1998 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 @@ -17,6 +17,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include #include @@ -36,7 +37,6 @@ tcsetattr (fd, optional_actions, termios_p) { struct __kernel_termios k_termios; unsigned long int cmd; - size_t cnt; switch (optional_actions) { @@ -65,8 +65,8 @@ tcsetattr (fd, optional_actions, termios_p) #ifdef _HAVE_C_OSPEED k_termios.c_ospeed = termios_p->c_ospeed; #endif - for (cnt = 0; cnt < __KERNEL_NCCS; ++cnt) - k_termios.c_cc[cnt] = termios_p->c_cc[cnt]; + memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0], + __KERNEL_NCCS * sizeof (cc_t)); return __ioctl (fd, cmd, &k_termios); } -- cgit 1.4.1