[ofa-general] [PATCH 3/3 v2] Minor changes to allow portability to WinOF
Sean Hefty
sean.hefty at intel.com
Mon Jan 19 09:40:58 PST 2009
adding ofw mail list
>- cleanup unnecessary include files
>- ULL declaration on 64 bit constants
>- cast or change data types to fix build warnings on windows
>
>Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
>---
> libibmad/src/dump.c | 25 +++++++++----------------
> libibmad/src/gs.c | 7 +------
> libibmad/src/mad.c | 14 +++++---------
> libibmad/src/portid.c | 9 +++------
> libibmad/src/register.c | 3 +--
> libibmad/src/resolve.c | 3 +--
> libibmad/src/rpc.c | 9 ++++-----
> libibmad/src/sa.c | 1 -
> libibmad/src/serv.c | 4 +---
> libibmad/src/smp.c | 1 -
> libibmad/src/vendor.c | 1 -
> 11 files changed, 25 insertions(+), 52 deletions(-)
>
>diff --git a/libibmad/src/dump.c b/libibmad/src/dump.c
>index 38a2254..a7575b9 100644
>--- a/libibmad/src/dump.c
>+++ b/libibmad/src/dump.c
>@@ -36,13 +36,6 @@
> # include <config.h>
> #endif /* HAVE_CONFIG_H */
>
>-#include <stdio.h>
>-#include <stdlib.h>
>-#include <unistd.h>
>-#include <string.h>
>-#include <inttypes.h>
>-#include <netinet/in.h>
>-
> #include <mad.h>
>
> void
>@@ -114,13 +107,13 @@ mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
> snprintf(buf, bufsz, "0x%08x", *(uint32_t *)val);
> break;
> case 5:
>- snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffllu);
>+ snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffULL);
> break;
> case 6:
>- snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffllu);
>+ snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffULL);
> break;
> case 7:
>- snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffffllu);
>+ snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffffULL);
> break;
> case 8:
> snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *)val);
>@@ -148,13 +141,13 @@ mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
> snprintf(buf, bufsz, "%08x", *(uint32_t *)val);
> break;
> case 5:
>- snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffllu);
>+ snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffULL);
> break;
> case 6:
>- snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffllu);
>+ snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffULL);
> break;
> case 7:
>- snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffffllu);
>+ snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val &
(uint64_t)
>0xffffffffffffffULL);
> break;
> case 8:
> snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *)val);
>@@ -606,7 +599,7 @@ typedef struct _ib_vl_arb_table {
> uint8_t res_vl;
> uint8_t weight;
> } vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
>-} __attribute__((packed)) ib_vl_arb_table_t;
>+} ib_vl_arb_table_t;
>
> static inline void
> ib_vl_arb_get_vl(uint8_t res_vl, uint8_t *const vl )
>@@ -634,7 +627,7 @@ void
> mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num)
> {
> ib_vl_arb_table_t* p_vla_tbl = val;
>- unsigned i, n;
>+ int i, n;
> uint8_t vl;
>
> num /= sizeof(p_vla_tbl->vl_entry[0]);
>@@ -681,7 +674,7 @@ _dump_fields(char *buf, int bufsz, void *data, int start,
>int end)
> bufsz -= n;
> }
>
>- return s - buf;
>+ return (int)(s - buf);
> }
>
> void
>diff --git a/libibmad/src/gs.c b/libibmad/src/gs.c
>index d350c0d..05ee132 100644
>--- a/libibmad/src/gs.c
>+++ b/libibmad/src/gs.c
>@@ -35,13 +35,8 @@
> # include <config.h>
> #endif /* HAVE_CONFIG_H */
>
>-#include <stdio.h>
>-#include <stdlib.h>
>-#include <unistd.h>
>-#include <string.h>
>-
>-#include <infiniband/umad.h>
> #include "mad.h"
>+#include <infiniband/umad.h>
>
> #undef DEBUG
> #define DEBUG if (ibdebug) IBWARN
>diff --git a/libibmad/src/mad.c b/libibmad/src/mad.c
>index be27c09..4a12e6c 100644
>--- a/libibmad/src/mad.c
>+++ b/libibmad/src/mad.c
>@@ -35,14 +35,10 @@
> # include <config.h>
> #endif /* HAVE_CONFIG_H */
>
>-#include <stdio.h>
>-#include <stdlib.h>
>-#include <unistd.h>
>-#include <string.h>
> #include <time.h>
>
>-#include <infiniband/umad.h>
> #include <mad.h>
>+#include <infiniband/umad.h>
>
> #undef DEBUG
> #define DEBUG if (ibdebug) IBWARN
>@@ -55,7 +51,7 @@ mad_trid(void)
> uint64_t next;
>
> if (!base) {
>- srandom(time(0)*getpid());
>+ srandom((int)time(0)*getpid());
> base = random();
> trid = random();
> }
>@@ -97,8 +93,8 @@ mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath,
>void *data)
> mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod);
>
> /* words 7,8 */
>- mad_set_field(buf, 0, IB_MAD_MKEY_F, rpc->mkey >> 32);
>- mad_set_field(buf, 4, IB_MAD_MKEY_F, rpc->mkey & 0xffffffff);
>+ mad_set_field(buf, 0, IB_MAD_MKEY_F, (uint32_t)(rpc->mkey >> 32));
>+ mad_set_field(buf, 4, IB_MAD_MKEY_F, (uint32_t)(rpc->mkey &
0xffffffff));
>
> if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) {
> /* word 9 */
>@@ -168,5 +164,5 @@ mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t
>*dport,
> mad_set_field(mad, 0, IB_SA_RMPP_D2_F, rmpp->d2.u);
> }
>
>- return p - mad;
>+ return ((int)(p - mad));
> }
>diff --git a/libibmad/src/portid.c b/libibmad/src/portid.c
>index 61e6be0..9a69728 100644
>--- a/libibmad/src/portid.c
>+++ b/libibmad/src/portid.c
>@@ -37,10 +37,7 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>-#include <inttypes.h>
>-#include <arpa/inet.h>
>
> #include <mad.h>
>
>@@ -94,7 +91,7 @@ str2drpath(ib_dr_path_t *path, char *routepath, int drslid,
>int drdlid)
> while (str && *str) {
> if ((s = strchr(str, ',')))
> *s = 0;
>- path->p[++path->cnt] = atoi(str);
>+ path->p[++path->cnt] = (uint8_t)atoi(str);
> if (!s)
> break;
> str = s+1;
>@@ -112,11 +109,11 @@ drpath2str(ib_dr_path_t *path, char *dstr, size_t
>dstr_size)
> int i = 0;
> int rc = snprintf(dstr, dstr_size, "slid %d; dlid %d; %d",
> path->drslid, path->drdlid, path->p[0]);
>- if (rc >= dstr_size)
>+ if (rc >= (int)dstr_size)
> return dstr;
> for (i = 1; i <= path->cnt; i++) {
> rc += snprintf(dstr+rc, dstr_size-rc, ",%d", path->p[i]);
>- if (rc >= dstr_size)
>+ if (rc >= (int)dstr_size)
> break;
> }
> return (dstr);
>diff --git a/libibmad/src/register.c b/libibmad/src/register.c
>index 045f840..ea916da 100644
>--- a/libibmad/src/register.c
>+++ b/libibmad/src/register.c
>@@ -37,12 +37,11 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
> #include <errno.h>
>
>-#include <infiniband/umad.h>
> #include "mad.h"
>+#include <infiniband/umad.h>
>
> #undef DEBUG
> #define DEBUG if (ibdebug) IBWARN
>diff --git a/libibmad/src/resolve.c b/libibmad/src/resolve.c
>index 906b28d..2e373e6 100644
>--- a/libibmad/src/resolve.c
>+++ b/libibmad/src/resolve.c
>@@ -37,11 +37,10 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>
>-#include <infiniband/umad.h>
> #include <mad.h>
>+#include <infiniband/umad.h>
>
> #undef DEBUG
> #define DEBUG if (ibdebug) IBWARN
>diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
>index 670a936..3bf3640 100644
>--- a/libibmad/src/rpc.c
>+++ b/libibmad/src/rpc.c
>@@ -37,12 +37,11 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
> #include <errno.h>
>
>-#include <infiniband/umad.h>
> #include "mad.h"
>+#include <infiniband/umad.h>
>
> #define MAX_CLASS 256
>
>@@ -129,7 +128,7 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int
>agentid, int len,
> save_mad = 0;
> }
>
>- trid = mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F);
>+ trid = (uint32_t)mad_get_field64(umad_get_mad(sndbuf), 0,
IB_MAD_TRID_F);
>
> for (retries = 0; retries < madrpc_retries; retries++) {
> if (retries) {
>@@ -298,7 +297,7 @@ madrpc_init(char *dev_name, int dev_port, int
>*mgmt_classes, int num_classes)
> IBPANIC("too many classes %d requested", num_classes);
>
> while (num_classes--) {
>- int rmpp_version = 0;
>+ uint8_t rmpp_version = 0;
> int mgmt = *mgmt_classes++;
>
> if (mgmt == IB_SA_CLASS)
>@@ -343,7 +342,7 @@ mad_rpc_open_port(char *dev_name, int dev_port,
> }
>
> while (num_classes--) {
>- int rmpp_version = 0;
>+ uint8_t rmpp_version = 0;
> int mgmt = *mgmt_classes++;
> int agent;
>
>diff --git a/libibmad/src/sa.c b/libibmad/src/sa.c
>index c601254..c08a392 100644
>--- a/libibmad/src/sa.c
>+++ b/libibmad/src/sa.c
>@@ -37,7 +37,6 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>
> #include <mad.h>
>diff --git a/libibmad/src/serv.c b/libibmad/src/serv.c
>index b329352..611a93f 100644
>--- a/libibmad/src/serv.c
>+++ b/libibmad/src/serv.c
>@@ -37,12 +37,10 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>-#include <netinet/in.h>
>
>-#include <infiniband/umad.h>
> #include <mad.h>
>+#include <infiniband/umad.h>
>
> #undef DEBUG
> #define DEBUG if (ibdebug) IBWARN
>diff --git a/libibmad/src/smp.c b/libibmad/src/smp.c
>index ad6b066..e872602 100644
>--- a/libibmad/src/smp.c
>+++ b/libibmad/src/smp.c
>@@ -37,7 +37,6 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>
> #include <mad.h>
>diff --git a/libibmad/src/vendor.c b/libibmad/src/vendor.c
>index eb703f6..7928a58 100644
>--- a/libibmad/src/vendor.c
>+++ b/libibmad/src/vendor.c
>@@ -37,7 +37,6 @@
>
> #include <stdio.h>
> #include <stdlib.h>
>-#include <unistd.h>
> #include <string.h>
>
> #include <mad.h>
>--
>1.5.2.5
>
>_______________________________________________
>general mailing list
>general at lists.openfabrics.org
>http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
>To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
More information about the general
mailing list