Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: crosstest/test_sync_atomic.cpp

Issue 1409863006: Subzero. ARM32. Refactors atomic intrinsics lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pydir/build-runtime.py » ('j') | src/IceTargetLoweringARM32.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/crosstest/test_sync_atomic.cpp - Implementation for tests --===// 1 //===- subzero/crosstest/test_sync_atomic.cpp - Implementation for tests --===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This aims to test that all the atomic RMW instructions and compare and swap 10 // This aims to test that all the atomic RMW instructions and compare and swap
(...skipping 29 matching lines...) Expand all
40 type sum = 0; \ 40 type sum = 0; \
41 for (size_t i = 0; i < buf_size; ++i) { \ 41 for (size_t i = 0; i < buf_size; ++i) { \
42 sum += buf[i]; \ 42 sum += buf[i]; \
43 } \ 43 } \
44 return sum; \ 44 return sum; \
45 } \ 45 } \
46 type test_const_##inst(bool fetch, volatile type *ptr, type ign) { \ 46 type test_const_##inst(bool fetch, volatile type *ptr, type ign) { \
47 if (fetch) { \ 47 if (fetch) { \
48 return __sync_fetch_and_##inst(ptr, 42); \ 48 return __sync_fetch_and_##inst(ptr, 42); \
49 } else { \ 49 } else { \
50 return __sync_##inst##_and_fetch(ptr, 99); \ 50 const type value = static_cast<type>(0xaaaaaaaaaaaaaaaaull); \
51 return __sync_##inst##_and_fetch(ptr, value); \
51 } \ 52 } \
52 } 53 }
53 54
54 FOR_ALL_RMWOP_TYPES(X) 55 FOR_ALL_RMWOP_TYPES(X)
55 #undef X 56 #undef X
56 57
57 #define X(type) \ 58 #define X(type) \
58 type test_val_cmp_swap(volatile type *ptr, type oldval, type newval) { \ 59 type test_val_cmp_swap(volatile type *ptr, type oldval, type newval) { \
59 return __sync_val_compare_and_swap(ptr, oldval, newval); \ 60 return __sync_val_compare_and_swap(ptr, oldval, newval); \
60 } \ 61 } \
61 type test_val_cmp_swap_loop(volatile type *ptr, type oldval, type newval) { \ 62 type test_val_cmp_swap_loop(volatile type *ptr, type oldval, type newval) { \
62 type prev; \ 63 type prev; \
63 type succeeded_first_try = 1; \ 64 type succeeded_first_try = 1; \
64 while (1) { \ 65 while (1) { \
65 prev = __sync_val_compare_and_swap(ptr, oldval, newval); \ 66 prev = __sync_val_compare_and_swap(ptr, oldval, newval); \
66 if (prev == oldval) \ 67 if (prev == oldval) \
67 break; \ 68 break; \
68 succeeded_first_try = 0; \ 69 succeeded_first_try = 0; \
69 oldval = prev; \ 70 oldval = prev; \
70 } \ 71 } \
71 return succeeded_first_try; \ 72 return succeeded_first_try; \
72 } 73 }
73 74
74 ATOMIC_TYPE_TABLE 75 ATOMIC_TYPE_TABLE
75 #undef X 76 #undef X
OLDNEW
« no previous file with comments | « no previous file | pydir/build-runtime.py » ('j') | src/IceTargetLoweringARM32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698