blob: 2f53c1bc43bc626cc0ca52d10538cdcf45b2001e [file] [log] [blame]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07001/*
Ian Rogers99908912012-08-17 17:28:15 -07002 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070015 */
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070016
Ian Rogers99908912012-08-17 17:28:15 -070017#ifndef LIBC_BIONIC_DLMALLOC_H_
18#define LIBC_BIONIC_DLMALLOC_H_
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070019
Elliott Hughes9b5235d2014-06-03 18:47:17 -070020#include <sys/cdefs.h>
21#include <stddef.h>
22
Ian Rogers99908912012-08-17 17:28:15 -070023/* Configure dlmalloc. */
24#define HAVE_GETPAGESIZE 1
25#define MALLOC_INSPECT_ALL 1
Ian Rogers99908912012-08-17 17:28:15 -070026#define MSPACES 0
27#define REALLOC_ZERO_BYTES_FREES 1
28#define USE_DL_PREFIX 1
29#define USE_LOCKS 1
Kirill Artamonov3e2d2932012-08-31 09:19:16 -070030#define LOCK_AT_FORK 1
Ian Rogers99908912012-08-17 17:28:15 -070031#define USE_RECURSIVE_LOCK 0
32#define USE_SPIN_LOCKS 0
Rom Lemarchandd0f2a602013-07-23 11:30:52 -070033#define DEFAULT_MMAP_THRESHOLD (64U * 1024U)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070034
Elliott Hughes91570ce2014-07-10 12:34:23 -070035#define malloc_getpagesize getpagesize()
36
Christopher Ferrisf9035582014-09-05 16:39:22 -070037#if !defined(__LP64__)
Christopher Ferrisf183f952014-10-08 22:48:20 -070038/* dlmalloc_usable_size and dlmalloc were exposed in the NDK and some
39 * apps actually used them. Rename these functions out of the way
40 * for 32 bit architectures so that ndk_cruft.cpp can expose
41 * compatibility shims with these names.
42 */
Christopher Ferrisf9035582014-09-05 16:39:22 -070043#define dlmalloc_usable_size dlmalloc_usable_size_real
Christopher Ferrisf183f952014-10-08 22:48:20 -070044#define dlmalloc dlmalloc_real
Christopher Ferrisf9035582014-09-05 16:39:22 -070045#endif
46
Elliott Hughes6403cc42014-06-04 16:08:17 -070047/* Export two symbols used by the VM. */
Elliott Hughes67c437b2014-06-04 23:14:48 +000048__BEGIN_DECLS
Elliott Hughes9b5235d2014-06-03 18:47:17 -070049int dlmalloc_trim(size_t) __LIBC_ABI_PUBLIC__;
50void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void*) __LIBC_ABI_PUBLIC__;
51__END_DECLS
52
Ian Rogers99908912012-08-17 17:28:15 -070053/* Include the proper definitions. */
54#include "../upstream-dlmalloc/malloc.h"
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070055
Ian Rogers99908912012-08-17 17:28:15 -070056#endif // LIBC_BIONIC_DLMALLOC_H_