The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 3 | * |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 7 | * |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 16 | |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 17 | #ifndef LIBC_INCLUDE_MALLOC_H_ |
| 18 | #define LIBC_INCLUDE_MALLOC_H_ |
| 19 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 20 | #include <sys/cdefs.h> |
| 21 | #include <stddef.h> |
Dan Albert | 4caa1f0 | 2014-08-20 09:16:57 -0700 | [diff] [blame] | 22 | #include <stdio.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 23 | |
| 24 | __BEGIN_DECLS |
| 25 | |
Elliott Hughes | 3b2096a | 2016-07-22 18:57:12 -0700 | [diff] [blame^] | 26 | void* malloc(size_t byte_count) __mallocfunc __wur; |
| 27 | void* calloc(size_t item_count, size_t item_size) __mallocfunc __wur; |
| 28 | void* realloc(void* p, size_t byte_count) __wur; |
| 29 | void free(void* p); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 30 | |
Elliott Hughes | 3b2096a | 2016-07-22 18:57:12 -0700 | [diff] [blame^] | 31 | void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur; |
| 32 | size_t malloc_usable_size(const void* p) __INTRODUCED_IN(17); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 33 | |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 34 | #ifndef STRUCT_MALLINFO_DECLARED |
| 35 | #define STRUCT_MALLINFO_DECLARED 1 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 36 | struct mallinfo { |
Elliott Hughes | 24fad01 | 2013-02-04 13:44:14 -0800 | [diff] [blame] | 37 | size_t arena; /* Total number of non-mmapped bytes currently allocated from OS. */ |
| 38 | size_t ordblks; /* Number of free chunks. */ |
| 39 | size_t smblks; /* (Unused.) */ |
| 40 | size_t hblks; /* (Unused.) */ |
| 41 | size_t hblkhd; /* Total number of bytes in mmapped regions. */ |
| 42 | size_t usmblks; /* Maximum total allocated space; greater than total if trimming has occurred. */ |
| 43 | size_t fsmblks; /* (Unused.) */ |
| 44 | size_t uordblks; /* Total allocated space (normal or mmapped.) */ |
| 45 | size_t fordblks; /* Total free space. */ |
| 46 | size_t keepcost; /* Upper bound on number of bytes releasable by malloc_trim. */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 47 | }; |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 48 | #endif /* STRUCT_MALLINFO_DECLARED */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 49 | |
Elliott Hughes | 3b2096a | 2016-07-22 18:57:12 -0700 | [diff] [blame^] | 50 | struct mallinfo mallinfo(void); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 51 | |
Dan Albert | 4caa1f0 | 2014-08-20 09:16:57 -0700 | [diff] [blame] | 52 | /* |
| 53 | * XML structure for malloc_info(3) is in the following format: |
| 54 | * |
| 55 | * <malloc version="jemalloc-1"> |
| 56 | * <heap nr="INT"> |
| 57 | * <allocated-large>INT</allocated-large> |
| 58 | * <allocated-huge>INT</allocated-huge> |
| 59 | * <allocated-bins>INT</allocated-bins> |
| 60 | * <bins-total>INT</bins-total> |
| 61 | * <bin nr="INT"> |
| 62 | * <allocated>INT</allocated> |
| 63 | * <nmalloc>INT</nmalloc> |
| 64 | * <ndalloc>INT</ndalloc> |
| 65 | * </bin> |
| 66 | * <!-- more bins --> |
| 67 | * </heap> |
| 68 | * <!-- more heaps --> |
| 69 | * </malloc> |
| 70 | */ |
Elliott Hughes | 3b2096a | 2016-07-22 18:57:12 -0700 | [diff] [blame^] | 71 | int malloc_info(int, FILE*) __INTRODUCED_IN(23); |
Dan Albert | 4caa1f0 | 2014-08-20 09:16:57 -0700 | [diff] [blame] | 72 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 73 | __END_DECLS |
| 74 | |
Ian Rogers | 2c344d3 | 2012-08-28 15:53:10 -0700 | [diff] [blame] | 75 | #endif /* LIBC_INCLUDE_MALLOC_H_ */ |