From: Yu Watanabe Date: Mon, 9 Jun 2025 15:40:59 +0000 (+0900) Subject: musl: introduce dummy functions for mallinfo(), malloc_info(), and malloc_trim() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bc610c70afcfe3cc489ecc18178f5d62d74e0d9b;p=thirdparty%2Fsystemd.git musl: introduce dummy functions for mallinfo(), malloc_info(), and malloc_trim() These functions are not provided by musl. --- diff --git a/src/include/musl/malloc.h b/src/include/musl/malloc.h new file mode 100644 index 00000000000..9d15d4bf911 --- /dev/null +++ b/src/include/musl/malloc.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include +#include + +/* struct mallinfo2 will be defined and struct mallinfo is converted to struct mallinfo2 in + * override/malloc.h. Hence, here we define struct mallinfo. */ + +struct mallinfo { + int arena; /* non-mmapped space allocated from system */ + int ordblks; /* number of free chunks */ + int smblks; /* number of fastbin blocks */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* space in mmapped regions */ + int usmblks; /* always 0, preserved for backwards compatibility */ + int fsmblks; /* space available in freed fastbin blocks */ + int uordblks; /* total allocated space */ + int fordblks; /* total free space */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ +}; + +static inline struct mallinfo mallinfo(void) { + return (struct mallinfo) {}; +} + +static inline int malloc_info(int options, FILE *stream) { + if (options != 0) + errno = EINVAL; + else + errno = EOPNOTSUPP; + return -1; +} + +static inline int malloc_trim(size_t pad) { + return 0; +} + +#include_next