* vim:expandtab:shiftwidth=8:tabstop=8:
*/
#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <portals/api-support.h>
#include <portals/list.h>
#include <portals/lib-types.h>
+extern size_t strnlen(const char *, size_t);
+
#define BLANK_LINE() \
do { \
printf ("\n"); \
CHECK_MEMBER (ptl_hdr_t, dest_pid);
CHECK_MEMBER (ptl_hdr_t, src_pid);
CHECK_MEMBER (ptl_hdr_t, type);
-
+ CHECK_MEMBER (ptl_hdr_t, payload_length);
+ CHECK_MEMBER (ptl_hdr_t, msg);
+
BLANK_LINE ();
COMMENT ("Ack");
- CHECK_MEMBER (ptl_hdr_t, msg.ack.mlength);
CHECK_MEMBER (ptl_hdr_t, msg.ack.dst_wmd);
CHECK_MEMBER (ptl_hdr_t, msg.ack.match_bits);
- CHECK_MEMBER (ptl_hdr_t, msg.ack.length);
+ CHECK_MEMBER (ptl_hdr_t, msg.ack.mlength);
BLANK_LINE ();
COMMENT ("Put");
- CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index);
CHECK_MEMBER (ptl_hdr_t, msg.put.ack_wmd);
CHECK_MEMBER (ptl_hdr_t, msg.put.match_bits);
- CHECK_MEMBER (ptl_hdr_t, msg.put.length);
- CHECK_MEMBER (ptl_hdr_t, msg.put.offset);
CHECK_MEMBER (ptl_hdr_t, msg.put.hdr_data);
+ CHECK_MEMBER (ptl_hdr_t, msg.put.ptl_index);
+ CHECK_MEMBER (ptl_hdr_t, msg.put.offset);
BLANK_LINE ();
COMMENT ("Get");
- CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index);
CHECK_MEMBER (ptl_hdr_t, msg.get.return_wmd);
CHECK_MEMBER (ptl_hdr_t, msg.get.match_bits);
- CHECK_MEMBER (ptl_hdr_t, msg.get.length);
+ CHECK_MEMBER (ptl_hdr_t, msg.get.ptl_index);
CHECK_MEMBER (ptl_hdr_t, msg.get.src_offset);
- CHECK_MEMBER (ptl_hdr_t, msg.get.return_offset);
CHECK_MEMBER (ptl_hdr_t, msg.get.sink_length);
BLANK_LINE ();
COMMENT ("Reply");
CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_wmd);
- CHECK_MEMBER (ptl_hdr_t, msg.reply.dst_offset);
- CHECK_MEMBER (ptl_hdr_t, msg.reply.length);
+
+ BLANK_LINE ();
+ COMMENT ("Hello");
+ CHECK_MEMBER (ptl_hdr_t, msg.hello.incarnation);
+ CHECK_MEMBER (ptl_hdr_t, msg.hello.type);
+}
+
+void
+system_string (char *cmdline, char *str, int len)
+{
+ int fds[2];
+ int rc;
+ pid_t pid;
+
+ rc = pipe (fds);
+ if (rc != 0)
+ abort ();
+
+ pid = fork ();
+ if (pid == 0) {
+ /* child */
+ int fd = fileno(stdout);
+
+ rc = dup2(fds[1], fd);
+ if (rc != fd)
+ abort();
+
+ exit(system(cmdline));
+ /* notreached */
+ } else if ((int)pid < 0) {
+ abort();
+ } else {
+ FILE *f = fdopen (fds[0], "r");
+
+ if (f == NULL)
+ abort();
+
+ close(fds[1]);
+
+ if (fgets(str, len, f) == NULL)
+ abort();
+
+ if (waitpid(pid, &rc, 0) != pid)
+ abort();
+
+ if (!WIFEXITED(rc) ||
+ WEXITSTATUS(rc) != 0)
+ abort();
+
+ if (strnlen(str, len) == len)
+ str[len - 1] = 0;
+
+ if (str[strlen(str) - 1] == '\n')
+ str[strlen(str) - 1] = 0;
+
+ fclose(f);
+ }
}
int
main (int argc, char **argv)
{
+ char unameinfo[80];
+ char gccinfo[80];
+
+ system_string("uname -a", unameinfo, sizeof(unameinfo));
+ system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
+
printf ("void lib_assert_wire_constants (void)\n"
- "{\n");
-
- COMMENT ("Wire protocol assertions generated by 'wirecheck'");
+ "{\n"
+ " /* Wire protocol assertions generated by 'wirecheck'\n"
+ " * running on %s\n"
+ " * with %s */\n"
+ "\n", unameinfo, gccinfo);
+
BLANK_LINE ();
COMMENT ("Constants...");