[Pixman] [RFC] Adding PIXMAN_CUSTOM_TLS and PIXMAN_UNGET_THREAD_LOCAL preprocessor defines

Sebastian Bauer mail at sebastianbauer.info
Tue Jul 17 22:33:05 PDT 2012


Dear Pixman-devs,

as written earlier, I working on a pixman port as a real AmigaOS shared 
library. As real pixman requires some static writable data and on 
AmigaOS TLS is not supported natively, the access to the pixman fast 
cache needs to be synched at least. As the AmigaOS port shouldn't be 
included in the main pixman git according to your first response I had 
to think of a variant how to to redefine the existing TLS macros for 
other platforms.

In this version of the patch, I introduced a PIXMAN_CUSTOM_TLS define. 
If defined, a file called pixman-tls.h will be included, in which the 
TLS definitions could be made. Otherwise, all TLS defines are done in 
pixman-compiler.h as usual. In AmigaOS, the synchronization will be done 
by a Mutex/Semaphore, therefore it is also necessary to indicate the end 
of an access to a variable. This will be done now by using the 
PIXMAN_UNGET_THREAD_LOCAL macros as the counterpart for 
PIXMAN_GET_THREAD_LOCAL (instead of GET/UNGET words like OBTAIN/RELEASE 
or LOCK/UNLOCK may be better, but I leave this up to you).

I'm not really 100% happy with the PIXMAN_CUSTOM_TLS solution, but I 
didn't see how an external port can supply own definitions otherwise. 
Feedback and comments are welcome! Thanks

Best
Sebastian


---
  pixman/pixman-compiler.h |    9 +++++++++
  pixman/pixman-utils.c    |    2 ++
  2 files changed, 11 insertions(+)

diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h
index a978acc..1081a39 100644
--- a/pixman/pixman-compiler.h
+++ b/pixman/pixman-compiler.h
@@ -94,6 +94,14 @@
      ((type *)(((uint8_t *)data) - offsetof (type, member)))

  /* TLS */
+#if defined(PIXMAN_CUSTOM_TLS)
+
+#include "pixman-tls.h"
+
+#else
+
+#   define PIXMAN_UNGET_THREAD_LOCAL(name) {}
+
  #if defined(PIXMAN_NO_TLS)

  #   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)			\
@@ -220,3 +228,4 @@
  #    error "Unknown thread local support for this system. Pixman will 
not work with multiple threads. Define PIXMAN_NO_TLS to acknowledge and 
accept this limitation and compile pixman without thread-safety 
support."

  #endif
+#endif
\ No newline at end of file
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index 93c061a..addadae 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -120,6 +120,7 @@ _pixman_lookup_composite_function 
(pixman_implementation_t     *toplevel,
  	    ++info;
  	}
      }
+    PIXMAN_UNGET_THREAD_LOCAL(fast_path_cache);
      return FALSE;

  update_cache:
@@ -138,6 +139,7 @@ update_cache:
  	cache->cache[0].fast_path.dest_flags = dest_flags;
  	cache->cache[0].fast_path.func = *out_func;
      }
+    PIXMAN_UNGET_THREAD_LOCAL(fast_path_cache);

      return TRUE;
  }
-- 
1.7.10.4



More information about the Pixman mailing list