aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-05-30 16:36:08 +0100
committerJosé Fonseca <[email protected]>2010-05-30 16:36:08 +0100
commit6f67a71aada11a097c7c11db8f11cd56557354ab (patch)
tree25e5bc067e508b99a359e0527e0870e747a70c5c
parent18fb9ff6d8f58a08e559070cf29f26ed0caa567f (diff)
util: Generic pointer to func conversion helper.
That observes strict-aliasing rules.
-rw-r--r--src/gallium/auxiliary/util/u_pointer.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_pointer.h b/src/gallium/auxiliary/util/u_pointer.h
index e1af9f11cb9..ae6f43bff87 100644
--- a/src/gallium/auxiliary/util/u_pointer.h
+++ b/src/gallium/auxiliary/util/u_pointer.h
@@ -98,6 +98,18 @@ align16( void *unaligned )
return align_pointer( unaligned, 16 );
}
+typedef void (*func_pointer)(void);
+
+static INLINE func_pointer
+pointer_to_func( void *p )
+{
+ union {
+ void *p;
+ func_pointer f;
+ } pf;
+ pf.p = p;
+ return pf.f;
+}
#ifdef __cplusplus