Mercurial > gnulib
annotate lib/alloca.in.h @ 40229:6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Reported by Eli Zaretskii <eliz@gnu.org>.
* lib/alloca.in.h: On mingw systems that have <alloca.h>, include that.
* m4/alloca.m4 (gl_FUNC_ALLOCA): Set HAVE_ALLOCA_H.
* modules/alloca-opt (Makefile.am): Substitute HAVE_ALLOCA_H.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 10 Mar 2019 20:39:34 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
9243
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Memory allocation on the stack. |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2019 Free Software Foundation, |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
9754
diff
changeset
|
4 Inc. |
9243
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify it |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 under the terms of the GNU General Public License as published |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 by the Free Software Foundation; either version 2, or (at your option) |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 any later version. |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 General Public License for more details. |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
17 License along with this program; if not, see |
19190 | 18 <https://www.gnu.org/licenses/>. |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
19 */ |
9243
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 means there is a real alloca function. */ |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #ifndef _GL_ALLOCA_H |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #define _GL_ALLOCA_H |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 /* alloca (N) returns a pointer to N bytes of memory |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 allocated on the stack, which will last until the function returns. |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 Use of alloca should be avoided: |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 - inside arguments of function calls - undefined behaviour, |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 - in inline functions - the allocation may actually last until the |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 calling function returns, |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 - for huge N (say, N >= 65536) - you never know how large (or small) |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 the stack is, and when the stack cannot fulfill the memory allocation |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 request, the program just crashes. |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 */ |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 #ifndef alloca |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 # ifdef __GNUC__ |
40229
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
39 /* Some version of mingw have an <alloca.h> that causes trouble when |
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
40 included after 'alloca' gets defined as a macro. As a workaround, include |
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
41 this <alloca.h> first and define 'alloca' as a macro afterwards. */ |
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
42 # if (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@ |
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
43 # include_next <alloca.h> |
6abc91ece034
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
44 # endif |
9243
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 # define alloca __builtin_alloca |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 # elif defined _AIX |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 # define alloca __alloca |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 # elif defined _MSC_VER |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 # include <malloc.h> |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 # define alloca _alloca |
9754 | 51 # elif defined __DECC && defined __VMS |
52 # define alloca __ALLOCA | |
16962
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
53 # elif defined __TANDEM && defined _TNS_E_TARGET |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
54 # ifdef __cplusplus |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
55 extern "C" |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
56 # endif |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
57 void *_alloca (unsigned short); |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
58 # pragma intrinsic (_alloca) |
5cf5743467da
alloca: add support for HP NonStop TNS/E native
Paul Eggert <eggert@cs.ucla.edu>
parents:
16366
diff
changeset
|
59 # define alloca _alloca |
18372
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
60 # elif defined __MVS__ |
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
61 # include <stdlib.h> |
9243
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 # else |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 # include <stddef.h> |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 # ifdef __cplusplus |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 extern "C" |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 # endif |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 void *alloca (size_t); |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 # endif |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 #endif |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 |
a7e785cafb33
Rename alloca_.h to alloca.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 #endif /* _GL_ALLOCA_H */ |