dlmalloc.h revision 1c365cb494d8cab1b639ecef21514425647e606b
1/*
2 * 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.
15 */
16
17#ifndef LIBC_BIONIC_DLMALLOC_H_
18#define LIBC_BIONIC_DLMALLOC_H_
19
20#include <sys/cdefs.h>
21#include <stddef.h>
22
23/* Configure dlmalloc. */
24#define HAVE_GETPAGESIZE 1
25#define MALLOC_INSPECT_ALL 1
26#define MSPACES 0
27#define REALLOC_ZERO_BYTES_FREES 1
28#define USE_DL_PREFIX 1
29#define USE_LOCKS 1
30#define LOCK_AT_FORK 1
31#define USE_RECURSIVE_LOCK 0
32#define USE_SPIN_LOCKS 0
33#define DEFAULT_MMAP_THRESHOLD (64U * 1024U)
34
35#define malloc_getpagesize getpagesize()
36
37/* dlmalloc_usable_size was exposed in the NDK, so change the name
38 * of the function on 32 bit architectures.
39 */
40#if !defined(__LP64__)
41#define dlmalloc_usable_size dlmalloc_usable_size_real
42#endif
43
44/* Export two symbols used by the VM. */
45__BEGIN_DECLS
46int dlmalloc_trim(size_t) __LIBC_ABI_PUBLIC__;
47void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void*) __LIBC_ABI_PUBLIC__;
48__END_DECLS
49
50/* Include the proper definitions. */
51#include "../upstream-dlmalloc/malloc.h"
52
53#endif  // LIBC_BIONIC_DLMALLOC_H_
54