Permalink
Browse files

Fix build on freebsd 8.2

Change-Id: I2b545d327a5e342a27f168f8304b494b2cdcc601
  • Loading branch information...
1 parent ca739a8 commit 7dcdd3ef818c3f88b56128317dc9d4ca82f11a47 @avsej committed Nov 22, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 clients/ms_atomic.h
View
@@ -27,7 +27,7 @@
# define atomic_dec_size_nv(X, Y) atomic_add_32((X), (Y))
# endif
# undef _KERNEL
-#elif HAVE_GCC_ATOMIC_BUILTINS
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
# define atomic_add_8(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_16(X, Y) __sync_fetch_and_add((X), (Y))
# define atomic_add_32(X, Y) __sync_fetch_and_add((X), (Y))
@@ -45,6 +45,17 @@
# define atomic_dec_16_nv(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_32_nv(X) __sync_fetch_and_sub((X), 1)
# define atomic_dec_size_nv(X) __sync_fetch_and_sub((X), 1)
+#elif defined(TARGET_OS_FREEBSD)
+# include <sys/cdefs.h>
+# include <machine/atomic.h>
+/* atomic_add_{8,16,32} already defined in machine/atomic.h */
+# define atomic_dec_8(X) atomic_subtract_8((X), 1)
+# define atomic_dec_16(X) atomic_subtract_16((X), 1)
+# define atomic_dec_32(X) atomic_subtract_32((X), 1)
+# define atomic_add_size(X, Y) atomic_add_32((X), (Y))
+# define atomic_dec_size(X, Y) atomic_subtract_32((X), (Y))
+# define atomic_add_size_nv(X, Y) atomic_fetchadd_32((X), (Y))
+# define atomic_add_32_nv(X, Y) atomic_fetchadd_32((X), (Y))
#else
#warning "Atomic operators not found so memslap will not work correctly"
# define atomic_add_8(X, Y)

1 comment on commit 7dcdd3e

alk commented on 7dcdd3e Nov 23, 2011

looks ok, but cannot verify/review freebsd-specific includes

Please sign in to comment.