annotate lib/c-stack.h @ 40203:30d91797009f

autoupdate
author Karl Berry <karl@freefriends.org>
date Fri, 01 Mar 2019 08:42:42 -0800
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3902
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
1 /* Stack overflow handling.
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
2
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
3 Copyright (C) 2002, 2004, 2008-2019 Free Software Foundation, Inc.
3902
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
5 This program is free software: you can redistribute it and/or modify
3902
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
8 (at your option) any later version.
3902
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
9
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13 GNU General Public License for more details.
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
3902
f26afed46772 New file, from diffutils-2.8.2.
Jim Meyering <jim@meyering.net>
parents:
diff changeset
17
10279
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
18
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
19 /* Set up ACTION so that it is invoked on C stack overflow and on other,
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
20 stack-unrelated, segmentation violation.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
21 Return -1 (setting errno) if this cannot be done.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
22
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
23 When a stack overflow or segmentation violation occurs:
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
24 1) ACTION is called. It is passed an argument equal to
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
25 - 0, for a stack overflow,
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
26 - SIGSEGV, for a segmentation violation that does not appear related
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
27 to stack overflow.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
28 On many platforms the two cases are hard to distinguish; when in doubt,
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
29 zero is passed.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
30 2) If ACTION returns, a message is written to standard error, and the
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
31 program is terminated: in the case of stack overflow, with exit code
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
32 exit_failure (see "exitfail.h"), otherwise through a signal SIGSEGV.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
33
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
34 A null ACTION acts like an action that does nothing.
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
35
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
36 ACTION must be async-signal-safe. ACTION together with its callees
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
37 must not require more than SIGSTKSZ bytes of stack space. Also,
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
38 ACTION should not call longjmp, because this implementation does
10852
024e032be5f2 Add comments.
Bruno Haible <bruno@clisp.org>
parents: 10279
diff changeset
39 not guarantee that it is safe to return to the original stack.
024e032be5f2 Add comments.
Bruno Haible <bruno@clisp.org>
parents: 10279
diff changeset
40
024e032be5f2 Add comments.
Bruno Haible <bruno@clisp.org>
parents: 10279
diff changeset
41 This function may install a handler for the SIGSEGV signal or for the SIGBUS
024e032be5f2 Add comments.
Bruno Haible <bruno@clisp.org>
parents: 10279
diff changeset
42 signal or exercise other system dependent exception handling APIs. */
10279
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
43
9c24129c10e2 Improve documentation.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
44 extern int c_stack_action (void (* /*action*/) (int));