VirtualBox

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

Last change on this file since 78293 was 51223, checked in by vboxsync, 11 years ago

Additions/x11/x11include: added header files for X.Org Server 1.0 and 1.1.

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