diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-17 09:31:12 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-17 11:53:26 +0530 |
commit | baa3641d5f8e64288f45432d6e4989701dbbcc0f (patch) | |
tree | 1ba8efafae76794db4d0853462f04c71d1f2e3e6 /gps/utils/LocSharedLock.h | |
parent | 360bc96adec406327820363cd5f79d3d0edbddf7 (diff) |
msm8996-common: Import newer GPS stack from xiaomi_msm8996-common
Change-Id: I5afe78048c4af3648b2d267d71a58b63b9decbc9
Diffstat (limited to 'gps/utils/LocSharedLock.h')
-rw-r--r-- | gps/utils/LocSharedLock.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gps/utils/LocSharedLock.h b/gps/utils/LocSharedLock.h index 7fe6237..a7af35e 100644 --- a/gps/utils/LocSharedLock.h +++ b/gps/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, |