VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.4.2/unpack.h@ 81043

Last change on this file since 81043 was 43272, checked in by vboxsync, 12 years ago

Additions/x11: more original X server headers.

  • Property svn:eol-style set to native
File size: 7.6 KB
Line 
1#ifndef __GLX_unpack_h__
2#define __GLX_unpack_h__
3
4/*
5** License Applicability. Except to the extent portions of this file are
6** made subject to an alternative license as permitted in the SGI Free
7** Software License B, Version 1.1 (the "License"), the contents of this
8** file are subject only to the provisions of the License. You may not use
9** this file except in compliance with the License. You may obtain a copy
10** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
11** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
12**
13** http://oss.sgi.com/projects/FreeB
14**
15** Note that, as provided in the License, the Software is distributed on an
16** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
17** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
18** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
19** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
20**
21** Original Code. The Original Code is: OpenGL Sample Implementation,
22** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
23** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
24** Copyright in any portions created by third parties is as indicated
25** elsewhere herein. All Rights Reserved.
26**
27** Additional Notice Provisions: The application programming interfaces
28** established by SGI in conjunction with the Original Code are The
29** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
30** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
31** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
32** Window System(R) (Version 1.3), released October 19, 1998. This software
33** was created using the OpenGL(R) version 1.2.1 Sample Implementation
34** published by SGI, but has not been independently verified as being
35** compliant with the OpenGL(R) version 1.2.1 Specification.
36**
37*/
38
39#define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
40
41/*
42** Fetch the context-id out of a SingleReq request pointed to by pc.
43*/
44#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
45#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
46
47/*
48** Fetch a double from potentially unaligned memory.
49*/
50#ifdef __GLX_ALIGN64
51#define __GLX_MEM_COPY(dst,src,n) memcpy(dst,src,n)
52#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
53#else
54#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
55#endif
56
57extern void __glXMemInit(void);
58
59extern xGLXSingleReply __glXReply;
60
61#define __GLX_BEGIN_REPLY(size) \
62 __glXReply.length = __GLX_PAD(size) >> 2; \
63 __glXReply.type = X_Reply; \
64 __glXReply.sequenceNumber = client->sequence;
65
66#define __GLX_SEND_HEADER() \
67 WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
68
69#define __GLX_PUT_RETVAL(a) \
70 __glXReply.retval = (a);
71
72#define __GLX_PUT_SIZE(a) \
73 __glXReply.size = (a);
74
75#define __GLX_PUT_RENDERMODE(m) \
76 __glXReply.pad3 = (m)
77
78/*
79** Get a buffer to hold returned data, with the given alignment. If we have
80** to realloc, allocate size+align, in case the pointer has to be bumped for
81** alignment. The answerBuffer should already be aligned.
82**
83** NOTE: the cast (long)res below assumes a long is large enough to hold a
84** pointer.
85*/
86#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
87 if ((size) > sizeof(answerBuffer)) { \
88 int bump; \
89 if ((cl)->returnBufSize < (size)+(align)) { \
90 (cl)->returnBuf = (GLbyte*)Xrealloc((cl)->returnBuf, \
91 (size)+(align)); \
92 if (!(cl)->returnBuf) { \
93 return BadAlloc; \
94 } \
95 (cl)->returnBufSize = (size)+(align); \
96 } \
97 res = (char*)cl->returnBuf; \
98 bump = (long)(res) % (align); \
99 if (bump) res += (align) - (bump); \
100 } else { \
101 res = (char *)answerBuffer; \
102 }
103
104#define __GLX_PUT_BYTE() \
105 *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
106
107#define __GLX_PUT_SHORT() \
108 *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
109
110#define __GLX_PUT_INT() \
111 *(GLint *)&__glXReply.pad3 = *(GLint *)answer
112
113#define __GLX_PUT_FLOAT() \
114 *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
115
116#define __GLX_PUT_DOUBLE() \
117 *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
118
119#define __GLX_SEND_BYTE_ARRAY(len) \
120 WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
121
122#define __GLX_SEND_SHORT_ARRAY(len) \
123 WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
124
125#define __GLX_SEND_INT_ARRAY(len) \
126 WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
127
128#define __GLX_SEND_FLOAT_ARRAY(len) \
129 WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
130
131#define __GLX_SEND_DOUBLE_ARRAY(len) \
132 WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
133
134
135#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
136#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
137#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
138#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
139
140/*
141** PERFORMANCE NOTE:
142** Machine dependent optimizations abound here; these swapping macros can
143** conceivably be replaced with routines that do the job faster.
144*/
145#define __GLX_DECLARE_SWAP_VARIABLES \
146 GLbyte sw; \
147 GLbyte *swapPC; \
148 GLbyte *swapEnd
149
150
151#define __GLX_SWAP_INT(pc) \
152 sw = ((GLbyte *)(pc))[0]; \
153 ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
154 ((GLbyte *)(pc))[3] = sw; \
155 sw = ((GLbyte *)(pc))[1]; \
156 ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
157 ((GLbyte *)(pc))[2] = sw;
158
159#define __GLX_SWAP_SHORT(pc) \
160 sw = ((GLbyte *)(pc))[0]; \
161 ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
162 ((GLbyte *)(pc))[1] = sw;
163
164#define __GLX_SWAP_DOUBLE(pc) \
165 sw = ((GLbyte *)(pc))[0]; \
166 ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
167 ((GLbyte *)(pc))[7] = sw; \
168 sw = ((GLbyte *)(pc))[1]; \
169 ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
170 ((GLbyte *)(pc))[6] = sw; \
171 sw = ((GLbyte *)(pc))[2]; \
172 ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
173 ((GLbyte *)(pc))[5] = sw; \
174 sw = ((GLbyte *)(pc))[3]; \
175 ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
176 ((GLbyte *)(pc))[4] = sw;
177
178#define __GLX_SWAP_FLOAT(pc) \
179 sw = ((GLbyte *)(pc))[0]; \
180 ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
181 ((GLbyte *)(pc))[3] = sw; \
182 sw = ((GLbyte *)(pc))[1]; \
183 ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
184 ((GLbyte *)(pc))[2] = sw;
185
186#define __GLX_SWAP_INT_ARRAY(pc, count) \
187 swapPC = ((GLbyte *)(pc)); \
188 swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
189 while (swapPC < swapEnd) { \
190 __GLX_SWAP_INT(swapPC); \
191 swapPC += __GLX_SIZE_INT32; \
192 }
193
194#define __GLX_SWAP_SHORT_ARRAY(pc, count) \
195 swapPC = ((GLbyte *)(pc)); \
196 swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
197 while (swapPC < swapEnd) { \
198 __GLX_SWAP_SHORT(swapPC); \
199 swapPC += __GLX_SIZE_INT16; \
200 }
201
202#define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
203 swapPC = ((GLbyte *)(pc)); \
204 swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
205 while (swapPC < swapEnd) { \
206 __GLX_SWAP_DOUBLE(swapPC); \
207 swapPC += __GLX_SIZE_FLOAT64; \
208 }
209
210#define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
211 swapPC = ((GLbyte *)(pc)); \
212 swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
213 while (swapPC < swapEnd) { \
214 __GLX_SWAP_FLOAT(swapPC); \
215 swapPC += __GLX_SIZE_FLOAT32; \
216 }
217
218#define __GLX_SWAP_REPLY_HEADER() \
219 __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
220 __GLX_SWAP_INT(&__glXReply.length);
221
222#define __GLX_SWAP_REPLY_RETVAL() \
223 __GLX_SWAP_INT(&__glXReply.retval)
224
225#define __GLX_SWAP_REPLY_SIZE() \
226 __GLX_SWAP_INT(&__glXReply.size)
227
228#endif /* !__GLX_unpack_h__ */
229
230
231
232
233
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