• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  libzvbi -- Useful macros
3  *
4  *  Copyright (C) 2002, 2003, 2004, 2007 Michael H. Schimek
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Library General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2 of the License, or (at your option) any later version.
10  *
11  *  This library 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 GNU
14  *  Library General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Library General Public
17  *  License along with this library; if not, write to the
18  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA  02110-1301  USA.
20  */
21 
22 /* $Id: macros.h,v 1.12 2013-07-10 23:11:18 mschimek Exp $ */
23 
24 #ifndef __ZVBI_MACROS_H__
25 #define __ZVBI_MACROS_H__
26 
27 #ifdef __cplusplus
28 #  define VBI_BEGIN_DECLS extern "C" {
29 #  define VBI_END_DECLS }
30 #else
31 #  define VBI_BEGIN_DECLS
32 #  define VBI_END_DECLS
33 #endif
34 
35 VBI_BEGIN_DECLS
36 
37 /* Public */
38 
39 #if __GNUC__ >= 4
40 #  define _vbi_sentinel __attribute__ ((__sentinel__(0)))
41 #  define _vbi_deprecated __attribute__ ((__deprecated__))
42 #else
43 #  define _vbi_sentinel
44 #  define _vbi_deprecated
45 #  define __restrict__
46 #endif
47 
48 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4
49 #  define _vbi_nonnull(params) __attribute__ ((__nonnull__ params))
50 #  define _vbi_format(params) __attribute__ ((__format__ params))
51 #else
52 #  define _vbi_nonnull(params)
53 #  define _vbi_format(params)
54 #endif
55 
56 #if __GNUC__ >= 3
57 #  define _vbi_pure __attribute__ ((__pure__))
58 #  define _vbi_alloc __attribute__ ((__malloc__))
59 #else
60 #  define _vbi_pure
61 #  define _vbi_alloc
62 #endif
63 
64 #if __GNUC__ >= 2
65 #  define _vbi_unused __attribute__ ((__unused__))
66 #  define _vbi_const __attribute__ ((__const__))
67 #  define _vbi_inline static __inline__
68 #else
69 #  define _vbi_unused
70 #  define _vbi_const
71 #  define _vbi_inline static
72 #endif
73 
74 /**
75  * @ingroup Basic
76  * @name Boolean type
77  * @{
78  */
79 #ifndef TRUE
80 #  define TRUE 1
81 #endif
82 #ifndef FALSE
83 #  define FALSE 0
84 #endif
85 
86 typedef int vbi_bool;
87 /** @} */
88 
89 #ifndef NULL
90 #  ifdef __cplusplus
91 #    define NULL (0L)
92 #  else
93 #    define NULL ((void *) 0)
94 #  endif
95 #endif
96 
97 /* XXX Document me - for variadic funcs. */
98 #define VBI_END ((void *) 0)
99 
100 #if 0
101 typedef void
102 vbi_lock_fn			(void *			user_data);
103 typedef void
104 vbi_unlock_fn			(void *			user_data);
105 #endif
106 
107 /**
108  * @ingroup Basic
109  * @{
110  */
111 typedef enum {
112 	/** External error causes, for example lack of memory. */
113 	VBI_LOG_ERROR		= 1 << 3,
114 
115 	/**
116 	 * Invalid parameters and similar problems which suggest
117 	 * a bug in the application using the library.
118 	 */
119 	VBI_LOG_WARNING		= 1 << 4,
120 
121 	/**
122 	 * Causes of possibly undesired results, for example when a
123 	 * data service cannot be decoded with the current video
124 	 * standard setting.
125 	 */
126 	VBI_LOG_NOTICE		= 1 << 5,
127 
128 	/** Progress messages. */
129 	VBI_LOG_INFO		= 1 << 6,
130 
131 	/** Information useful to debug the library. */
132 	VBI_LOG_DEBUG		= 1 << 7,
133 
134 	/** Driver responses (strace). Not implemented yet. */
135 	VBI_LOG_DRIVER		= 1 << 8,
136 
137 	/** More detailed debugging information. */
138 	VBI_LOG_DEBUG2		= 1 << 9,
139 	VBI_LOG_DEBUG3		= 1 << 10
140 } vbi_log_mask;
141 
142 typedef void
143 vbi_log_fn			(vbi_log_mask		level,
144 				 const char *		context,
145 				 const char *		message,
146 				 void *			user_data);
147 
148 extern vbi_log_fn		vbi_log_on_stderr;
149 /** @} */
150 
151 /* Private */
152 
153 typedef struct {
154 	vbi_log_fn *		fn;
155 	void *			user_data;
156 	vbi_log_mask		mask;
157 } _vbi_log_hook;
158 
159 VBI_END_DECLS
160 
161 #endif /* __ZVBI_MACROS_H__ */
162 
163 /*
164 Local variables:
165 c-set-style: K&R
166 c-basic-offset: 8
167 End:
168 */
169