Mercurial > hg > octave-lojdl > gnulib-hg
annotate doc/alloca.texi @ 14776:a3bd209aea02
test-perror: rewrite to use init script
Make the test simpler, and also check for correct exit status.
* modules/perror-tests (Files): Add init.sh.
* tests/test-perror.sh: Use temporary directory.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Fri, 20 May 2011 08:57:54 -0600 |
parents | 97fc9a21a8fb |
children | 8250f2777afc |
rev | line source |
---|---|
5535
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 @c Documentation of gnulib module 'alloca'. |
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
3 @c Copyright (C) 2004, 2007, 2009-2011 Free Software Foundation, Inc. |
7139
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
4 |
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
5 @c Permission is granted to copy, distribute and/or modify this document |
10762
d67664a4e01c
Change license to GFDLv1.3+.
Simon Josefsson <simon@josefsson.org>
parents:
9550
diff
changeset
|
6 @c under the terms of the GNU Free Documentation License, Version 1.3 or |
7139
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
7 @c any later version published by the Free Software Foundation; with no |
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
8 @c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover |
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
9 @c Texts. A copy of the license is included in the ``GNU Free |
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
10 @c Documentation License'' file as part of this distribution. |
adb21c293305
Add copyright notices to long-enough files that lack them, since
Paul Eggert <eggert@cs.ucla.edu>
parents:
5535
diff
changeset
|
11 |
9550
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
12 The alloca module provides for a function @code{alloca} which allocates |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
13 memory on the stack, where the system allows it. A memory block allocated with |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
14 @code{alloca} exists only until the function that calls @code{alloca} returns |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
15 or exits abruptly. |
5535
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 There are a few systems where this is not possible: HP-UX systems, and some |
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 other platforms when the C++ compiler is used. On these platforms the alloca |
9550
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
19 module provides a @code{malloc} based emulation. This emulation will not free a |
5535
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 memory block immediately when the calling function returns, but rather will |
9550
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
21 wait until the next @code{alloca} call from a function with the same or a |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
22 shorter stack length. Thus, in some cases, a few memory blocks will be kept |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
23 although they are not needed any more. |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
24 |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
25 The user can @code{#include <alloca.h>} and use @code{alloca} on all platforms. |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
26 Note that the @code{#include <alloca.h>} must be the first one after the |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
27 autoconf-generated @file{config.h}, for AIX 3 compatibility. Thanks to IBM for |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
28 this nice restriction! |
5535
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 |
9550
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
30 Note that GCC 3.1 and 3.2 can @emph{inline} functions that call @code{alloca}. |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
31 When this happens, the memory blocks allocated with @code{alloca} will not be |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
32 freed until @emph{the end of the calling function}. If this calling function |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
33 runs a loop calling the function that uses @code{alloca}, the program easily |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
34 gets a stack overflow and crashes. To protect against this compiler behaviour, |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
35 you can mark the function that uses @code{alloca} with the following attribute: |
5535
5a898d7a80a6
Documentation of 'alloca' and 'alloca-opt' modules.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 |
9550
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
37 @smallexample |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
38 #ifdef __GNUC__ |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
39 __attribute__ ((__noinline__)) |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
40 #endif |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
41 @end smallexample |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
42 |
6bc27027a2d6
Avoid using the syntax symbol() in formatted documentation.
Bruno Haible <bruno@clisp.org>
parents:
7139
diff
changeset
|
43 An alternative to this module is the @samp{alloca-opt} module. |