Fabio D'Urso 2396c46999
[libc] Add malloc.h header defining mallopt (#110908)
This patch adds the malloc.h header, declaring Scudo's mallopt
entrypoint when built LLVM_LIBC_INCLUDE_SCUDO, as well as two
constants that can be passed to it (M_PURGE and M_PURGE_ALL).

Due to limitations of the current build system, only the declaration
of mallopt is gated by LLVM_LIBC_INCLUDE_SCUDO, and the two new
constants are defined irrespectively of it. We may need to refine
this in the future.

Note that some allocators other than Scudo may offer a mallopt
implementation too (e.g. man 3 mallopt), albeit with different
supported input values. This patch only supports the specific case of
LLVM_LIBC_INCLUDE_SCUDO.
2024-10-03 18:45:23 +02:00

18 lines
632 B
C

//===-- Definition of macros to be used with malloc functions -------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_MACROS_MALLOC_MACROS_H
#define LLVM_LIBC_MACROS_MALLOC_MACROS_H
// Note: these values only make sense when Scudo is used as the memory
// allocator.
#define M_PURGE (-101)
#define M_PURGE_ALL (-104)
#endif // LLVM_LIBC_MACROS_MALLOC_MACROS_H