[1] | 1 | /** @file
|
---|
[8245] | 2 | * IPRT - alloca().
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[98103] | 6 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[1] | 7 | *
|
---|
[96407] | 8 | * This file is part of VirtualBox base platform packages, as
|
---|
| 9 | * available from https://www.virtualbox.org.
|
---|
[5999] | 10 | *
|
---|
[96407] | 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 | *
|
---|
[5999] | 24 | * The contents of this file may alternatively be used under the terms
|
---|
| 25 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 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
|
---|
[5999] | 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.
|
---|
[96407] | 32 | *
|
---|
| 33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[1] | 34 | */
|
---|
| 35 |
|
---|
[76557] | 36 | #ifndef IPRT_INCLUDED_alloca_h
|
---|
| 37 | #define IPRT_INCLUDED_alloca_h
|
---|
[76507] | 38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 39 | # pragma once
|
---|
| 40 | #endif
|
---|
[1] | 41 |
|
---|
[31847] | 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 |
|
---|
[1] | 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.
|
---|
[3092] | 50 | * When we're in kernel territory it starts getting a bit more
|
---|
| 51 | * interesting of course...
|
---|
[1] | 52 | */
|
---|
[10083] | 53 | #if defined(IN_RING0) \
|
---|
[62941] | 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))
|
---|
[3092] | 59 | /* ASSUMES GNU C */
|
---|
| 60 | # define alloca(cb) __builtin_alloca(cb)
|
---|
[31847] | 61 |
|
---|
[95768] | 62 | #elif defined(IPRT_NO_CRT) && defined(RT_OS_WINDOWS)
|
---|
| 63 | # include <iprt/types.h>
|
---|
[95769] | 64 |
|
---|
| 65 | RT_C_DECLS_BEGIN
|
---|
| 66 | # ifdef RT_ARCH_X86
|
---|
| 67 | void * __cdecl _alloca(size_t);
|
---|
| 68 | # else
|
---|
| 69 | void *_alloca(size_t);
|
---|
| 70 | # endif
|
---|
[95768] | 71 | # define alloca _alloca
|
---|
[95769] | 72 | RT_C_DECLS_END
|
---|
[95768] | 73 |
|
---|
[3092] | 74 | #else
|
---|
| 75 | # include <stdlib.h>
|
---|
[62942] | 76 | # if !defined(RT_OS_DARWIN) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_NETBSD)
|
---|
[3092] | 77 | # include <malloc.h>
|
---|
| 78 | # endif
|
---|
[53997] | 79 | # if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX)
|
---|
[3092] | 80 | # include <alloca.h>
|
---|
| 81 | # endif
|
---|
[94281] | 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
|
---|
[1] | 107 | #endif
|
---|
| 108 |
|
---|
[76585] | 109 | #endif /* !IPRT_INCLUDED_alloca_h */
|
---|
[1] | 110 |
|
---|