summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_alloca.h
blob: db6a3945a695fdc715153920a90308bd503ac938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* EINA - EFL data type library
 * Copyright (C) 2013 Gustavo Sverzut Barbieri
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library;
 * if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef EINA_ALLOCA_H
# define EINA_ALLOCA_H

# include <stdlib.h>
# include <stddef.h>

/**
 * @file eina_alloca.h
 * Check if GCC's alloca() is available.  If it is available via a different spelling,
 * define alloca to that spelling.
 */

# ifdef EINA_HAVE_ALLOCA_H
#  include <alloca.h>
# elif !defined alloca
#  ifdef __GNUC__
#   define alloca __builtin_alloca
#  elif defined _AIX
#   define alloca __alloca
#  elif defined _MSC_VER
#   include <malloc.h>
#   define alloca _alloca
#  elif !defined EINA_HAVE_ALLOCA
#   ifdef  __cplusplus
extern "C"
#   endif
/**
 * @brief Allocates memory in the stack frame of the caller, so that it
 * is automatically freed when the caller returns.
 *
 * @param size Number of bytes of space to allocate.
 * @return Pointer to beginning of the allocated space.
 *
 * @see alloca(3) for more details.
 */
void *alloca(size_t size);
#  endif
# endif

#endif /* EINA_HAVE_ALLOCA_H */