diff options
author | Mike Cailean <mcailean@codeaurora.org> | 2018-12-13 10:08:18 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-02-07 11:13:58 -0800 |
commit | dc0efb480067db854d27ef439c1fb598769ba361 (patch) | |
tree | b7d82b3aed9615d95e9abf4c16795e4b06c0dc5f /utils/LocSharedLock.h | |
parent | 9d6d95d09650ea9ada4771f00f1991b7a5f2cc91 (diff) | |
download | gps-dc0efb480067db854d27ef439c1fb598769ba361.tar.gz |
Enable support for External AP build
Enable support for build on External AP without
libcutils or any Android library support.
CRs-fixed: 2368435
Change-Id: I978127348fd6b8d90ed5ef0a714c02437dc59ee0
Diffstat (limited to 'utils/LocSharedLock.h')
-rw-r--r-- | utils/LocSharedLock.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/utils/LocSharedLock.h b/utils/LocSharedLock.h index 7fe6237..a7af35e 100644 --- a/utils/LocSharedLock.h +++ b/utils/LocSharedLock.h @@ -30,10 +30,28 @@ #define __LOC_SHARED_LOCK__ #include <stddef.h> +#ifndef FEATURE_EXTERNAL_AP #include <cutils/atomic.h> +#endif /* FEATURE_EXTERNAL_AP */ #include <pthread.h> -// This is a utility created for use cases such that there are more than +#ifdef FEATURE_EXTERNAL_AP +#include <atomic> + +inline int32_t android_atomic_inc(volatile int32_t *addr) +{ + volatile std::atomic_int_least32_t* a = (volatile std::atomic_int_least32_t*)addr; + return std::atomic_fetch_add_explicit(a, 1, std::memory_order_release); +} + +inline int32_t android_atomic_dec(volatile int32_t *addr) +{ + volatile std::atomic_int_least32_t* a = (volatile std::atomic_int_least32_t*)addr; + return std::atomic_fetch_sub_explicit(a, 1, std::memory_order_release); +} + +#endif /* FEATURE_EXTERNAL_AP */ + // This is a utility created for use cases such that there are more than // one client who need to share the same lock, but it is not predictable // which of these clients is to last to go away. This shared lock deletes // itself when the last client calls its drop() method. To add a cient, |