libparted 3.6
Loading...
Searching...
No Matches
debug.in.h
Go to the documentation of this file.
1/*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 1998-2000, 2002, 2007, 2009-2014, 2019-2023 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef PED_DEBUG_H_INCLUDED
21#define PED_DEBUG_H_INCLUDED
22
23#include <stdarg.h>
24
25#ifdef DEBUG
26
27typedef void (PedDebugHandler) ( const int level, const char* file, int line,
28 const char* function, const char* msg );
29
30extern void ped_debug_set_handler (PedDebugHandler* handler);
31extern void ped_debug ( const int level, const char* file, int line,
32 const char* function, const char* msg, ... );
33
34extern void __attribute__((__noreturn__))
35ped_assert ( const char* cond_text,
36 const char* file, int line, const char* function );
37
38#if defined __GNUC__ && !defined __JSFTRACE__
39
40#define PED_DEBUG(level, ...) \
41 ped_debug ( level, __FILE__, __LINE__, __PRETTY_FUNCTION__, \
42 __VA_ARGS__ )
43
44#define PED_ASSERT(cond) \
45 do { \
46 if (!(cond)) { \
47 ped_assert ( \
48 #cond, \
49 __FILE__, \
50 __LINE__, \
51 __PRETTY_FUNCTION__ ); \
52 } \
53 } while (0)
54
55#else /* !__GNUC__ */
56
57/* function because variadic macros are C99 */
58static void PED_DEBUG (int level, ...)
59{
60 va_list va_args;
61
62 va_start (va_args, level);
63 ped_debug ( level, "unknown file", 0, "unknown function", va_args );
64 va_end (va_args);
65}
66
67#define PED_ASSERT(cond) \
68 do { \
69 if (!(cond)) { \
70 ped_assert ( \
71 #cond, \
72 "unknown", \
73 0, \
74 "unknown"); \
75 } \
76 } while (0)
77
78#endif /* __GNUC__ */
79
80#else /* !DEBUG */
81
82#define PED_ASSERT(cond) do {} while (0)
83#define PED_DEBUG(level, ...) do {} while (0)
84
85
86#endif /* DEBUG */
87
88#endif /* PED_DEBUG_H_INCLUDED */
typedef __attribute__
Definition: vtoc.h:80
#define PED_DEBUG(level,...)
Definition: debug.in.h:83