From c69d60fbe458bec800583bc57d5b3bad61fa72e4 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 8 Dec 2004 14:26:48 +0000 Subject: [PATCH] Use union type to avoid strict aliasing problems. --- src/mesa/drivers/dri/common/dri_util.c | 54 +++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index a9faaa2..88caa34 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -232,23 +232,33 @@ static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw) static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw) { int retcode; - __DRIdrawable *pdraw; + union + { + __DRIdrawable *pdraw; + void *ptr; + } p; - retcode = drmHashLookup(drawHash, draw, (void **)&pdraw); + retcode = drmHashLookup(drawHash, draw, &p.ptr); if (retcode) return NULL; - return pdraw; + return p.pdraw; } static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw) { int retcode; - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; + union + { + __DRIdrawablePrivate *pdp; + void *ptr; + } p; - retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw); + p.pdp = (__DRIdrawablePrivate *)pdraw->private; + + retcode = drmHashLookup(drawHash, p.pdp->draw, &p.ptr); if (!retcode) { /* Found */ - drmHashDelete(drawHash, pdp->draw); + drmHashDelete(drawHash, p.pdp->draw); } } @@ -306,21 +316,25 @@ static GLboolean __driWindowExists(Display *dpy, GLXDrawable draw) static void __driGarbageCollectDrawables(void *drawHash) { __DRIid draw; - __DRIdrawable *pdraw; __DRInativeDisplay *dpy; + union + { + __DRIdrawable *pdraw; + void *ptr; + } p; - if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) { + if (drmHashFirst(drawHash, &draw, &p.ptr)) { do { - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; + __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)p.pdraw->private; dpy = pdp->driScreenPriv->display; if (! (*window_exists)(dpy, draw)) { /* Destroy the local drawable data in the hash table, if the drawable no longer exists in the Xserver */ - __driRemoveDrawable(drawHash, pdraw); - (*pdraw->destroyDrawable)(dpy, pdraw->private); - _mesa_free(pdraw); + __driRemoveDrawable(drawHash, p.pdraw); + (*p.pdraw->destroyDrawable)(dpy, p.pdraw->private); + _mesa_free(p.pdraw); } - } while (drmHashNext(drawHash, &draw, (void **)&pdraw)); + } while (drmHashNext(drawHash, &draw, &p.ptr)); } } @@ -868,7 +882,7 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, _mesa_free(pdp); return NULL; #else - pdp->getInfo = XF86DRIGetDrawableInfo; + pdp->getInfo = (PFNGLXGETDRAWABLEINFOPROC) XF86DRIGetDrawableInfo; #endif /* DRI_NEW_INTERFACE_ONLY */ } @@ -1053,16 +1067,16 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, pctx->bindContext3 = driBindContext3; pctx->unbindContext3 = driUnbindContext3; #else - pctx->bindContext = driBindContext; - pctx->unbindContext = driUnbindContext; + pctx->bindContext = (void *)driBindContext; + pctx->unbindContext = (void *)driUnbindContext; if ( driCompareGLXAPIVersion( 20030606 ) >= 0 ) { - pctx->bindContext2 = driBindContext2; - pctx->unbindContext2 = driUnbindContext2; + pctx->bindContext2 = (void *)driBindContext2; + pctx->unbindContext2 = (void *)driUnbindContext2; } if ( driCompareGLXAPIVersion( 20040415 ) >= 0 ) { - pctx->bindContext3 = driBindContext3; - pctx->unbindContext3 = driUnbindContext3; + pctx->bindContext3 = (void *)driBindContext3; + pctx->unbindContext3 = (void *)driUnbindContext3; } #endif -- 2.7.4