2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/malloc.h
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_MALLOC_H
|
|
|
|
#define __INCLUDE_MALLOC_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-08-19 22:13:36 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-05-28 20:09:42 +08:00
|
|
|
/* Special PID to query the info about alloc, free and mempool */
|
|
|
|
|
|
|
|
#define PID_MM_INVALID ((pid_t)-4)
|
|
|
|
#define PID_MM_MEMPOOL ((pid_t)-3)
|
|
|
|
#define PID_MM_FREE ((pid_t)-2)
|
|
|
|
#define PID_MM_ALLOC ((pid_t)-1)
|
|
|
|
|
2021-06-27 03:57:56 +08:00
|
|
|
/* For Linux and MacOS compatibility */
|
|
|
|
|
|
|
|
#define malloc_usable_size malloc_size
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct mallinfo
|
|
|
|
{
|
|
|
|
int arena; /* This is the total size of memory allocated
|
|
|
|
* for use by malloc in bytes. */
|
|
|
|
int ordblks; /* This is the number of free (not in use) chunks */
|
2021-04-28 11:05:20 +08:00
|
|
|
int aordblks; /* This is the number of allocated (in use) chunks */
|
2020-06-15 10:38:55 +08:00
|
|
|
int mxordblk; /* Size of the largest free (not in use) chunk */
|
|
|
|
int uordblks; /* This is the total size of memory occupied by
|
|
|
|
* chunks handed out by malloc. */
|
|
|
|
int fordblks; /* This is the total size of memory occupied
|
|
|
|
* by free (not in use) chunks. */
|
|
|
|
};
|
|
|
|
|
2023-05-28 19:23:56 +08:00
|
|
|
struct malltask
|
2023-05-05 16:52:30 +08:00
|
|
|
{
|
|
|
|
pid_t pid; /* Process id */
|
|
|
|
#if CONFIG_MM_BACKTRACE >= 0
|
|
|
|
unsigned long seqmin; /* The minimum sequence */
|
|
|
|
unsigned long seqmax; /* The maximum sequence */
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2022-01-22 20:21:51 +08:00
|
|
|
struct mallinfo_task
|
|
|
|
{
|
|
|
|
int aordblks; /* This is the number of allocated (in use) chunks for task */
|
|
|
|
int uordblks; /* This is the total size of memory occupied for task */
|
|
|
|
};
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct mallinfo mallinfo(void);
|
2021-06-27 03:57:56 +08:00
|
|
|
size_t malloc_size(FAR void *ptr);
|
2023-05-28 19:23:56 +08:00
|
|
|
struct mallinfo_task mallinfo_task(FAR const struct malltask *task);
|
2020-06-15 10:38:55 +08:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCLUDE_MALLOC_H */
|