summaryrefslogtreecommitdiff
path: root/mcon/U/d_sync_atomic.U
blob: 3e94cb74a057113632dfd757588da84027700b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
?RCS: $Id: d_sync_atomic.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 2011, Raphael Manfredi
?RCS:
?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.
?RCS:
?MAKE:d_sync_atomic: Trylink cat
?MAKE:	-pick add $@ %<
?S:d_sync_atomic:
?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.
?S:.
?C:HAS_SYNC_ATOMIC:
?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.
?C:.
?H:#$d_sync_atomic HAS_SYNC_ATOMIC	/**/
?H:.
?LINT:set d_sync_atomic
: check for __sync_synchronize and friends
$cat >try.c <<EOC
int main(void)
{
	static int ret;
	int i;
	__sync_synchronize();
	ret |= __sync_bool_compare_and_swap(&i, 0, 1);
	ret += __sync_fetch_and_add(&i, 1);
	return ret;
}
EOC
cyn="whether atomic memory operations are possible"
set d_sync_atomic
eval $trylink