1/* FriBidi
2 * debug.h - debug-only interfaces
3 *
4 * Author:
5 * Behdad Esfahbod, 2001, 2002, 2004
6 *
7 * Copyright (C) 2004 Sharif FarsiWeb, Inc.
8 * Copyright (C) 2001,2002 Behdad Esfahbod
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library, in a file named COPYING; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA
24 *
25 * For licensing issues, contact <fribidi.license@gmail.com>.
26 */
27#ifndef _DEBUG_H
28#define _DEBUG_H
29
30#include "common.h"
31
32#include <fribidi-types.h>
33
34#include <fribidi-begindecls.h>
35
36#ifdef DEBUG
37
38/* These definitions should only be used in DEBUG mode: */
39#ifndef __LINE__
40# define __LINE__ 0
41#endif /* !__LINE__ */
42#ifndef __FILE__
43# define __FILE__ "unknown"
44#endif /* !__FILE__ */
45
46#ifndef FRIBIDI_FPRINTF
47# ifndef __FRIBIDI_DOC
48# include <stdio.h>
49# endif /* !__FRIBIDI_DOC */
50# define FRIBIDI_FPRINTF fprintf
51# define FRIBIDI_STDERR_ stderr,
52#endif /* !FRIBIDI_FPRINTF */
53
54#ifndef MSG
55#define MSG(s) \
56 FRIBIDI_BEGIN_STMT \
57 FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s); \
58 FRIBIDI_END_STMT
59#define MSG2(s, t) \
60 FRIBIDI_BEGIN_STMT \
61 FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t); \
62 FRIBIDI_END_STMT
63#define MSG3(s, t, u) \
64 FRIBIDI_BEGIN_STMT \
65 FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t, u); \
66 FRIBIDI_END_STMT
67#define MSG5(s, t, u, v, w) \
68 FRIBIDI_BEGIN_STMT \
69 FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t, u, v, w); \
70 FRIBIDI_END_STMT
71#define MSG6(s, t, u, v, w, z) \
72 FRIBIDI_BEGIN_STMT \
73 FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t, u, v, w, z); \
74 FRIBIDI_END_STMT
75#endif /* !MSG */
76
77#ifndef DBG
78# define DBG(s) \
79 FRIBIDI_BEGIN_STMT \
80 if (fribidi_debug_status()) { MSG(FRIBIDI ": " s "\n"); } \
81 FRIBIDI_END_STMT
82# define DBG2(s, t) \
83 FRIBIDI_BEGIN_STMT \
84 if (fribidi_debug_status()) { MSG2(FRIBIDI ": " s "\n", t); } \
85 FRIBIDI_END_STMT
86#endif /* !DBG */
87
88#ifndef fribidi_assert
89# define fribidi_assert(cond) \
90 FRIBIDI_BEGIN_STMT \
91 if (!(cond)) { \
92 DBG(__FILE__ ":" STRINGIZE(__LINE__) ": " \
93 "assertion failed (" STRINGIZE(cond) ")"); \
94 } \
95 FRIBIDI_END_STMT
96#endif /* !fribidi_assert */
97
98#else /* !DEBUG */
99
100#ifndef DBG
101# define DBG(s) FRIBIDI_EMPTY_STMT
102# define DBG2(s, t) FRIBIDI_EMPTY_STMT
103#endif /* !DBG */
104#ifndef fribidi_assert
105# define fribidi_assert(cond) FRIBIDI_EMPTY_STMT
106#endif /* !fribidi_assert */
107
108#endif /* !DEBUG */
109
110#include <fribidi-enddecls.h>
111
112#endif /* !_DEBUG_H */
113/* Editor directions:
114 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
115 */
116

source code of gtk/subprojects/fribidi/lib/debug.h