1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2005 Cluster File Systems, Inc. All rights reserved.
5 * Author: PJ Kirner <pjkirner@clusterfs.com>
7 * This file is part of the Lustre file system, http://www.lustre.org
8 * Lustre is a trademark of Cluster File Systems, Inc.
10 * This file is confidential source code owned by Cluster File Systems.
11 * No viewing, modification, compilation, redistribution, or any other
12 * form of use is permitted except through a signed license agreement.
14 * If you have not signed such an agreement, then you have no rights to
15 * this file. Please destroy it immediately and contact CFS.
20 #include <sys/types.h>
25 #include <lnet/api-support.h>
27 /* This ghastly hack to allows me to include lib-types.h It doesn't affect any
28 * assertions generated here (but fails-safe if it ever does) */
33 #include <lnet/lib-types.h>
34 #include <lnet/ptllnd_wire.h>
37 #define strnlen(s, i) strlen(s)
40 #define BLANK_LINE() \
47 printf (" /* "c" */\n"); \
51 #define STRINGIFY(a) #a
53 #define CHECK_DEFINE(a) \
55 printf (" CLASSERT ("#a" == "STRINGIFY(a)");\n"); \
58 #define CHECK_VALUE(a) \
60 printf (" CLASSERT ("#a" == %d);\n", a); \
63 #define CHECK_MEMBER_OFFSET(s,m) \
65 CHECK_VALUE((int)offsetof(s, m)); \
68 #define CHECK_MEMBER_SIZEOF(s,m) \
70 CHECK_VALUE((int)sizeof(((s *)0)->m)); \
73 #define CHECK_MEMBER(s,m) \
75 CHECK_MEMBER_OFFSET(s, m); \
76 CHECK_MEMBER_SIZEOF(s, m); \
79 #define CHECK_STRUCT(s) \
82 COMMENT ("Checks for struct "#s); \
83 CHECK_VALUE((int)sizeof(s)); \
87 system_string (char *cmdline, char *str, int len)
100 int fd = fileno(stdout);
102 rc = dup2(fds[1], fd);
106 exit(system(cmdline));
108 } else if ((int)pid < 0) {
111 FILE *f = fdopen (fds[0], "r");
118 if (fgets(str, len, f) == NULL)
121 if (waitpid(pid, &rc, 0) != pid)
124 if (!WIFEXITED(rc) ||
125 WEXITSTATUS(rc) != 0)
128 if (strnlen(str, len) == len)
131 if (str[strlen(str) - 1] == '\n')
132 str[strlen(str) - 1] = 0;
139 main (int argc, char **argv)
144 system_string("uname -a", unameinfo, sizeof(unameinfo));
145 system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
147 printf ("void kptllnd_assert_wire_constants (void)\n"
149 " /* Wire protocol assertions generated by 'wirecheck'\n"
152 "\n", unameinfo, gccinfo);
156 COMMENT ("Constants...");
157 CHECK_DEFINE (PTL_RESERVED_MATCHBITS);
158 CHECK_DEFINE (LNET_MSG_MATCHBITS);
160 CHECK_DEFINE (PTLLND_MSG_MAGIC);
161 CHECK_DEFINE (PTLLND_MSG_VERSION);
163 CHECK_DEFINE (PTLLND_RDMA_OK);
164 CHECK_DEFINE (PTLLND_RDMA_FAIL);
166 CHECK_DEFINE (PTLLND_MSG_TYPE_INVALID);
167 CHECK_DEFINE (PTLLND_MSG_TYPE_PUT);
168 CHECK_DEFINE (PTLLND_MSG_TYPE_GET);
169 CHECK_DEFINE (PTLLND_MSG_TYPE_IMMEDIATE);
170 CHECK_DEFINE (PTLLND_MSG_TYPE_NOOP);
171 CHECK_DEFINE (PTLLND_MSG_TYPE_HELLO);
172 CHECK_DEFINE (PTLLND_MSG_TYPE_NAK);
174 CHECK_STRUCT (kptl_msg_t);
175 CHECK_MEMBER (kptl_msg_t, ptlm_magic);
176 CHECK_MEMBER (kptl_msg_t, ptlm_version);
177 CHECK_MEMBER (kptl_msg_t, ptlm_type);
178 CHECK_MEMBER (kptl_msg_t, ptlm_credits);
179 CHECK_MEMBER (kptl_msg_t, ptlm_nob);
180 CHECK_MEMBER (kptl_msg_t, ptlm_cksum);
181 CHECK_MEMBER (kptl_msg_t, ptlm_srcnid);
182 CHECK_MEMBER (kptl_msg_t, ptlm_srcstamp);
183 CHECK_MEMBER (kptl_msg_t, ptlm_dstnid);
184 CHECK_MEMBER (kptl_msg_t, ptlm_dststamp);
185 CHECK_MEMBER (kptl_msg_t, ptlm_srcpid);
186 CHECK_MEMBER (kptl_msg_t, ptlm_dstpid);
187 CHECK_MEMBER (kptl_msg_t, ptlm_u.immediate);
188 CHECK_MEMBER (kptl_msg_t, ptlm_u.rdma);
189 CHECK_MEMBER (kptl_msg_t, ptlm_u.hello);
191 CHECK_STRUCT (kptl_immediate_msg_t);
192 CHECK_MEMBER (kptl_immediate_msg_t, kptlim_hdr);
193 CHECK_MEMBER (kptl_immediate_msg_t, kptlim_payload[13]);
195 CHECK_STRUCT (kptl_rdma_msg_t);
196 CHECK_MEMBER (kptl_rdma_msg_t, kptlrm_hdr);
197 CHECK_MEMBER (kptl_rdma_msg_t, kptlrm_matchbits);
199 CHECK_STRUCT (kptl_hello_msg_t);
200 CHECK_MEMBER (kptl_hello_msg_t, kptlhm_matchbits);
201 CHECK_MEMBER (kptl_hello_msg_t, kptlhm_max_msg_size);