diff options
author | Chia-Wu <olvaffe@gmail.com> | 2009-07-31 07:28:56 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2009-07-31 07:30:13 -0600 |
commit | dc516d6e2afe7f157dbe5aad1288e5624b27e093 (patch) | |
tree | bea322f3bd3eb06b866510cbe7441055e10ba157 /src/egl | |
parent | 826f1f9c6fd976ff36594e272c0a391187ca0bd8 (diff) |
egl: Silence warnings on x86-64.
Casting an unsigned int to or from a pointer directly gives warnings on
x86-64. Add wrappers to silence the warnings.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/main/eglcompiler.h | 33 | ||||
-rw-r--r-- | src/egl/main/eglconfig.c | 2 | ||||
-rw-r--r-- | src/egl/main/egldisplay.c | 19 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 21 |
4 files changed, 65 insertions, 10 deletions
diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index 0b19afedfd..6b639b75c6 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -3,6 +3,39 @@ /** + * Get standard integer types + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) +# include <stdint.h> +#elif defined(_MSC_VER) + typedef __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef __int16 int16_t; + typedef unsigned __int16 uint16_t; +# ifndef __eglplatform_h_ + typedef __int32 int32_t; +# endif + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; + +# if defined(_WIN64) + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +# else + typedef __int32 intptr_t; + typedef unsigned __int32 uintptr_t; +# endif + +# define INT64_C(__val) __val##i64 +# define UINT64_C(__val) __val##ui64 +#else +/* hope the best instead of adding a bunch of ifdef's */ +# include <stdint.h> +#endif + + +/** * Function inlining */ #if defined(__GNUC__) diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index f2f32585c7..bbc585b55e 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -34,7 +34,7 @@ void _eglInitConfig(_EGLConfig *config, EGLint id) { memset(config, 0, sizeof(*config)); - config->Handle = (EGLConfig) id; + config->Handle = (EGLConfig) _eglUIntToPointer((unsigned int) id); _eglSetConfigAttrib(config, EGL_CONFIG_ID, id); _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGB, EGL_DONT_CARE); _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_DONT_CARE); diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 89de609d0b..5304b84a26 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -53,7 +53,7 @@ _eglLinkDisplay(_EGLDisplay *dpy) assert(key); /* "link" the display to the hash table */ _eglHashInsert(_eglGlobal.Displays, key, dpy); - dpy->Handle = (EGLDisplay) key; + dpy->Handle = (EGLDisplay) _eglUIntToPointer(key); return dpy->Handle; } @@ -66,7 +66,8 @@ _eglLinkDisplay(_EGLDisplay *dpy) void _eglUnlinkDisplay(_EGLDisplay *dpy) { - _eglHashRemove(_eglGlobal.Displays, (EGLuint) dpy->Handle); + EGLuint key = _eglPointerToUInt((void *) dpy->Handle); + _eglHashRemove(_eglGlobal.Displays, key); dpy->Handle = EGL_NO_DISPLAY; } @@ -91,7 +92,7 @@ _eglGetDisplayHandle(_EGLDisplay *display) _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy) { - EGLuint key = (EGLuint) dpy; + EGLuint key = _eglPointerToUInt((void *) dpy); return (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key); } @@ -224,7 +225,7 @@ _eglUnlinkContext(_EGLContext *ctx) EGLContext _eglGetContextHandle(_EGLContext *ctx) { - return (EGLContext) (ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT; + return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); } @@ -257,7 +258,7 @@ _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy) assert(key); _eglHashInsert(_eglGlobal.Surfaces, key, surf); - surf->Handle = (EGLSurface) key; + surf->Handle = (EGLSurface) _eglUIntToPointer(key); return surf->Handle; } @@ -270,8 +271,9 @@ void _eglUnlinkSurface(_EGLSurface *surf) { _EGLSurface *prev; + EGLuint key = _eglPointerToUInt((void *) surf->Handle); - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle); + _eglHashRemove(_eglGlobal.Surfaces, key); surf->Handle = EGL_NO_SURFACE; prev = surf->Display->SurfaceList; @@ -314,7 +316,6 @@ _eglGetSurfaceHandle(_EGLSurface *surface) _EGLSurface * _eglLookupSurface(EGLSurface surf) { - _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, - (EGLuint) surf); - return c; + EGLuint key = _eglPointerToUInt((void *) surf); + return (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, key); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 372ed3cd79..2ef5db8a18 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -125,4 +125,25 @@ _eglIsSurfaceLinked(_EGLSurface *surf) } +/** + * Cast an unsigned int to a pointer. + */ +static INLINE void * +_eglUIntToPointer(unsigned int v) +{ + return (void *) ((uintptr_t) v); +} + + +/** + * Cast a pointer to an unsigned int. The pointer must be one that is + * returned by _eglUIntToPointer. + */ +static INLINE unsigned int +_eglPointerToUInt(const void *p) +{ + return (unsigned int) ((uintptr_t) p); +} + + #endif /* EGLDISPLAY_INCLUDED */ |