1 /* $NetBSD: debug.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */
4 * Copyright (c) 2010 Department of Software Engineering,
5 * University of Szeged, Hungary
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by the Department of Software Engineering, University of Szeged, Hungary
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * XipFFS -- Xip Flash File System
36 * Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>,
37 * Zoltan Sogor <weth@inf.u-szeged.hu>,
39 * University of Szeged, Hungary
42 * For licensing information, see the file 'LICENCE' in this directory.
46 #ifndef __CHFS_DEBUG_H__
47 #define __CHFS_DEBUG_H__
49 #define CHFS_ERROR_PREFIX "[CHFS ERROR]"
50 #define CHFS_WARNING_PREFIX "[CHFS WARNING]"
51 #define CHFS_NOTICE_PREFIX "[CHFS NOTICE]"
52 #define CHFS_DBG_PREFIX "[CHFS DBG]"
53 #define CHFS_DBG2_PREFIX "[CHFS DBG2]"
54 #define CHFS_DBG_EBH_PREFIX "[CHFS DBG EBH]"
55 #define CHFS_DBG_GC_PREFIX "[CHFS_GC DBG]"
57 #define unlikely(x) __builtin_expect ((x), 0)
61 #define debug_msg(pref, fmt, ...) \
64 " %s: " fmt, __FUNCTION__ , ##__VA_ARGS__); \
67 #define chfs_assert(expr) do { \
68 if (unlikely(!(expr))) { \
69 printf("CHFS assert failed in %s at %u\n", \
70 __func__, __LINE__); \
76 #define chfs_err(fmt, ...) debug_msg(CHFS_ERROR_PREFIX, fmt, ##__VA_ARGS__)
77 #define chfs_warn(fmt, ...) debug_msg(CHFS_WARNING_PREFIX, fmt, ##__VA_ARGS__)
78 #define chfs_noti(fmt, ...) debug_msg(CHFS_NOTICE_PREFIX, fmt, ##__VA_ARGS__)
79 #define dbg(fmt, ...) debug_msg(CHFS_DBG_PREFIX, fmt, ##__VA_ARGS__)
80 #define dbg2(fmt, ...) debug_msg(CHFS_DBG2_PREFIX(fmt, ##__VA_ARGS__)
81 #define dbg_ebh(fmt, ...) debug_msg(CHFS_DBG_EBH_PREFIX, fmt, ##__VA_ARGS__)
83 #define chfs_err(fmt, ...) debug_msg(CHFS_ERROR_PREFIX, fmt, ##__VA_ARGS__)
84 #define chfs_warn(fmt, ...) debug_msg(CHFS_WARNING_PREFIX, fmt, ##__VA_ARGS__)
85 #define chfs_noti(fmt, ...) debug_msg(CHFS_NOTICE_PREFIX, fmt, ##__VA_ARGS__)
87 #define dbg2(fmt, ...)
88 #define dbg_ebh(fmt, ...)
92 #define dbg_gc(fmt, ...) debug_msg(CHFS_DBG_GC_PREFIX, fmt, ##__VA_ARGS__)
94 #define dbg_gc(fmt, ...)
97 #endif /* __CHFS_DEBUG_H__ */