Path: blob/main/sys/contrib/openzfs/include/zfs_valstr.h
48254 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License (the "License").6* You may not use this file except in compliance with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/2122/*23* Copyright (c) 2024, Klara Inc.24*/2526#ifndef _ZFS_VALSTR_H27#define _ZFS_VALSTR_H extern __attribute__((visibility("default")))2829#include <sys/fs/zfs.h>30#include <sys/types.h>3132#ifdef __cplusplus33extern "C" {34#endif3536/*37* These macros create function prototypes for pretty-printing or stringifying38* certain kinds of numeric types.39*40* _ZFS_VALSTR_DECLARE_BITFIELD(name) creates:41*42* size_t zfs_valstr_<name>_bits(uint64_t bits, char *out, size_t outlen);43* expands single char for each set bit, and space for each clear bit44*45* size_t zfs_valstr_<name>_pairs(uint64_t bits, char *out, size_t outlen);46* expands two-char mnemonic for each bit set in `bits`, separated by `|`47*48* size_t zfs_valstr_<name>(uint64_t bits, char *out, size_t outlen);49* expands full name of each bit set in `bits`, separated by spaces50*51* _ZFS_VALSTR_DECLARE_ENUM(name) creates:52*53* size_t zfs_valstr_<name>(int v, char *out, size_t outlen);54* expands full name of enum value55*56* Each _ZFS_VALSTR_DECLARE_xxx needs a corresponding _VALSTR_xxx_IMPL string57* table in vfs_valstr.c.58*/5960#define _ZFS_VALSTR_DECLARE_BITFIELD(name) \61_ZFS_VALSTR_H size_t zfs_valstr_ ## name ## _bits( \62uint64_t bits, char *out, size_t outlen); \63_ZFS_VALSTR_H size_t zfs_valstr_ ## name ## _pairs( \64uint64_t bits, char *out, size_t outlen); \65_ZFS_VALSTR_H size_t zfs_valstr_ ## name( \66uint64_t bits, char *out, size_t outlen); \6768#define _ZFS_VALSTR_DECLARE_ENUM(name) \69_ZFS_VALSTR_H size_t zfs_valstr_ ## name( \70int v, char *out, size_t outlen); \7172_ZFS_VALSTR_DECLARE_BITFIELD(zio_flag)73_ZFS_VALSTR_DECLARE_BITFIELD(zio_stage)7475_ZFS_VALSTR_DECLARE_ENUM(zio_type)76_ZFS_VALSTR_DECLARE_ENUM(zio_priority)7778#undef _ZFS_VALSTR_DECLARE_BITFIELD79#undef _ZFS_VALSTR_DECLARE_ENUM8081#ifdef __cplusplus82}83#endif8485#endif /* _ZFS_VALSTR_H */868788