2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Some convenience macros for firmnet.c
23 * @author Christian Wuerdig, implementation copied from liblpp created by Sebastian Hack
28 #ifndef FIRM_NET_FIRMNET_T_H
29 #define FIRM_NET_FIRMNET_T_H
33 #define BASIC_ERR_CHECK(expr,op,cond,fmt,last) \
36 if((res = (expr)) op cond) { \
37 fprintf(stderr, "%s(%d): %d = %s(%d): ", \
38 __FILE__, __LINE__, res, #expr, cond); \
40 fprintf(stderr, "\n"); \
45 #define BASIC_ERRNO_CHECK(expr,op,cond,last) \
47 int _basic_errno_check_res = (expr); \
48 if(_basic_errno_check_res op cond) { \
49 fprintf(stderr, "%s(%d): %d = %s(%d): %s\n", \
50 __FILE__, __LINE__, _basic_errno_check_res, #expr, cond, strerror(errno)); \
55 #define ERR_CHECK_RETURN(expr, op, cond, fmt, retval) \
56 BASIC_ERR_CHECK(expr, op, cond, fmt, return retval)
58 #define ERRNO_CHECK_RETURN(expr, op, cond, retval) \
59 BASIC_ERRNO_CHECK(expr, op, cond, return retval)
61 #define ERR_CHECK_RETURN_VOID(expr, op, cond, fmt) \
62 BASIC_ERR_CHECK(expr, op, cond, fmt, return)
64 #define ERRNO_CHECK_RETURN_VOID(expr, op, cond) \
65 BASIC_ERRNO_CHECK(expr, op, cond, return)
67 #define ERR_CHECK(expr, op, cond, fmt) \
68 BASIC_ERR_CHECK(expr, op, cond, fmt, (void) 0)
70 #define ERRNO_CHECK(expr, op, cond) \
71 BASIC_ERRNO_CHECK(expr, op, cond, (void) 0)