1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3 * (C) 2008 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
5 */
6
7 #include "opa_primitives.h"
8 #include <assert.h>
9 #include <stdio.h>
10
11
main(int argc,char ** argv)12 int main(int argc, char **argv)
13 {
14 OPA_int_t a, b;
15 int c;
16 #if defined(OPA_USE_LOCK_BASED_PRIMITIVES)
17 OPA_emulation_ipl_t shm_lock;
18 OPA_Interprocess_lock_init(&shm_lock, 1/*isLeader*/);
19 #endif
20
21 OPA_store_int(&a, 0);
22 OPA_store_int(&b, 1);
23 OPA_add_int(&a, 10);
24 assert(10 == OPA_load_int(&a));
25 c = OPA_cas_int(&a, 10, 11);
26 assert(10 == c);
27 c = OPA_swap_int(&a, OPA_load_int(&b));
28 assert(11 == c);
29 assert(1 == OPA_load_int(&a));
30
31 printf("success!\n");
32
33 return 0;
34 }
35
36