- when a graph is lowered because of struct return changes, transform
[libfirm] / ir / net / firmnet_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Some convenience macros for firmnet.c
23  * @author  Christian Wuerdig, implementation copied from liblpp created by Sebastian Hack
24  * @date    17.11.2006
25  * @version $Id$
26  */
27
28 #ifndef FIRM_NET_FIRMNET_T_H
29 #define FIRM_NET_FIRMNET_T_H
30
31 #include "firmnet.h"
32
33 #define BASIC_ERR_CHECK(expr,op,cond,fmt,last) \
34 { \
35         int res; \
36         if((res = (expr)) op cond) { \
37         fprintf(stderr, "%s(%d): %d = %s(%d): ", \
38         __FILE__, __LINE__, res, #expr, cond); \
39         lpp_print_err fmt; \
40         fprintf(stderr, "\n"); \
41         last; \
42         } \
43 }
44
45 #define BASIC_ERRNO_CHECK(expr,op,cond,last) \
46 { \
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)); \
51         last; \
52         } \
53 }
54
55 #define ERR_CHECK_RETURN(expr, op, cond, fmt, retval) \
56         BASIC_ERR_CHECK(expr, op, cond, fmt, return retval)
57
58 #define ERRNO_CHECK_RETURN(expr, op, cond, retval) \
59         BASIC_ERRNO_CHECK(expr, op, cond, return retval)
60
61 #define ERR_CHECK_RETURN_VOID(expr, op, cond, fmt) \
62         BASIC_ERR_CHECK(expr, op, cond, fmt, return)
63
64 #define ERRNO_CHECK_RETURN_VOID(expr, op, cond) \
65         BASIC_ERRNO_CHECK(expr, op, cond, return)
66
67 #define ERR_CHECK(expr, op, cond, fmt) \
68         BASIC_ERR_CHECK(expr, op, cond, fmt, (void) 0)
69
70 #define ERRNO_CHECK(expr, op, cond) \
71         BASIC_ERRNO_CHECK(expr, op, cond, (void) 0)
72
73 #endif