1 /*
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
32 inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; }
33 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; }
34 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
35 inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; }
36
37 inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; }
38 inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; }
39 inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; }
40 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; }
41 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
42 inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; }
43
44 inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); }
45 inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); }
46 inline void Atomic::inc_ptr(volatile void* dest) { (void)add_ptr(1, dest); }
47
48 inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); }
49 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
50 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); }
51
52 inline jlong Atomic::load(volatile jlong* src) { return *src; }
53
54 inline jint Atomic::add (jint add_value, volatile jint* dest) {
55 intptr_t rv;
56 __asm__ volatile(
57 "1: \n\t"
58 " ld [%2], %%o2\n\t"
59 " add %1, %%o2, %%o3\n\t"
60 " cas [%2], %%o2, %%o3\n\t"
61 " cmp %%o2, %%o3\n\t"
62 " bne 1b\n\t"
63 " nop\n\t"
64 " add %1, %%o2, %0\n\t"
65 : "=r" (rv)
66 : "r" (add_value), "r" (dest)
67 : "memory", "o2", "o3");
68 return rv;
69 }
70
71 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
72 intptr_t rv;
|
1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
32 inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; }
33 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; }
34 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
35 inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; }
36
37 inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; }
38 inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; }
39 inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; }
40 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; }
41 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
42 inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; }
43
44 inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); }
45 inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); }
46 inline void Atomic::inc_ptr(volatile void* dest) { (void)add_ptr(1, dest); }
47
48 inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); }
49 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
50 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); }
51
52 inline jlong Atomic::load(const volatile jlong* src) { return *src; }
53
54 inline jint Atomic::add (jint add_value, volatile jint* dest) {
55 intptr_t rv;
56 __asm__ volatile(
57 "1: \n\t"
58 " ld [%2], %%o2\n\t"
59 " add %1, %%o2, %%o3\n\t"
60 " cas [%2], %%o2, %%o3\n\t"
61 " cmp %%o2, %%o3\n\t"
62 " bne 1b\n\t"
63 " nop\n\t"
64 " add %1, %%o2, %0\n\t"
65 : "=r" (rv)
66 : "r" (add_value), "r" (dest)
67 : "memory", "o2", "o3");
68 return rv;
69 }
70
71 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
72 intptr_t rv;
|