aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_alloc.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2011-03-10 14:53:29 +0100
committerSverker Eriksson <[email protected]>2011-03-10 14:53:29 +0100
commit27e6ebe3eaf9186e797e3a334d85f64e9ddb37ec (patch)
treeb7b1df00b2f67b3b7836a961cb385d3405dcc8a3 /erts/emulator/beam/erl_alloc.h
parent0213def22b5ab6f145a5529f9bbef0d26124abaf (diff)
parent4a09d6252e6fca9ed07c479ce16717085969d998 (diff)
downloadotp-27e6ebe3eaf9186e797e3a334d85f64e9ddb37ec.tar.gz
otp-27e6ebe3eaf9186e797e3a334d85f64e9ddb37ec.tar.bz2
otp-27e6ebe3eaf9186e797e3a334d85f64e9ddb37ec.zip
Merge branch 'sverker/valgrind-new-suppressions' into dev
* sverker/valgrind-new-suppressions: Make halfword emulator with valgrind target allocate low memory Add erts_alloc_permanent_cache_aligned to supress valgrind
Diffstat (limited to 'erts/emulator/beam/erl_alloc.h')
-rw-r--r--erts/emulator/beam/erl_alloc.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_alloc.h b/erts/emulator/beam/erl_alloc.h
index 17ff9c3b03..ce792d4d17 100644
--- a/erts/emulator/beam/erl_alloc.h
+++ b/erts/emulator/beam/erl_alloc.h
@@ -172,9 +172,17 @@ void *erts_realloc(ErtsAlcType_t type, void *ptr, Uint size);
void erts_free(ErtsAlcType_t type, void *ptr);
void *erts_alloc_fnf(ErtsAlcType_t type, Uint size);
void *erts_realloc_fnf(ErtsAlcType_t type, void *ptr, Uint size);
+void *erts_alloc_permanent_cache_aligned(ErtsAlcType_t type, Uint size);
+
#endif /* #if !ERTS_ALC_DO_INLINE */
+#ifndef ERTS_CACHE_LINE_SIZE
+/* Assume a cache line size of 64 bytes */
+# define ERTS_CACHE_LINE_SIZE ((UWord) 64)
+# define ERTS_CACHE_LINE_MASK (ERTS_CACHE_LINE_SIZE - 1)
+#endif
+
#if ERTS_ALC_DO_INLINE || defined(ERTS_ALC_INTERNAL__)
ERTS_ALC_INLINE
@@ -234,6 +242,18 @@ void *erts_realloc_fnf(ErtsAlcType_t type, void *ptr, Uint size)
size);
}
+ERTS_ALC_INLINE
+void *erts_alloc_permanent_cache_aligned(ErtsAlcType_t type, Uint size)
+{
+ UWord v = (UWord) erts_alloc(type, size + (ERTS_CACHE_LINE_SIZE-1));
+
+ if (v & ERTS_CACHE_LINE_MASK) {
+ v = (v & ~ERTS_CACHE_LINE_MASK) + ERTS_CACHE_LINE_SIZE;
+ }
+ ASSERT((v & ERTS_CACHE_LINE_MASK) == 0);
+ return (void*)v;
+}
+
#endif /* #if ERTS_ALC_DO_INLINE || defined(ERTS_ALC_INTERNAL__) */
typedef void (*erts_alloc_verify_func_t)(Allctr_t *);
@@ -241,11 +261,6 @@ typedef void (*erts_alloc_verify_func_t)(Allctr_t *);
erts_alloc_verify_func_t
erts_alloc_get_verify_unused_temp_alloc(Allctr_t **allctr);
-#ifndef ERTS_CACHE_LINE_SIZE
-/* Assume a cache line size of 64 bytes */
-# define ERTS_CACHE_LINE_SIZE ((UWord) 64)
-# define ERTS_CACHE_LINE_MASK (ERTS_CACHE_LINE_SIZE - 1)
-#endif
#define ERTS_ALC_CACHE_LINE_ALIGN_SIZE(SZ) \
(((((SZ) - 1) / ERTS_CACHE_LINE_SIZE) + 1) * ERTS_CACHE_LINE_SIZE)