updated licence header
[profile/ivi/message-port.git] / daemon / utils.h
1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4  * This file is part of message-port.
5  *
6  * Copyright (C) 2013 Intel Corporation.
7  *
8  * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
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, but
16  * 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
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23  * 02110-1301 USA
24  */
25
26 #ifndef __MSGPORT_UTILS_H
27 #define __MSGPORT_UTILS_H
28
29 #include <glib.h>
30 #include "utils.h"
31
32 #define msgport_return_if_fail(expr)      g_return_if_fail (expr)
33 #define msgport_return_if_fail_with_error(expr, err) \
34 do {\
35     if (G_LIKELY (expr)) { }\
36     else \
37         g_return_if_fail_warning (G_LOG_DOMAIN,__PRETTY_FUNCTION__, ##expr);\
38         if (err) *err = msgport_error_new (MSGPORT_ERROR_INVALID_PARAMS, "assert("#expr")"); \
39         return; \
40     }\
41 } while(0);
42
43 #define msgport_return_val_if_fail(expr, ret)     g_return_val_if_fail (expr, ret)
44 #define msgport_return_val_if_fail_with_error(expr, ret, err) \
45 do {\
46     if (G_LIKELY(expr)) { } \
47     else {\
48         g_return_if_fail_warning (G_LOG_DOMAIN,__PRETTY_FUNCTION__, #expr);\
49         if (err) *err = msgport_error_new (MSGPORT_ERROR_INVALID_PARAMS, "assert("#expr")"); \
50         return ret; \
51     }\
52 } while (0);
53
54 #endif /* __MSGPORT_UTILS_H */