ext4: Remove redundant unlikely()
[zen-stable.git] / include / linux / drbd_tag_magic.h
blobfcdff8410e99ddad7f1dac756bd915aefce5c494
1 #ifndef DRBD_TAG_MAGIC_H
2 #define DRBD_TAG_MAGIC_H
4 #define TT_END 0
5 #define TT_REMOVED 0xE000
7 /* declare packet_type enums */
8 enum packet_types {
9 #define NL_PACKET(name, number, fields) P_ ## name = number,
10 #define NL_INTEGER(pn, pr, member)
11 #define NL_INT64(pn, pr, member)
12 #define NL_BIT(pn, pr, member)
13 #define NL_STRING(pn, pr, member, len)
14 #include "drbd_nl.h"
15 P_nl_after_last_packet,
18 /* These struct are used to deduce the size of the tag lists: */
19 #define NL_PACKET(name, number, fields) \
20 struct name ## _tag_len_struct { fields };
21 #define NL_INTEGER(pn, pr, member) \
22 int member; int tag_and_len ## member;
23 #define NL_INT64(pn, pr, member) \
24 __u64 member; int tag_and_len ## member;
25 #define NL_BIT(pn, pr, member) \
26 unsigned char member:1; int tag_and_len ## member;
27 #define NL_STRING(pn, pr, member, len) \
28 unsigned char member[len]; int member ## _len; \
29 int tag_and_len ## member;
30 #include "linux/drbd_nl.h"
32 /* declate tag-list-sizes */
33 static const int tag_list_sizes[] = {
34 #define NL_PACKET(name, number, fields) 2 fields ,
35 #define NL_INTEGER(pn, pr, member) + 4 + 4
36 #define NL_INT64(pn, pr, member) + 4 + 8
37 #define NL_BIT(pn, pr, member) + 4 + 1
38 #define NL_STRING(pn, pr, member, len) + 4 + (len)
39 #include "drbd_nl.h"
42 /* The two highest bits are used for the tag type */
43 #define TT_MASK 0xC000
44 #define TT_INTEGER 0x0000
45 #define TT_INT64 0x4000
46 #define TT_BIT 0x8000
47 #define TT_STRING 0xC000
48 /* The next bit indicates if processing of the tag is mandatory */
49 #define T_MANDATORY 0x2000
50 #define T_MAY_IGNORE 0x0000
51 #define TN_MASK 0x1fff
52 /* The remaining 13 bits are used to enumerate the tags */
54 #define tag_type(T) ((T) & TT_MASK)
55 #define tag_number(T) ((T) & TN_MASK)
57 /* declare tag enums */
58 #define NL_PACKET(name, number, fields) fields
59 enum drbd_tags {
60 #define NL_INTEGER(pn, pr, member) T_ ## member = pn | TT_INTEGER | pr ,
61 #define NL_INT64(pn, pr, member) T_ ## member = pn | TT_INT64 | pr ,
62 #define NL_BIT(pn, pr, member) T_ ## member = pn | TT_BIT | pr ,
63 #define NL_STRING(pn, pr, member, len) T_ ## member = pn | TT_STRING | pr ,
64 #include "drbd_nl.h"
67 struct tag {
68 const char *name;
69 int type_n_flags;
70 int max_len;
73 /* declare tag names */
74 #define NL_PACKET(name, number, fields) fields
75 static const struct tag tag_descriptions[] = {
76 #define NL_INTEGER(pn, pr, member) [ pn ] = { #member, TT_INTEGER | pr, sizeof(int) },
77 #define NL_INT64(pn, pr, member) [ pn ] = { #member, TT_INT64 | pr, sizeof(__u64) },
78 #define NL_BIT(pn, pr, member) [ pn ] = { #member, TT_BIT | pr, sizeof(int) },
79 #define NL_STRING(pn, pr, member, len) [ pn ] = { #member, TT_STRING | pr, (len) },
80 #include "drbd_nl.h"
83 #endif