[llvm-commits] [test-suite] r49919 - /test-suite/trunk/SingleSource/UnitTests/AtomicOps.c
Evan Cheng
evan.cheng at apple.com
Fri Apr 18 13:54:46 PDT 2008
Author: evancheng
Date: Fri Apr 18 15:54:46 2008
New Revision: 49919
URL: http://llvm.org/viewvc/llvm-project?rev=49919&view=rev
Log:
Add a test for atomic builtins.
Added:
test-suite/trunk/SingleSource/UnitTests/AtomicOps.c
Added: test-suite/trunk/SingleSource/UnitTests/AtomicOps.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/AtomicOps.c?rev=49919&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/AtomicOps.c (added)
+++ test-suite/trunk/SingleSource/UnitTests/AtomicOps.c Fri Apr 18 15:54:46 2008
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+int foo(volatile *mem, int val, int c) {
+ int oldval = __sync_fetch_and_add(mem, val);
+ return oldval + c;
+}
+
+int main() {
+ volatile int x = 0;
+ int y = foo(&x, 1, 2);
+ printf("%d, %d\n", y, x);
+ y = __sync_val_compare_and_swap(&x, 1, 2);
+ printf("%d, %d\n", y, x);
+ y = __sync_lock_test_and_set(&x, 1);
+ printf("%d, %d\n", y, x);
+ return 0;
+}
More information about the llvm-commits
mailing list