Debian Codegraph @

regressions/ck_pr/validate/ck_pr_fence.c

raw
1 /*
2 * Copyright 2009-2018 Samy Al Bahra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27 #include <ck_pr.h>
28 #include "../../common.h"
29
30 int
31 main(void)
32 {
33 int r = 0;
34
35 /* Below serves as a marker. */
36 ck_pr_sub_int(&r, 31337);
37
38 /*
39 * This is a simple test to help ensure all fences compile or crash
40 * on target. Below are generated according to the underlying memory
41 * model's ordering.
42 */
43 ck_pr_fence_atomic();
44 ck_pr_fence_atomic_store();
45 ck_pr_fence_atomic_load();
46 ck_pr_fence_store_atomic();
47 ck_pr_fence_load_atomic();
48 ck_pr_fence_load();
49 ck_pr_fence_load_store();
50 ck_pr_fence_store();
51 ck_pr_fence_store_load();
52 ck_pr_fence_memory();
53 ck_pr_fence_release();
54 ck_pr_fence_acquire();
55 ck_pr_fence_acqrel();
56 ck_pr_fence_lock();
57 ck_pr_fence_unlock();
58
59 /* Below serves as a marker. */
60 ck_pr_sub_int(&r, 31337);
61
62 /* The following are generating assuming RMO. */
63 ck_pr_fence_strict_atomic();
64 ck_pr_fence_strict_atomic_store();
65 ck_pr_fence_strict_atomic_load();
66 ck_pr_fence_strict_store_atomic();
67 ck_pr_fence_strict_load_atomic();
68 ck_pr_fence_strict_load();
69 ck_pr_fence_strict_load_store();
70 ck_pr_fence_strict_store();
71 ck_pr_fence_strict_store_load();
72 ck_pr_fence_strict_memory();
73 ck_pr_fence_strict_release();
74 ck_pr_fence_strict_acquire();
75 ck_pr_fence_strict_acqrel();
76 ck_pr_fence_strict_lock();
77 ck_pr_fence_strict_unlock();
78 return 0;
79 }
80