Diffstat (limited to 'mcon/U/d_sync_atomic.U')
1 files changed, 42 insertions, 0 deletions
diff --git a/mcon/U/d_sync_atomic.U b/mcon/U/d_sync_atomic.U
new file mode 100644
@@ -0,0 +1,42 @@
+?RCS: $Id: d_sync_atomic.U 167 2013-05-08 17:58:00Z rmanfredi $
+?RCS: Copyright (c) 2011, Raphael Manfredi
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?MAKE:d_sync_atomic: Trylink cat
+?MAKE: -pick add $@ %<
+?S: This variable conditionally defines the HAS_SYNC_ATOMIC symbol, which
+?S: indicates to the C program that __sync_xxx() atomic operations are
+?S: made available by the compiler.
+?C: This symbol, if defined, indicates that __sync_xxx() atomic operations
+?C: are made available by the compiler, namely __sync_synchronize() to
+?C: issue a memory barrieer, __sync_bool_compare_and_swap() for issuing a
+?C: test-and-set and __sync_fetch_and_add() for atomic increases of values.
+?H:#$d_sync_atomic HAS_SYNC_ATOMIC /**/
+: check for __sync_synchronize and friends
+$cat >try.c <<EOC
+ static int ret;
+ int i;
+ ret |= __sync_bool_compare_and_swap(&i, 0, 1);
+ ret += __sync_fetch_and_add(&i, 1);
+ return ret;
+cyn="whether atomic memory operations are possible"