tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Alignment of small memory allocations returned by malloc(3)



Hi,

Standards and modern tools, e.g. gcc[1] 4.8, expect malloc to return memory with alignment that is different to our current jemalloc.Attached is a suggested diff to fix the problem for most platforms.

I've probably missed other alignment requirements.

Comments?

Nick

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59958
Index: lib/libc/stdlib/jemalloc.c
===================================================================
RCS file: /cvsroot/src/lib/libc/stdlib/jemalloc.c,v
retrieving revision 1.29
diff -u -p -r1.29 jemalloc.c
--- lib/libc/stdlib/jemalloc.c  12 Sep 2013 15:35:15 -0000      1.29
+++ lib/libc/stdlib/jemalloc.c  30 Jan 2014 07:53:27 -0000
@@ -228,6 +228,7 @@ __strerror_r(int e, char *s, size_t l)
 #ifdef __alpha__
 #  define QUANTUM_2POW_MIN     4
 #  define SIZEOF_PTR_2POW      3
+#  define TINY_MIN_2POW                3
 #  define NO_TLS
 #endif
 #ifdef __sparc64__
@@ -243,6 +244,9 @@ __strerror_r(int e, char *s, size_t l)
 #  define QUANTUM_2POW_MIN     3
 #  define SIZEOF_PTR_2POW      2
 #  define USE_BRK
+#  ifdef __ARM_EABI__
+#    define TINY_MIN_2POW      3
+#  endif
 #  define NO_TLS
 #endif
 #ifdef __powerpc__
@@ -303,7 +307,9 @@ __strerror_r(int e, char *s, size_t l)
 #define        CACHELINE               ((size_t)(1 << CACHELINE_2POW))
 
 /* Smallest size class to support. */
-#define        TINY_MIN_2POW           1
+#ifndef TINY_MIN_2POW
+#define        TINY_MIN_2POW           2
+#endif
 
 /*
  * Maximum size class that is a multiple of the quantum, but not (necessarily)



Home | Main Index | Thread Index | Old Index