4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
46 #include <sys/types.h>
48 #include <lnet/types.h>
51 #define strnlen(s, i) strlen(s)
54 #define BLANK_LINE() \
61 printf (" /* "c" */\n"); \
64 #define STRINGIFY(a) #a
66 #define CHECK_DEFINE(a) \
68 printf (" CLASSERT ("#a" == "STRINGIFY(a)");\n"); \
71 #define CHECK_VALUE(a) \
73 printf (" CLASSERT ("#a" == %d);\n", a); \
76 #define CHECK_MEMBER_OFFSET(s,m) \
78 CHECK_VALUE((int)offsetof(s, m)); \
81 #define CHECK_MEMBER_SIZEOF(s,m) \
83 CHECK_VALUE((int)sizeof(((s *)0)->m)); \
86 #define CHECK_MEMBER(s,m) \
88 CHECK_MEMBER_OFFSET(s, m); \
89 CHECK_MEMBER_SIZEOF(s, m); \
92 #define CHECK_STRUCT(s) \
95 COMMENT ("Checks for struct "#s); \
96 CHECK_VALUE((int)sizeof(s)); \
100 check_lnet_handle_wire (void)
102 CHECK_STRUCT (lnet_handle_wire_t);
103 CHECK_MEMBER (lnet_handle_wire_t, wh_interface_cookie);
104 CHECK_MEMBER (lnet_handle_wire_t, wh_object_cookie);
108 check_lnet_magicversion (void)
110 CHECK_STRUCT (lnet_magicversion_t);
111 CHECK_MEMBER (lnet_magicversion_t, magic);
112 CHECK_MEMBER (lnet_magicversion_t, version_major);
113 CHECK_MEMBER (lnet_magicversion_t, version_minor);
117 check_lnet_hdr (void)
119 CHECK_STRUCT (lnet_hdr_t);
120 CHECK_MEMBER (lnet_hdr_t, dest_nid);
121 CHECK_MEMBER (lnet_hdr_t, src_nid);
122 CHECK_MEMBER (lnet_hdr_t, dest_pid);
123 CHECK_MEMBER (lnet_hdr_t, src_pid);
124 CHECK_MEMBER (lnet_hdr_t, type);
125 CHECK_MEMBER (lnet_hdr_t, payload_length);
126 CHECK_MEMBER (lnet_hdr_t, msg);
130 CHECK_MEMBER (lnet_hdr_t, msg.ack.dst_wmd);
131 CHECK_MEMBER (lnet_hdr_t, msg.ack.match_bits);
132 CHECK_MEMBER (lnet_hdr_t, msg.ack.mlength);
136 CHECK_MEMBER (lnet_hdr_t, msg.put.ack_wmd);
137 CHECK_MEMBER (lnet_hdr_t, msg.put.match_bits);
138 CHECK_MEMBER (lnet_hdr_t, msg.put.hdr_data);
139 CHECK_MEMBER (lnet_hdr_t, msg.put.ptl_index);
140 CHECK_MEMBER (lnet_hdr_t, msg.put.offset);
144 CHECK_MEMBER (lnet_hdr_t, msg.get.return_wmd);
145 CHECK_MEMBER (lnet_hdr_t, msg.get.match_bits);
146 CHECK_MEMBER (lnet_hdr_t, msg.get.ptl_index);
147 CHECK_MEMBER (lnet_hdr_t, msg.get.src_offset);
148 CHECK_MEMBER (lnet_hdr_t, msg.get.sink_length);
152 CHECK_MEMBER (lnet_hdr_t, msg.reply.dst_wmd);
156 CHECK_MEMBER (lnet_hdr_t, msg.hello.incarnation);
157 CHECK_MEMBER (lnet_hdr_t, msg.hello.type);
161 system_string (char *cmdline, char *str, int len)
174 int fd = fileno(stdout);
176 rc = dup2(fds[1], fd);
180 exit(system(cmdline));
182 } else if ((int)pid < 0) {
185 FILE *f = fdopen (fds[0], "r");
192 if (fgets(str, len, f) == NULL)
195 if (waitpid(pid, &rc, 0) != pid)
198 if (!WIFEXITED(rc) ||
199 WEXITSTATUS(rc) != 0)
202 if (strnlen(str, len) == len)
205 if (str[strlen(str) - 1] == '\n')
206 str[strlen(str) - 1] = 0;
213 main (int argc, char **argv)
218 system_string("uname -a", unameinfo, sizeof(unameinfo));
219 system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
221 printf ("void lnet_assert_wire_constants (void)\n"
223 " /* Wire protocol assertions generated by 'wirecheck'\n"
226 "\n", unameinfo, gccinfo);
230 COMMENT ("Constants...");
232 CHECK_DEFINE (LNET_PROTO_RA_MAGIC);
234 CHECK_DEFINE (LNET_PROTO_TCP_MAGIC);
235 CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MAJOR);
236 CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MINOR);
238 CHECK_VALUE (LNET_MSG_ACK);
239 CHECK_VALUE (LNET_MSG_PUT);
240 CHECK_VALUE (LNET_MSG_GET);
241 CHECK_VALUE (LNET_MSG_REPLY);
242 CHECK_VALUE (LNET_MSG_HELLO);
244 check_lnet_handle_wire ();
245 check_lnet_magicversion ();