VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xproto-7.0.15/X11/Xalloca.h@ 24873

Last change on this file since 24873 was 22662, checked in by vboxsync, 15 years ago

export more X11 stuff to OSE

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