2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBase_String.h
19 * @brief This is the header file for handling atomic operations.
21 #ifndef _FBASE_INTERNAL_STRING_H_
22 #define _FBASE_INTERNAL_STRING_H_
24 namespace Tizen { namespace Base
30 * Atomically add the value to the variable that pRefCount points to.
35 AtomicAdd(volatile int* pRefCount, int value)
40 "1: ldrex %0, [%1] \n\t"
42 "strex r2, r1, [%1] \n\t"
46 : "r"(pRefCount), "r"(value)
51 return __sync_fetch_and_add(pRefCount, value);
56 * Atomically increase the variable that pRefCount points to by 1
61 AtomicInc(volatile int* pRefCount)
63 return AtomicAdd(pRefCount, 1);
67 * Atomically decrease the variable that pRefCount points to by 1
72 AtomicDec(volatile int* pRefCount)
74 return AtomicAdd(pRefCount, -1);
78 #endif // _FBASE_INTERNAL_STRING_H_