unpack.h revision a5e7ae69e440f6816420fc99599f044e79e716b6
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Permission is hereby granted, free of charge, to any person obtaining a
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * copy of this software and associated documentation files (the "Software"),
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * to deal in the Software without restriction, including without limitation
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * and/or sell copies of the Software, and to permit persons to whom the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Software is furnished to do so, subject to the following conditions:
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * The above copyright notice including the dates of first publication and
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * either this permission notice or a reference to
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * shall be included in all copies or substantial portions of the Software.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Except as contained in this notice, the name of Silicon Graphics, Inc.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * shall not be used in advertising or otherwise to promote the sale, use or
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * other dealings in this Software without prior written authorization from
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Silicon Graphics, Inc.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** Fetch the context-id out of a SingleReq request pointed to by pc.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** Fetch a double from potentially unaligned memory.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_MEM_COPY(dst,src,n) memmove(dst,src,n)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern void __glXMemInit(void);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient (client, sz_xGLXSingleReply, &__glXReply);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** Get a buffer to hold returned data, with the given alignment. If we have
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** to realloc, allocate size+align, in case the pointer has to be bumped for
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** alignment. The answerBuffer should already be aligned.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** NOTE: the cast (long)res below assumes a long is large enough to hold a
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync (cl)->returnBuf = (GLbyte*)realloc((cl)->returnBuf, \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), answer)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), answer)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient(client, (len)*__GLX_SIZE_INT32, answer)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, answer)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, answer)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** PERFORMANCE NOTE:
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** Machine dependent optimizations abound here; these swapping macros can
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync** conceivably be replaced with routines that do the job faster.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif /* !__GLX_unpack_h__ */