diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-14 20:38:19 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-14 20:38:19 +0530 |
commit | 86a968c3f424cb70e03cccb24cabf9751f6f636d (patch) | |
tree | 5aedd15a754e4c0de8a015a4fd2c2e5c0698a22b /gps/utils/LocSharedLock.h | |
parent | ea30e6e77df9c7a651f22bcc5797b8a3f33703dc (diff) |
update gps stack
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, |