162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * debug.h - NTFS kernel debug support. Part of the Linux-NTFS project.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2001-2004 Anton Altaparmakov
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _LINUX_NTFS_DEBUG_H
962306a36Sopenharmony_ci#define _LINUX_NTFS_DEBUG_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/fs.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include "runlist.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifdef DEBUG
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciextern int debug_msgs;
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciextern __printf(4, 5)
2062306a36Sopenharmony_civoid __ntfs_debug(const char *file, int line, const char *function,
2162306a36Sopenharmony_ci		  const char *format, ...);
2262306a36Sopenharmony_ci/**
2362306a36Sopenharmony_ci * ntfs_debug - write a debug level message to syslog
2462306a36Sopenharmony_ci * @f:		a printf format string containing the message
2562306a36Sopenharmony_ci * @...:	the variables to substitute into @f
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * ntfs_debug() writes a DEBUG level message to the syslog but only if the
2862306a36Sopenharmony_ci * driver was compiled with -DDEBUG. Otherwise, the call turns into a NOP.
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci#define ntfs_debug(f, a...)						\
3162306a36Sopenharmony_ci	__ntfs_debug(__FILE__, __LINE__, __func__, f, ##a)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciextern void ntfs_debug_dump_runlist(const runlist_element *rl);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#else	/* !DEBUG */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define ntfs_debug(fmt, ...)						\
3862306a36Sopenharmony_cido {									\
3962306a36Sopenharmony_ci	if (0)								\
4062306a36Sopenharmony_ci		no_printk(fmt, ##__VA_ARGS__);				\
4162306a36Sopenharmony_ci} while (0)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define ntfs_debug_dump_runlist(rl)	do {} while (0)
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#endif	/* !DEBUG */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciextern  __printf(3, 4)
4862306a36Sopenharmony_civoid __ntfs_warning(const char *function, const struct super_block *sb,
4962306a36Sopenharmony_ci		    const char *fmt, ...);
5062306a36Sopenharmony_ci#define ntfs_warning(sb, f, a...)	__ntfs_warning(__func__, sb, f, ##a)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciextern  __printf(3, 4)
5362306a36Sopenharmony_civoid __ntfs_error(const char *function, const struct super_block *sb,
5462306a36Sopenharmony_ci		  const char *fmt, ...);
5562306a36Sopenharmony_ci#define ntfs_error(sb, f, a...)		__ntfs_error(__func__, sb, f, ##a)
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#endif /* _LINUX_NTFS_DEBUG_H */
58