VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/XFree86-4.3/X11/Xalloca.h@ 99743

Last change on this file since 99743 was 69098, checked in by vboxsync, 7 years ago

Clean up XFree86 driver header files.
bugref:3810: X11 Guest Additions maintenance
Over the years we have cleaned up the layout in the tree of the X.Org
header files we use to build drivers. The XFree86 ones were still in their
original, rather sub-optimal layout. This change fixes that.

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/* $Xorg: Xalloca.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ */
2
3/*
4
5Copyright 1995, 1998 The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be
14included in all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
20OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23
24Except as contained in this notice, the name of The Open Group shall
25not be used in advertising or otherwise to promote the sale, use or
26other dealings in this Software without prior written authorization
27from The Open Group.
28
29*/
30/* $XFree86: xc/include/Xalloca.h,v 3.11 2002/12/01 20:08:41 tsi Exp $ */
31
32/*
33 * The purpose of this header is to define the macros ALLOCATE_LOCAL and
34 * DEALLOCATE_LOCAL appropriately for the platform being compiled on.
35 * These macros are used to make fast, function-local memory allocations.
36 * Their characteristics are as follows:
37 *
38 * void *ALLOCATE_LOCAL(int size)
39 * Returns a pointer to size bytes of memory, or NULL if the allocation
40 * failed. The memory must be freed with DEALLOCATE_LOCAL before the
41 * function that made the allocation returns. You should not ask for
42 * large blocks of memory with this function, since on many platforms
43 * the memory comes from the stack, which may have limited size.
44 *
45 * void DEALLOCATE_LOCAL(void *)
46 * Frees the memory allocated by ALLOCATE_LOCAL. Omission of this
47 * step may be harmless on some platforms, but will result in
48 * memory leaks or worse on others.
49 *
50 * Before including this file, you should define two macros,
51 * ALLOCATE_LOCAL_FALLBACK and DEALLOCATE_LOCAL_FALLBACK, that have the
52 * same characteristics as ALLOCATE_LOCAL and DEALLOCATE_LOCAL. The
53 * header uses the fallbacks if it doesn't know a "better" way to define
54 * ALLOCATE_LOCAL and DEALLOCATE_LOCAL. Typical usage would be:
55 *
56 * #define ALLOCATE_LOCAL_FALLBACK(_size) malloc(_size)
57 * #define DEALLOCATE_LOCAL_FALLBACK(_ptr) free(_ptr)
58 * #include "Xalloca.h"
59 */
60
61#ifndef XALLOCA_H
62#define XALLOCA_H 1
63
64#ifdef INCLUDE_ALLOCA_H
65# include <alloca.h>
66#endif
67
68#ifndef NO_ALLOCA
69/*
70 * os-dependent definition of local allocation and deallocation
71 * If you want something other than (DE)ALLOCATE_LOCAL_FALLBACK
72 * for ALLOCATE/DEALLOCATE_LOCAL then you add that in here.
73 */
74# if defined(__HIGHC__)
75# ifndef NCR
76 extern char *alloca();
77# if HCVERSION < 21003
78# define ALLOCATE_LOCAL(size) alloca((int)(size))
79 pragma on(alloca);
80# else /* HCVERSION >= 21003 */
81# define ALLOCATE_LOCAL(size) _Alloca((int)(size))
82# endif /* HCVERSION < 21003 */
83# else /* NCR */
84# define ALLOCATE_LOCAL(size) alloca(size)
85# endif
86# endif /* defined(__HIGHC__) */
87
88
89# ifdef __GNUC__
90# ifndef alloca
91# define alloca __builtin_alloca
92# endif /* !alloca */
93# define ALLOCATE_LOCAL(size) alloca((int)(size))
94# else /* ! __GNUC__ */
95
96/*
97 * warning: old mips alloca (pre 2.10) is unusable, new one is built in
98 * Test is easy, the new one is named __builtin_alloca and comes
99 * from alloca.h which #defines alloca.
100 */
101# ifndef NCR
102# if defined(vax) || defined(sun) || defined(apollo) || defined(stellar) || defined(alloca)
103/*
104 * Some System V boxes extract alloca.o from /lib/libPW.a; if you
105 * decide that you don't want to use alloca, you might want to fix it here.
106 */
107/* alloca might be a macro taking one arg (hi, Sun!), so give it one. */
108# ifndef __sgi /* IRIX 5/6 has definition */
109# ifndef __QNX__
110# define __Xnullarg /* as nothing */
111# ifndef X_NOT_STDC_ENV
112 extern void *alloca(__Xnullarg);
113# else
114 extern char *alloca(__Xnullarg);
115# endif
116# endif /* __QNX__ */
117# endif /* __sgi */
118# define ALLOCATE_LOCAL(size) alloca((int)(size))
119# endif /* who does alloca */
120# endif /* NCR */
121# endif /* __GNUC__ */
122
123#endif /* NO_ALLOCA */
124
125#if !defined(ALLOCATE_LOCAL)
126# if defined(ALLOCATE_LOCAL_FALLBACK) && defined(DEALLOCATE_LOCAL_FALLBACK)
127# define ALLOCATE_LOCAL(_size) ALLOCATE_LOCAL_FALLBACK(_size)
128# define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK(_ptr)
129# else /* no fallbacks supplied; error */
130# define ALLOCATE_LOCAL(_size) ALLOCATE_LOCAL_FALLBACK undefined!
131# define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK undefined!
132# endif /* defined(ALLOCATE_LOCAL_FALLBACK && DEALLOCATE_LOCAL_FALLBACK) */
133#else
134# if !defined(DEALLOCATE_LOCAL)
135# define DEALLOCATE_LOCAL(_ptr) do {} while(0)
136# endif
137#endif /* defined(ALLOCATE_LOCAL) */
138
139#endif /* XALLOCA_H */
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