/*
* Mutex-free cache for key1+key2=value.
*/
-#ifndef _DALVIK_ATOMICCACHE
-#define _DALVIK_ATOMICCACHE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef DALVIK_ATOMICCACHE_H_
+#define DALVIK_ATOMICCACHE_H_
/*
* If set to "1", gather some stats on our caching success rate.
*
* Must be exactly 16 bytes.
*/
-typedef struct AtomicCacheEntry {
+struct AtomicCacheEntry {
u4 key1;
u4 key2;
u4 value;
volatile u4 version; /* version and lock flag */
-} AtomicCacheEntry;
+};
/*
* One cache.
* struct and "entries" separately, avoiding an indirection. (We already
* handle "numEntries" separately in ATOMIC_CACHE_LOOKUP.)
*/
-typedef struct AtomicCache {
+struct AtomicCache {
AtomicCacheEntry* entries; /* array of entries */
int numEntries; /* #of entries, must be power of 2 */
int hits; /* found entry in cache */
int misses; /* entry was for other keys */
int fills; /* entry was empty */
-} AtomicCache;
+};
/*
* Do a cache lookup. We need to be able to read and write entries
* boost. \
*/ \
value = (u4) ATOMIC_CACHE_CALC; \
- dvmUpdateAtomicCache((u4) (_key1), (u4) (_key2), value, pEntry, \
- firstVersion CACHE_XARG(_cache) ); \
+ if (value == 0 && ATOMIC_CACHE_NULL_ALLOWED) { \
+ dvmUpdateAtomicCache((u4) (_key1), (u4) (_key2), value, pEntry, \
+ firstVersion CACHE_XARG(_cache) ); \
+ } \
} \
value; \
})
*/
void dvmDumpAtomicCacheStats(const AtomicCache* pCache);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_DALVIK_ATOMICCACHE*/
+#endif // DALVIK_ATOMICCACHE_H_