1 /* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License, version 2.0,
5    as published by the Free Software Foundation.
6 
7    This program is also distributed with certain software (including
8    but not limited to OpenSSL) that is licensed under separate terms,
9    as designated in a particular file or component or in included license
10    documentation.  The authors of MySQL hereby grant you an additional
11    permission to link the program and your derivative works with the
12    separately licensed software that they have included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22 
23 #ifndef PAX_MSG_H
24 #define PAX_MSG_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 
31 #if 0
32 #define PAX_MSG_SANITY_CHECK(p) {                       \
33     if((p) && !(p)->a && (p)->msg_type == normal){      \
34       assert((p)->op != client_msg);                    \
35       assert((p)->op != ack_prepare_op);                \
36       assert((p)->op != accept_op);                     \
37       assert((p)->op != learn_op);                      \
38     }                                                   \
39   }
40 #else
41 #define PAX_MSG_SANITY_CHECK(p)
42 #endif
43 
44 #define CLONE_PAX_MSG(target, msg) replace_pax_msg((&target), clone_pax_msg_no_app(msg))
45 
46 int	eq_ballot(ballot x, ballot y);
47 int	gt_ballot(ballot x, ballot y);
48 int	ref_msg(pax_msg *p);
49 int	unref_msg(pax_msg **pp);
50 pax_msg *clone_pax_msg_no_app(pax_msg *msg);
51 pax_msg *clone_pax_msg(pax_msg *msg);
52 ballot *init_ballot(ballot *bal, int cnt, node_no node);
53 pax_msg *pax_msg_new(synode_no synode, site_def const *site);
54 pax_msg *pax_msg_new_0(synode_no synode);
55 void dbg_ballot(ballot const *p, char *s);
56 char *dbg_pax_msg(pax_msg const *p);
57 void delete_pax_msg(pax_msg *p);
58 /* void replace_pax_msg(pax_msg **target, pax_msg *p); */
59 void unchecked_replace_pax_msg(pax_msg **target, pax_msg *p);
60 
61 #define replace_pax_msg(target, p) { PAX_MSG_SANITY_CHECK(p); unchecked_replace_pax_msg(target, p);}
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif
68 
69