[ofw] [ib-diag] sminfo: add support for WinOF
Sean Hefty
sean.hefty at intel.com
Thu Feb 12 23:21:21 PST 2009
Allow sminfo to build and run on both Linux and Windows. Window
build files are maintained in the WinOF respository. These changes
allow dropping the infiniband-diags into the WinOF build environment.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Would there be any objection to including the windows source files (.c and .h)
in the mgmt tree?
infiniband-diags/Makefile.am | 2 +
infiniband-diags/include/ibdiag_common.h | 2 +
infiniband-diags/include/linux/ibdiag_osd.h | 43 +++++++++++++++++++++++++++
infiniband-diags/src/ibdiag_common.c | 13 ++++----
infiniband-diags/src/sminfo.c | 15 ++++-----
5 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/infiniband-diags/Makefile.am b/infiniband-diags/Makefile.am
index f9cc5bd..0d32abd 100644
--- a/infiniband-diags/Makefile.am
+++ b/infiniband-diags/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(top_builddir)/include/ -I$(srcdir)/include -I$(includedir) -I$(includedir)/infiniband
+INCLUDES = -I$(top_builddir)/include/ -I$(srcdir)/include -I$(includedir) -I$(includedir)/infiniband -I$(srcdir)/include/linux
if DEBUG
DBGFLAGS = -ggdb -D_DEBUG_
diff --git a/infiniband-diags/include/ibdiag_common.h b/infiniband-diags/include/ibdiag_common.h
index 4783b8e..2dea873 100644
--- a/infiniband-diags/include/ibdiag_common.h
+++ b/infiniband-diags/include/ibdiag_common.h
@@ -52,7 +52,7 @@ extern int ibd_timeout;
#undef DEBUG
#define DEBUG if (ibdebug || ibverbose) IBWARN
#define VERBOSE if (ibdebug || ibverbose > 1) IBWARN
-#define IBERROR(fmt, args...) iberror(__FUNCTION__, fmt, ## args)
+#define IBERROR(fmt, ...) iberror(__FUNCTION__, fmt, ## __VA_ARGS__)
struct ibdiag_opt {
const char *name;
diff --git a/infiniband-diags/include/linux/ibdiag_osd.h b/infiniband-diags/include/linux/ibdiag_osd.h
new file mode 100644
index 0000000..5c6faa9
--- /dev/null
+++ b/infiniband-diags/include/linux/ibdiag_osd.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2009 Intel Corp, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBDIAG_OSD_H_
+#define _IBDIAG_OSD_H_
+
+#include <unistd.h>
+#include <inttypes.h>
+#include <config.h>
+
+#define CDECL
+
+#endif /* _IBDIAG_OSD_H_ */
diff --git a/infiniband-diags/src/ibdiag_common.c b/infiniband-diags/src/ibdiag_common.c
index bda1efa..154e00c 100644
--- a/infiniband-diags/src/ibdiag_common.c
+++ b/infiniband-diags/src/ibdiag_common.c
@@ -43,15 +43,14 @@
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
-#include <unistd.h>
#include <ctype.h>
-#include <config.h>
#include <getopt.h>
#include <infiniband/umad.h>
#include <infiniband/mad.h>
#include <ibdiag_common.h>
#include <ibdiag_version.h>
+#include "ibdiag_osd.h"
int ibdebug;
int ibverbose;
@@ -204,7 +203,7 @@ static const struct ibdiag_opt common_opts[] = {
{ "usage", 'u', 0, NULL, "usage message" },
{ "help", 'h', 0, NULL, "help message" },
{ "version", 'V', 0, NULL, "show version" },
- {}
+ { 0 }
};
static void make_opt(struct option *l, const struct ibdiag_opt *o,
@@ -254,11 +253,11 @@ static struct option *make_long_opts(const char *exclude_str,
static void make_str_opts(const struct option *o, char *p, unsigned size)
{
- int i, n = 0;
+ unsigned i, n = 0;
for (n = 0; o->name && n + 2 + o->has_arg < size; o++) {
- p[n++] = o->val;
- for (i = 0; i < o->has_arg; i++)
+ p[n++] = (char) o->val;
+ for (i = 0; i < (unsigned) o->has_arg; i++)
p[n++] = ':';
}
p[n] = '\0';
@@ -273,7 +272,7 @@ int ibdiag_process_opts(int argc, char * const argv[], void *cxt,
char str_opts[1024];
const struct ibdiag_opt *o;
- memset(opts_map, 0, sizeof(opts_map));
+ memset((void *) opts_map, 0, sizeof(opts_map));
prog_name = argv[0];
prog_args = usage_args;
diff --git a/infiniband-diags/src/sminfo.c b/infiniband-diags/src/sminfo.c
index e96c782..7767668 100644
--- a/infiniband-diags/src/sminfo.c
+++ b/infiniband-diags/src/sminfo.c
@@ -37,14 +37,13 @@
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
#include <getopt.h>
#include <infiniband/umad.h>
#include <infiniband/mad.h>
#include "ibdiag_common.h"
+#include "ibdiag_osd.h"
static uint8_t sminfo[1024];
@@ -59,10 +58,10 @@ enum {
};
char *statestr[] = {
- [SMINFO_NOTACT] "SMINFO_NOTACT",
- [SMINFO_DISCOVER] "SMINFO_DISCOVER",
- [SMINFO_STANDBY] "SMINFO_STANDBY",
- [SMINFO_MASTER] "SMINFO_MASTER",
+ "SMINFO_NOTACT",
+ "SMINFO_DISCOVER",
+ "SMINFO_STANDBY",
+ "SMINFO_MASTER",
};
#define STATESTR(s) (((unsigned)(s)) < SMINFO_STATE_LAST ? statestr[s] : "???")
@@ -88,7 +87,7 @@ static int process_opt(void *context, int ch, char *optarg)
return 0;
}
-int main(int argc, char **argv)
+int CDECL main(int argc, char **argv)
{
int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
int mod = 0;
@@ -100,7 +99,7 @@ int main(int argc, char **argv)
{ "state", 's', 1, "<0-3>", "set SM state"},
{ "priority", 'p', 1, "<0-15>", "set SM priority"},
{ "activity", 'a', 1, NULL, "set activity count"},
- { }
+ { 0 }
};
char usage_args[] = "<sm_lid|sm_dr_path> [modifier]";
More information about the ofw
mailing list