Support for jemalloc to replace dlmalloc.

To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.

Update the pthread_create_key tests since jemalloc uses a few keys.
Add a new test to verify memalign works as expected.

Bug: 981363

Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index 28be042..c1c3c89 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -45,11 +45,22 @@
 
 #define MAX_SIZE_T           (~(size_t)0)
 
-// This must match the alignment used by dlmalloc.
+// This must match the alignment used by the malloc implementation.
 #ifndef MALLOC_ALIGNMENT
 #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))
 #endif
 
+#ifdef USE_JEMALLOC
+#include "jemalloc.h"
+#define Malloc(function)  je_ ## function
+#else
+#ifndef USE_DLMALLOC
+#error "Either one of USE_DLMALLOC or USE_JEMALLOC must be defined."
+#endif
+#include "dlmalloc.h"
+#define Malloc(function)  dl ## function
+#endif
+
 // =============================================================================
 // Structures
 // =============================================================================