diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/abort-instr.h | 2 | ||||
-rw-r--r-- | sysdeps/generic/abort.c | 99 | ||||
-rw-r--r-- | sysdeps/i386/abort-instr.h | 2 | ||||
-rw-r--r-- | sysdeps/i386/fpu_control.h | 36 | ||||
-rw-r--r-- | sysdeps/unix/common/pause.c | 28 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/timebits.h | 17 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/fcntlbits.h | 28 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ioctls.h | 26 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/m68k/setjmp.c | 83 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sigcontext.h | 32 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/acct.h | 32 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/timebits.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/utsnamelen.h | 27 |
13 files changed, 282 insertions, 134 deletions
diff --git a/sysdeps/generic/abort-instr.h b/sysdeps/generic/abort-instr.h new file mode 100644 index 0000000..106a330 --- /dev/null +++ b/sysdeps/generic/abort-instr.h @@ -0,0 +1,2 @@ +/* We cannot give any generic instruction to crash the program. + abort() will have to make sure it never returns. */ diff --git a/sysdeps/generic/abort.c b/sysdeps/generic/abort.c index 61b9937..604eadc 100644 --- a/sysdeps/generic/abort.c +++ b/sysdeps/generic/abort.c @@ -16,16 +16,26 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <libc-lock.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <signal.h> +/* Try to get a machine dependent instruction which will make the + program crash. This is used in case everything else fails. */ +#include "abort-instr.h" +#ifndef ABORT_INSTRUCTION +/* No such instruction is available. */ +# define ABORT_INSTRUCTION +#endif + +/* We must avoid to run in circles. Therefore we remember how far we + already got. */ +static int stage; -/* Function to close all streams and also make sure we don't loop by - calling abort while closing the streams. */ -extern void __close_all_streams (void); +/* We should be prepared for multiple threads trying to run abort. */ +__libc_lock_define_initialized_recursive (static, lock); /* Cause an abnormal program termination with core-dump. */ @@ -35,41 +45,78 @@ abort (void) struct sigaction act; sigset_t sigs; - if (__sigemptyset (&sigs) == 0 && - __sigaddset (&sigs, SIGABRT) == 0) - __sigprocmask (SIG_UNBLOCK, &sigs, (sigset_t *) NULL); + /* First acquire the lock. */ + __libc_lock_lock (lock); + + /* Now it's for sure we are alone. But recursive calls are possible. */ - /* If there is a user handler installed use it. We don't close or - flush streams. */ - if (__sigaction (SIGABRT, NULL, &act) >= 0 - && act.sa_handler != SIG_DFL) + /* Unlock SIGABRT. */ + if (stage == 0) { - /* Send signal to call user handler. */ - raise (SIGABRT); + ++stage; + if (__sigemptyset (&sigs) == 0 && + __sigaddset (&sigs, SIGABRT) == 0) + __sigprocmask (SIG_UNBLOCK, &sigs, (sigset_t *) NULL); + } + + /* Flush all streams. We cannot close them now because the user + might have registered a handler for SIGABRT. */ + if (stage == 1) + { + ++stage; + fflush (NULL); + } - /* It returns, so we are responsible for closing the streams. */ - __close_all_streams (); + /* Send signal which possibly calls a user handler. */ + if (stage == 2) + { + ++stage; + raise (SIGABRT); + } - /* There was a handler installed. Now remove it. */ + /* There was a handler installed. Now remove it. */ + if (stage == 3) + { + ++stage; memset (&act, '\0', sizeof (struct sigaction)); act.sa_handler = SIG_DFL; __sigfillset (&act.sa_mask); act.sa_flags = 0; __sigaction (SIGABRT, &act, NULL); } - else - /* No handler installed so the next `raise' will hopefully - terminate the process. Therefore we must close the streams. */ - __close_all_streams (); + + /* Now close the streams which also flushes the output the user + defined handler might has produced. */ + if (stage == 4) + { + ++stage; + fclose (NULL); + } /* Try again. */ - raise (SIGABRT); + if (stage == 5) + { + ++stage; + raise (SIGABRT); + } - /* If we can't signal ourselves, exit. */ - _exit (127); + /* Now try to abort using the system specific command. */ + if (stage == 6) + { + ++stage; + ABORT_INSTRUCTION; + } + + /* If we can't signal ourselves and the abort instruction failed, exit. */ + if (stage == 7) + { + ++stage; + _exit (127); + } - /* If even this fails make sure we never return. */ + /* If even this fails try to use the provided instruction to crash + or otherwise make sure we never return. */ while (1) - /* For ever and ever. */ - ; + /* Try for ever and ever. */ + ABORT_INSTRUCTION; } diff --git a/sysdeps/i386/abort-instr.h b/sysdeps/i386/abort-instr.h new file mode 100644 index 0000000..810f103 --- /dev/null +++ b/sysdeps/i386/abort-instr.h @@ -0,0 +1,2 @@ +/* An instruction which should crash any program is `hlt'. */ +#define ABORT_INSTRUCTION asm ("hlt") diff --git a/sysdeps/i386/fpu_control.h b/sysdeps/i386/fpu_control.h index 7944b1a..4677f13 100644 --- a/sysdeps/i386/fpu_control.h +++ b/sysdeps/i386/fpu_control.h @@ -1,22 +1,22 @@ /* FPU control word bits. i387 version. -Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Olaf Flebbe. - -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. */ + Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Olaf Flebbe. + + 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 _FPU_CONTROL_H #define _FPU_CONTROL_H 1 diff --git a/sysdeps/unix/common/pause.c b/sysdeps/unix/common/pause.c index a073dd2..1580a0b 100644 --- a/sysdeps/unix/common/pause.c +++ b/sysdeps/unix/common/pause.c @@ -1,20 +1,20 @@ /* Copyright (C) 1991, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + 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 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. + 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., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + 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. */ #include <signal.h> #include <unistd.h> @@ -26,6 +26,6 @@ Cambridge, MA 02139, USA. */ int __libc_pause (void) { - return __sigpause (__sigblock (0)); + return __sigpause (__sigblock (0), 0); } weak_alias (__libc_pause, pause) diff --git a/sysdeps/unix/sysv/linux/alpha/timebits.h b/sysdeps/unix/sysv/linux/alpha/timebits.h index f777dc2..1ad0df8 100644 --- a/sysdeps/unix/sysv/linux/alpha/timebits.h +++ b/sysdeps/unix/sysv/linux/alpha/timebits.h @@ -33,9 +33,18 @@ struct timeval #ifndef _TIMEBITS_H -#define _TIMEBITS_H 1 - -#include <asm/param.h> -#define CLOCKS_PER_SEC HZ /* XXX names not kosher */ +# define _TIMEBITS_H 1 + +/* ISO/IEC 9899:1990 7.12.1: <time.h> + The macro `CLOCKS_PER_SEC' is the number per second of the value + returned by the `clock' function. */ +/* CAE XSH, Issue 4, Version 2: <time.h> + The value of CLOCKS_PER_SEC is required to be 1 million on all + XSI-conformant systems. */ +# define CLOCKS_PER_SEC 1000000 + +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# define CLK_TCK 1024 #endif /* timebits.h */ diff --git a/sysdeps/unix/sysv/linux/fcntlbits.h b/sysdeps/unix/sysv/linux/fcntlbits.h index 9088e6d..43954df 100644 --- a/sysdeps/unix/sysv/linux/fcntlbits.h +++ b/sysdeps/unix/sysv/linux/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for Linux. -Copyright (C) 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1995, 1996 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 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. + 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. */ + 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 _FCNTLBITS_H #define _FCNTLBITS_H 1 diff --git a/sysdeps/unix/sysv/linux/ioctls.h b/sysdeps/unix/sysv/linux/ioctls.h index f7a3467..8b53269 100644 --- a/sysdeps/unix/sysv/linux/ioctls.h +++ b/sysdeps/unix/sysv/linux/ioctls.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + 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 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. + 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. */ + 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 _IOCTLS_H #define _IOCTLS_H 1 diff --git a/sysdeps/unix/sysv/linux/m68k/setjmp.c b/sysdeps/unix/sysv/linux/m68k/setjmp.c new file mode 100644 index 0000000..ef609cc --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/setjmp.c @@ -0,0 +1,83 @@ +/* Copyright (C) 1991, 1992, 1994, 1996 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. */ + +#include <setjmp.h> + +/* Save the current program position in ENV and return 0. */ +int +__sigsetjmp (jmp_buf env, int savemask) +{ + /* Save data registers D1 through D7. */ + asm volatile ("movem%.l %/d1-%/d7, %0" + : : "m" (env[0].__jmpbuf[0].__dregs[0])); + + /* Save return address in place of register A0. */ + env[0].__jmpbuf[0].__aregs[0] = ((void **) &env)[-1]; + + /* Save address registers A1 through A5. */ + asm volatile ("movem%.l %/a1-%/a5, %0" + : : "m" (env[0].__jmpbuf[0].__aregs[1])); + + /* Save caller's FP, not our own. */ + env[0].__jmpbuf[0].__fp = ((void **) &env)[-2]; + + /* Save caller's SP, not our own. */ + env[0].__jmpbuf[0].__sp = (void *) &env; + +#if defined (__HAVE_68881__) || defined (__HAVE_FPU__) + /* Save floating-point (68881) registers FP0 through FP7. */ + asm volatile ("fmovem%.x %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#endif + + /* Save the signal mask if requested. */ + return __sigjmp_save (env, savemask); +} + +/* Binary compatibility entry point. */ +int +__setjmp (jmp_buf env) +{ + /* Save data registers D1 through D7. */ + asm volatile ("movem%.l %/d1-%/d7, %0" + : : "m" (env[0].__jmpbuf[0].__dregs[0])); + + /* Save return address in place of register A0. */ + env[0].__jmpbuf[0].__aregs[0] = ((void **) &env)[-1]; + + /* Save address registers A1 through A5. */ + asm volatile ("movem%.l %/a1-%/a5, %0" + : : "m" (env[0].__jmpbuf[0].__aregs[1])); + + /* Save caller's FP, not our own. */ + env[0].__jmpbuf[0].__fp = ((void **) &env)[-2]; + + /* Save caller's SP, not our own. */ + env[0].__jmpbuf[0].__sp = (void *) &env; + +#if defined (__HAVE_68881__) || defined (__HAVE_FPU__) + /* Save floating-point (68881) registers FP0 through FP7. */ + asm volatile ("fmovem%.x %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#endif + + /* Don't save the signal mask. */ + env[0].__mask_was_saved = 0; + + return 0; +} diff --git a/sysdeps/unix/sysv/linux/sigcontext.h b/sysdeps/unix/sysv/linux/sigcontext.h index 92733ab..71afc76 100644 --- a/sysdeps/unix/sysv/linux/sigcontext.h +++ b/sysdeps/unix/sysv/linux/sigcontext.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 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. */ + 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 _SIGCONTEXT_H #define _SIGCONTEXT_H 1 diff --git a/sysdeps/unix/sysv/linux/sys/acct.h b/sysdeps/unix/sysv/linux/sys/acct.h index da03930..4267ef4 100644 --- a/sysdeps/unix/sysv/linux/sys/acct.h +++ b/sysdeps/unix/sysv/linux/sys/acct.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 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. */ + 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 _SYS_ACCT_H diff --git a/sysdeps/unix/sysv/linux/timebits.h b/sysdeps/unix/sysv/linux/timebits.h index 52f666f..f2f73a4 100644 --- a/sysdeps/unix/sysv/linux/timebits.h +++ b/sysdeps/unix/sysv/linux/timebits.h @@ -43,4 +43,8 @@ struct timeval XSI-conformant systems. */ # define CLOCKS_PER_SEC 1000000 +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# define CLK_TCK 100 + #endif /* timebits.h */ diff --git a/sysdeps/unix/sysv/linux/utsnamelen.h b/sysdeps/unix/sysv/linux/utsnamelen.h index c16c385..64e2ab5 100644 --- a/sysdeps/unix/sysv/linux/utsnamelen.h +++ b/sysdeps/unix/sysv/linux/utsnamelen.h @@ -1,19 +1,20 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 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 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. + 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. */ + 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. */ /* Length of the entries in `struct utsname' is 65. */ #define _UTSNAME_LENGTH 65 |