VirtualBox

source: vbox/trunk/include/iprt/alloca.h

Last change on this file was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/** @file
2 * IPRT - alloca().
3 */
4
5/*
6 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_alloca_h
37#define IPRT_INCLUDED_alloca_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#if defined(IN_RC) || defined(IN_RING0_AGNOSTIC)
43# error "No alloca() in raw-mode and agnostic ring-0 context as it may have external dependencies like libgcc."
44#endif
45
46/*
47 * If there are more difficult platforms out there, we'll do OS
48 * specific #ifdefs. But for now we'll just include the headers
49 * which normally contains the alloca() prototype.
50 * When we're in kernel territory it starts getting a bit more
51 * interesting of course...
52 */
53#if defined(IN_RING0) \
54 && ( defined(RT_OS_DARWIN) \
55 || defined(RT_OS_FREEBSD) \
56 || defined(RT_OS_LINUX) \
57 || defined(RT_OS_NETBSD) \
58 || defined(RT_OS_SOLARIS))
59/* ASSUMES GNU C */
60# define alloca(cb) __builtin_alloca(cb)
61
62#elif defined(IPRT_NO_CRT) && defined(RT_OS_WINDOWS)
63# include <iprt/types.h>
64
65RT_C_DECLS_BEGIN
66# ifdef RT_ARCH_X86
67void * __cdecl _alloca(size_t);
68# else
69void *_alloca(size_t);
70# endif
71# define alloca _alloca
72RT_C_DECLS_END
73
74#else
75# include <stdlib.h>
76# if !defined(RT_OS_DARWIN) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_NETBSD)
77# include <malloc.h>
78# endif
79# if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX)
80# include <alloca.h>
81# endif
82
83# if defined(RT_OS_SOLARIS) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) \
84 && defined(_SYS_REGSET_H) && !defined(IPRT_NO_SOLARIS_UCONTEXT_CLEANUPS)
85/* Solaris' sys/regset.h pollutes the namespace with register constants that
86 frequently conflicts with structure members and variable/parameter names. */
87# undef CS
88# undef DS
89# undef EAX
90# undef EBP
91# undef EBX
92# undef ECX
93# undef EDI
94# undef EDX
95# undef EFL
96# undef EIP
97# undef ERR
98# undef ES
99# undef ESI
100# undef ESP
101# undef FS
102# undef GS
103# undef SS
104# undef TRAPNO
105# undef UESP
106# endif
107#endif
108
109#endif /* !IPRT_INCLUDED_alloca_h */
110
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette