1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
7 #include <lnet/lib-lnet.h>
12 #define strnlen(s, i) strlen(s)
15 #define BLANK_LINE() \
22 printf (" /* "c" */\n"); \
25 #define STRINGIFY(a) #a
27 #define CHECK_DEFINE(a) \
29 printf (" CLASSERT ("#a" == "STRINGIFY(a)");\n"); \
32 #define CHECK_VALUE(a) \
34 printf (" CLASSERT ("#a" == %d);\n", a); \
37 #define CHECK_MEMBER_OFFSET(s,m) \
39 CHECK_VALUE((int)offsetof(s, m)); \
42 #define CHECK_MEMBER_SIZEOF(s,m) \
44 CHECK_VALUE((int)sizeof(((s *)0)->m)); \
47 #define CHECK_MEMBER(s,m) \
49 CHECK_MEMBER_OFFSET(s, m); \
50 CHECK_MEMBER_SIZEOF(s, m); \
53 #define CHECK_STRUCT(s) \
56 COMMENT ("Checks for struct "#s); \
57 CHECK_VALUE((int)sizeof(s)); \
61 check_lnet_handle_wire (void)
63 CHECK_STRUCT (lnet_handle_wire_t);
64 CHECK_MEMBER (lnet_handle_wire_t, wh_interface_cookie);
65 CHECK_MEMBER (lnet_handle_wire_t, wh_object_cookie);
69 check_lnet_magicversion (void)
71 CHECK_STRUCT (lnet_magicversion_t);
72 CHECK_MEMBER (lnet_magicversion_t, magic);
73 CHECK_MEMBER (lnet_magicversion_t, version_major);
74 CHECK_MEMBER (lnet_magicversion_t, version_minor);
80 CHECK_STRUCT (lnet_hdr_t);
81 CHECK_MEMBER (lnet_hdr_t, dest_nid);
82 CHECK_MEMBER (lnet_hdr_t, src_nid);
83 CHECK_MEMBER (lnet_hdr_t, dest_pid);
84 CHECK_MEMBER (lnet_hdr_t, src_pid);
85 CHECK_MEMBER (lnet_hdr_t, type);
86 CHECK_MEMBER (lnet_hdr_t, payload_length);
87 CHECK_MEMBER (lnet_hdr_t, msg);
91 CHECK_MEMBER (lnet_hdr_t, msg.ack.dst_wmd);
92 CHECK_MEMBER (lnet_hdr_t, msg.ack.match_bits);
93 CHECK_MEMBER (lnet_hdr_t, msg.ack.mlength);
97 CHECK_MEMBER (lnet_hdr_t, msg.put.ack_wmd);
98 CHECK_MEMBER (lnet_hdr_t, msg.put.match_bits);
99 CHECK_MEMBER (lnet_hdr_t, msg.put.hdr_data);
100 CHECK_MEMBER (lnet_hdr_t, msg.put.ptl_index);
101 CHECK_MEMBER (lnet_hdr_t, msg.put.offset);
105 CHECK_MEMBER (lnet_hdr_t, msg.get.return_wmd);
106 CHECK_MEMBER (lnet_hdr_t, msg.get.match_bits);
107 CHECK_MEMBER (lnet_hdr_t, msg.get.ptl_index);
108 CHECK_MEMBER (lnet_hdr_t, msg.get.src_offset);
109 CHECK_MEMBER (lnet_hdr_t, msg.get.sink_length);
113 CHECK_MEMBER (lnet_hdr_t, msg.reply.dst_wmd);
117 CHECK_MEMBER (lnet_hdr_t, msg.hello.incarnation);
118 CHECK_MEMBER (lnet_hdr_t, msg.hello.type);
122 system_string (char *cmdline, char *str, int len)
135 int fd = fileno(stdout);
137 rc = dup2(fds[1], fd);
141 exit(system(cmdline));
143 } else if ((int)pid < 0) {
146 FILE *f = fdopen (fds[0], "r");
153 if (fgets(str, len, f) == NULL)
156 if (waitpid(pid, &rc, 0) != pid)
159 if (!WIFEXITED(rc) ||
160 WEXITSTATUS(rc) != 0)
163 if (strnlen(str, len) == len)
166 if (str[strlen(str) - 1] == '\n')
167 str[strlen(str) - 1] = 0;
174 main (int argc, char **argv)
179 system_string("uname -a", unameinfo, sizeof(unameinfo));
180 system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
182 printf ("void lnet_assert_wire_constants (void)\n"
184 " /* Wire protocol assertions generated by 'wirecheck'\n"
187 "\n", unameinfo, gccinfo);
191 COMMENT ("Constants...");
193 CHECK_DEFINE (LNET_PROTO_OPENIB_MAGIC);
194 CHECK_DEFINE (LNET_PROTO_RA_MAGIC);
196 CHECK_DEFINE (LNET_PROTO_TCP_MAGIC);
197 CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MAJOR);
198 CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MINOR);
200 CHECK_VALUE (LNET_MSG_ACK);
201 CHECK_VALUE (LNET_MSG_PUT);
202 CHECK_VALUE (LNET_MSG_GET);
203 CHECK_VALUE (LNET_MSG_REPLY);
204 CHECK_VALUE (LNET_MSG_HELLO);
206 check_lnet_handle_wire ();
207 check_lnet_magicversion ();