Consistently use conts to avoid duplicate error handling code in copy op.
[barrelfish] / usr / monitor / capops / internal.h
1 /*
2  * Copyright (c) 2012 ETH Zurich.
3  * All rights reserved.
4  *
5  * This file is distributed under the terms in the attached LICENSE file.
6  * If you do not find this file, copies can be found by writing to:
7  * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8  */
9
10 #ifndef CAPOPS_INTERNAL_H
11 #define CAPOPS_INTERNAL_H
12
13 #define malloce(size, ret) \
14     (*(ret) = malloc(size), \
15      *(ret) ? SYS_ERR_OK : LIB_ERR_MALLOC_FAIL)
16
17 #define calloce(n, size, ret) \
18     (*(ret) = calloc(n, size), \
19      *(ret) ? SYS_ERR_OK : LIB_ERR_MALLOC_FAIL)
20
21 #define GOTO_IF_ERR(err, label) do { \
22     if (err_is_fail(err)) { \
23         goto label; \
24     } \
25 } while (0)
26
27 #define PANIC_IF_ERR(err, msg) do { \
28     errval_t tmp_err__ = (err); \
29     if (err_is_fail(tmp_err__)) { \
30         USER_PANIC_ERR(tmp_err__, (msg)); \
31     } \
32 } while (0)
33
34 #define PANIC_IF_ERR2(err2, msg2, err, msg) do { \
35     errval_t tmp_err2__ = (err2); \
36     if (err_is_fail(tmp_err2__)) { \
37         DEBUG_ERR((err), (msg)); \
38         USER_PANIC_ERR(tmp_err2__, (msg2)); \
39     } \
40 } while (0)
41
42 #define DEBUG_IF_ERR(err, msg) do { \
43     errval_t tmp_err__ = (err); \
44     if (err_is_fail(tmp_err__)) { \
45         DEBUG_ERR(tmp_err__, (msg)); \
46     } \
47 } while (0)
48
49 void find_cap__rx_handler(struct intermon_binding *b, intermon_caprep_t caprep,
50                           genvaddr_t st);
51 void find_cap_result__rx_handler(struct intermon_binding *b, errval_t result,
52                                  genvaddr_t st);
53 void find_descendants__rx_handler(struct intermon_binding *b,
54                                   intermon_caprep_t caprep, genvaddr_t st);
55 void find_descendants_result__rx_handler(struct intermon_binding *b,
56                                          errval_t status, genvaddr_t st);
57 void owner_updated__rx_handler(struct intermon_binding *b, genvaddr_t st);
58 void update_owner__rx_handler(struct intermon_binding *b,
59                               intermon_caprep_t caprep, genvaddr_t st);
60 void recv_copy_result__rx(struct intermon_binding *b, errval_t status,
61                           capaddr_t capaddr, uint8_t vbits, cslot_t slot,
62                           genvaddr_t st);
63 void recv_copy__rx(struct intermon_binding *b, intermon_caprep_t caprep,
64                    uint8_t owner_relations, genvaddr_t st);
65 void request_copy__rx(struct intermon_binding *b, coreid_t dest,
66                       intermon_caprep_t caprep, genvaddr_t st);
67 void delete_remote__rx_handler(struct intermon_binding *b,
68                                intermon_caprep_t caprep, genvaddr_t st);
69 void delete_remote_result__rx_handler(struct intermon_binding *b,
70                                       errval_t status, genvaddr_t st);
71 void move_request__rx_handler(struct intermon_binding *b,
72                               intermon_caprep_t caprep, uint8_t relations,
73                               genvaddr_t st);
74 void move_result__rx_handler(struct intermon_binding *b, errval_t status,
75                              genvaddr_t st);
76 void request_retype__rx_handler(struct intermon_binding *b,
77                                 intermon_caprep_t srcrep, int desttype,
78                                 uint32_t destbits, genvaddr_t st);
79 void retype_response__rx_handler(struct intermon_binding *b, errval_t status,
80                                  genvaddr_t st);
81 void request_revoke__rx_handler(struct intermon_binding *b,
82                                 intermon_caprep_t caprep, genvaddr_t st);
83 void revoke_result__rx_handler(struct intermon_binding *b, errval_t status,
84                                genvaddr_t st);
85
86 #endif