VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/7.0/X11/Xalloca.h@ 18709

Last change on this file since 18709 was 17236, checked in by vboxsync, 16 years ago

Additions/x11/x11include: blast! Reverted r43555 and r43556

  • Property svn:eol-style set to native
File size: 5.3 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.10 2001/12/14 19:53:25 dawes 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#ifndef INCLUDE_ALLOCA_H
65# if defined(__SUNPRO_C) /* Need to add more here to match Imake *.cf's */
66# define INCLUDE_ALLOCA_H
67# endif
68#endif
69
70#ifdef INCLUDE_ALLOCA_H
71# include <alloca.h>
72#endif
73
74#ifndef NO_ALLOCA
75/*
76 * os-dependent definition of local allocation and deallocation
77 * If you want something other than (DE)ALLOCATE_LOCAL_FALLBACK
78 * for ALLOCATE/DEALLOCATE_LOCAL then you add that in here.
79 */
80# if defined(__HIGHC__)
81# ifndef NCR
82 extern char *alloca();
83# if HCVERSION < 21003
84# define ALLOCATE_LOCAL(size) alloca((int)(size))
85 pragma on(alloca);
86# else /* HCVERSION >= 21003 */
87# define ALLOCATE_LOCAL(size) _Alloca((int)(size))
88# endif /* HCVERSION < 21003 */
89# else /* NCR */
90# define ALLOCATE_LOCAL(size) alloca(size)
91# endif
92# endif /* defined(__HIGHC__) */
93
94
95# ifdef __GNUC__
96# ifndef alloca
97# define alloca __builtin_alloca
98# endif /* !alloca */
99# define ALLOCATE_LOCAL(size) alloca((int)(size))
100# else /* ! __GNUC__ */
101
102/*
103 * warning: old mips alloca (pre 2.10) is unusable, new one is built in
104 * Test is easy, the new one is named __builtin_alloca and comes
105 * from alloca.h which #defines alloca.
106 */
107# ifndef NCR
108# if defined(vax) || defined(sun) || defined(apollo) || defined(stellar) || defined(alloca)
109/*
110 * Some System V boxes extract alloca.o from /lib/libPW.a; if you
111 * decide that you don't want to use alloca, you might want to fix it here.
112 */
113/* alloca might be a macro taking one arg (hi, Sun!), so give it one. */
114# ifndef __sgi /* IRIX 5/6 has definition */
115# ifndef __QNX__
116# define __Xnullarg /* as nothing */
117# ifndef X_NOT_STDC_ENV
118 extern void *alloca(__Xnullarg);
119# else
120 extern char *alloca(__Xnullarg);
121# endif
122# endif /* __QNX__ */
123# endif /* __sgi */
124# define ALLOCATE_LOCAL(size) alloca((int)(size))
125# endif /* who does alloca */
126# endif /* NCR */
127# endif /* __GNUC__ */
128
129#endif /* NO_ALLOCA */
130
131#if !defined(ALLOCATE_LOCAL)
132# if defined(ALLOCATE_LOCAL_FALLBACK) && defined(DEALLOCATE_LOCAL_FALLBACK)
133# define ALLOCATE_LOCAL(_size) ALLOCATE_LOCAL_FALLBACK(_size)
134# define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK(_ptr)
135# else /* no fallbacks supplied; error */
136# define ALLOCATE_LOCAL(_size) ALLOCATE_LOCAL_FALLBACK undefined!
137# define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK undefined!
138# endif /* defined(ALLOCATE_LOCAL_FALLBACK && DEALLOCATE_LOCAL_FALLBACK) */
139#else
140# if !defined(DEALLOCATE_LOCAL)
141# define DEALLOCATE_LOCAL(_ptr) do {} while(0)
142# endif
143#endif /* defined(ALLOCATE_LOCAL) */
144
145#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