OSDN Git Service

Add support for Solaris libc atomic operations
authorAlan Coopersmith <alan.coopersmith@sun.com>
Sun, 17 Jan 2010 03:28:50 +0000 (19:28 -0800)
committerAlan Coopersmith <alan.coopersmith@sun.com>
Sun, 17 Jan 2010 03:37:06 +0000 (19:37 -0800)
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
configure.ac
intel/intel_atomic.h

index b257ccf..49e193e 100644 (file)
@@ -186,6 +186,12 @@ if test "x$INTEL" != "xno"; then
                    AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops")
            fi
 
+           # atomic functions defined in <atomic.h> & libc on Solaris
+           if test "x$drm_cv_atomic_primitives" = "xnone"; then
+                   AC_CHECK_FUNC([atomic_cas_uint],
+                                 drm_cv_atomic_primitives="Solaris")
+           fi
+
     ])
     if test "x$drm_cv_atomic_primitives" = xIntel; then
            AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1,
index e725c4a..12bb96b 100644 (file)
@@ -71,6 +71,21 @@ typedef struct {
 
 #endif
 
+#if defined(__sun) && !defined(HAS_ATOMIC_OPS)  /* Solaris & OpenSolaris */
+
+#include <sys/atomic.h>
+#define HAS_ATOMIC_OPS 1
+
+typedef struct { uint_t atomic; } atomic_t;
+
+# define atomic_read(x) (int) ((x)->atomic)
+# define atomic_set(x, val) ((x)->atomic = (uint_t)(val))
+# define atomic_inc(x) (atomic_inc_uint (&(x)->atomic))
+# define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 1)
+# define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv)
+
+#endif
+
 #if ! HAS_ATOMIC_OPS
 #error libdrm-intel requires atomic operations, please define them for your CPU/compiler.
 #endif