1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2014, 2017, 2020-2022 ARM Limited. All rights reserved. 5 * 6 * This program is free software and is provided to you under the terms of the 7 * GNU General Public License version 2 as published by the Free Software 8 * Foundation, and any use by you of this program is subject to the terms 9 * of such GNU license. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, you can access it online at 18 * http://www.gnu.org/licenses/gpl-2.0.html. 19 * 20 */ 21 22 #ifndef _KERNEL_UTF_UTILS_H_ 23 #define _KERNEL_UTF_UTILS_H_ 24 25 /* kutf_utils.h 26 * Utilities for the kernel UTF test infrastructure. 27 * 28 * This collection of library functions are provided for use by kernel UTF 29 * and users of kernel UTF which don't directly fit within the other 30 * code modules. 31 */ 32 33 #include <kutf/kutf_mem.h> 34 35 /** 36 * KUTF_MAX_DSPRINTF_LEN - Maximum size of the message strings within 37 * kernel UTF, messages longer then this will be truncated. 38 */ 39 #define KUTF_MAX_DSPRINTF_LEN 1024 40 41 /** 42 * kutf_dsprintf() - dynamic sprintf 43 * @pool: memory pool to allocate from 44 * @fmt: The format string describing the string to document. 45 * @... The parameters to feed in to the format string. 46 * 47 * This function implements sprintf which dynamically allocates memory to store 48 * the string. The library will free the memory containing the string when the 49 * result set is cleared or destroyed. 50 * 51 * Note The returned string may be truncated to fit an internal temporary 52 * buffer, which is KUTF_MAX_DSPRINTF_LEN bytes in length. 53 * 54 * Return: Returns pointer to allocated string, or NULL on error. 55 */ 56 const char *kutf_dsprintf(struct kutf_mempool *pool, 57 const char *fmt, ...) __printf(2, 3); 58 59 60 #endif /* _KERNEL_UTF_UTILS_H_ */ 61