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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/klnds/ptllnd/wirecheck.c
36 * Author: PJ Kirner <pjkirner@clusterfs.com>
40 #include <sys/types.h>
45 #include <lnet/api-support.h>
47 /* This ghastly hack to allows me to include lib-types.h It doesn't affect any
48 * assertions generated here (but fails-safe if it ever does) */
53 #include <lnet/lib-types.h>
54 #include <lnet/ptllnd_wire.h>
57 #define strnlen(s, i) strlen(s)
60 #define BLANK_LINE() \
67 printf (" /* "c" */\n"); \
71 #define STRINGIFY(a) #a
73 #define CHECK_DEFINE(a) \
75 printf (" CLASSERT ("#a" == "STRINGIFY(a)");\n"); \
78 #define CHECK_VALUE(a) \
80 printf (" CLASSERT ("#a" == %d);\n", a); \
83 #define CHECK_MEMBER_OFFSET(s,m) \
85 CHECK_VALUE((int)offsetof(s, m)); \
88 #define CHECK_MEMBER_SIZEOF(s,m) \
90 CHECK_VALUE((int)sizeof(((s *)0)->m)); \
93 #define CHECK_MEMBER(s,m) \
95 CHECK_MEMBER_OFFSET(s, m); \
96 CHECK_MEMBER_SIZEOF(s, m); \
99 #define CHECK_STRUCT(s) \
102 COMMENT ("Checks for struct "#s); \
103 CHECK_VALUE((int)sizeof(s)); \
107 system_string (char *cmdline, char *str, int len)
120 int fd = fileno(stdout);
122 rc = dup2(fds[1], fd);
126 exit(system(cmdline));
128 } else if ((int)pid < 0) {
131 FILE *f = fdopen (fds[0], "r");
138 if (fgets(str, len, f) == NULL)
141 if (waitpid(pid, &rc, 0) != pid)
144 if (!WIFEXITED(rc) ||
145 WEXITSTATUS(rc) != 0)
148 if (strnlen(str, len) == len)
151 if (str[strlen(str) - 1] == '\n')
152 str[strlen(str) - 1] = 0;
159 main (int argc, char **argv)
164 system_string("uname -a", unameinfo, sizeof(unameinfo));
165 system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
167 printf ("void kptllnd_assert_wire_constants (void)\n"
169 " /* Wire protocol assertions generated by 'wirecheck'\n"
172 "\n", unameinfo, gccinfo);
176 COMMENT ("Constants...");
177 CHECK_DEFINE (PTL_RESERVED_MATCHBITS);
178 CHECK_DEFINE (LNET_MSG_MATCHBITS);
180 CHECK_DEFINE (PTLLND_MSG_MAGIC);
181 CHECK_DEFINE (PTLLND_MSG_VERSION);
183 CHECK_DEFINE (PTLLND_RDMA_OK);
184 CHECK_DEFINE (PTLLND_RDMA_FAIL);
186 CHECK_DEFINE (PTLLND_MSG_TYPE_INVALID);
187 CHECK_DEFINE (PTLLND_MSG_TYPE_PUT);
188 CHECK_DEFINE (PTLLND_MSG_TYPE_GET);
189 CHECK_DEFINE (PTLLND_MSG_TYPE_IMMEDIATE);
190 CHECK_DEFINE (PTLLND_MSG_TYPE_NOOP);
191 CHECK_DEFINE (PTLLND_MSG_TYPE_HELLO);
192 CHECK_DEFINE (PTLLND_MSG_TYPE_NAK);
194 CHECK_STRUCT (kptl_msg_t);
195 CHECK_MEMBER (kptl_msg_t, ptlm_magic);
196 CHECK_MEMBER (kptl_msg_t, ptlm_version);
197 CHECK_MEMBER (kptl_msg_t, ptlm_type);
198 CHECK_MEMBER (kptl_msg_t, ptlm_credits);
199 CHECK_MEMBER (kptl_msg_t, ptlm_nob);
200 CHECK_MEMBER (kptl_msg_t, ptlm_cksum);
201 CHECK_MEMBER (kptl_msg_t, ptlm_srcnid);
202 CHECK_MEMBER (kptl_msg_t, ptlm_srcstamp);
203 CHECK_MEMBER (kptl_msg_t, ptlm_dstnid);
204 CHECK_MEMBER (kptl_msg_t, ptlm_dststamp);
205 CHECK_MEMBER (kptl_msg_t, ptlm_srcpid);
206 CHECK_MEMBER (kptl_msg_t, ptlm_dstpid);
207 CHECK_MEMBER (kptl_msg_t, ptlm_u.immediate);
208 CHECK_MEMBER (kptl_msg_t, ptlm_u.rdma);
209 CHECK_MEMBER (kptl_msg_t, ptlm_u.hello);
211 CHECK_STRUCT (kptl_immediate_msg_t);
212 CHECK_MEMBER (kptl_immediate_msg_t, kptlim_hdr);
213 CHECK_MEMBER (kptl_immediate_msg_t, kptlim_payload[13]);
215 CHECK_STRUCT (kptl_rdma_msg_t);
216 CHECK_MEMBER (kptl_rdma_msg_t, kptlrm_hdr);
217 CHECK_MEMBER (kptl_rdma_msg_t, kptlrm_matchbits);
219 CHECK_STRUCT (kptl_hello_msg_t);
220 CHECK_MEMBER (kptl_hello_msg_t, kptlhm_matchbits);
221 CHECK_MEMBER (kptl_hello_msg_t, kptlhm_max_msg_size);