[ofa-general] [PATCH] manangement: kill __WORDSIZE macro checks

Sasha Khapyorsky sashak at voltaire.com
Sat Dec 22 03:16:27 PST 2007


Kill #if __WORRDSIZE == 64 checks.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 infiniband-diags/src/ibping.c           |   23 ++----------
 libibcommon/include/infiniband/common.h |    5 ---
 libibcommon/src/sysfs.c                 |    5 ---
 libibmad/src/dump.c                     |   59 ++++++-------------------------
 libibmad/src/portid.c                   |    7 +---
 opensm/include/opensm/st.h              |    4 --
 opensm/opensm/osm_db_pack.c             |    6 +---
 opensm/opensm/osm_prtn_config.c         |   10 +-----
 opensm/opensm/osm_qos_parser.y          |    4 --
 opensm/opensm/osm_subnet.c              |    4 --
 10 files changed, 18 insertions(+), 109 deletions(-)

diff --git a/infiniband-diags/src/ibping.c b/infiniband-diags/src/ibping.c
index ea46002..ba32508 100644
--- a/infiniband-diags/src/ibping.c
+++ b/infiniband-diags/src/ibping.c
@@ -139,13 +139,8 @@ ibping(ib_portid_t *portid, int quiet)
 		memcpy(last_host, data, sizeof last_host);
 
 	if (!quiet)
-#if __WORDSIZE == 64
-		printf("Pong from %s (%s): time %lu.%03lu ms\n",
+		printf("Pong from %s (%s): time %" PRIu64 ".%03" PRIu64 " ms\n",
 			data, portid2str(portid), rtt/1000, rtt%1000);
-#else
-		printf("Pong from %s (%s): time %llu.%03llu ms\n",
-			data, portid2str(portid), rtt/1000, rtt%1000);
-#endif
 
 	return rtt;
 }
@@ -178,27 +173,15 @@ report(int sig)
 	DEBUG("out due signal %d", sig);
 
 	printf("\n--- %s (%s) ibping statistics ---\n", last_host, portid2str(&portid));
-#if __WORDSIZE == 64
-	printf("%lu packets transmitted, %lu received, %lu%% packet loss, time %lu ms\n",
+	printf("%" PRIu64 " packets transmitted, %" PRIu64 " received, %" PRIu64 "%% packet loss, time %" PRIu64 " ms\n",
 		ntrans, replied,
-		(lost != 0) ?  lost * 100ul / ntrans : 0ul, total_time / 1000ul);
-	printf("rtt min/avg/max = %lu.%03lu/%lu.%03lu/%lu.%03lu ms\n",
-		minrtt == ~0ull ? 0 : minrtt/1000,
-		minrtt == ~0ull ? 0 : minrtt%1000,
-		replied ? total_rtt/replied/1000 : 0,
-		replied ? (total_rtt/replied)%1000 : 0,
-		maxrtt/1000, maxrtt%1000);
-#else
-	printf("%llu packets transmitted, %llu received, %llu%% packet loss, time %llu ms\n",
-		(unsigned long long)ntrans, (unsigned long long)replied,
 		(lost != 0) ?  lost * 100ull / ntrans : 0ull, total_time / 1000ull);
-	printf("rtt min/avg/max = %llu.%03llu/%llu.%03llu/%llu.%03llu ms\n",
+	printf("rtt min/avg/max = %" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 " ms\n",
 		minrtt == ~0ull ? 0 : minrtt/1000,
 		minrtt == ~0ull ? 0 : minrtt%1000,
 		replied ? total_rtt/replied/1000 : 0,
 		replied ? (total_rtt/replied)%1000 : 0,
 		maxrtt/1000, maxrtt%1000);
-#endif
 
 	exit(0);
 }
diff --git a/libibcommon/include/infiniband/common.h b/libibcommon/include/infiniband/common.h
index 4eb3872..01fc796 100644
--- a/libibcommon/include/infiniband/common.h
+++ b/libibcommon/include/infiniband/common.h
@@ -49,11 +49,6 @@
 
 BEGIN_C_DECLS
 
-/**
- * Byte alignments for structures
- */
-#define BUFALIGN __WORDSIZE
-
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #ifndef ntohll
 static inline uint64_t ntohll(uint64_t x) {
diff --git a/libibcommon/src/sysfs.c b/libibcommon/src/sysfs.c
index 49fc79c..f3f6711 100644
--- a/libibcommon/src/sysfs.c
+++ b/libibcommon/src/sysfs.c
@@ -59,11 +59,6 @@
 
 #include "common.h"
 
-#if __WORDSIZE == 64
-#define strtoll		strtol
-#define strtoull	strtoul
-#endif
-
 static int
 ret_code(void)
 {
diff --git a/libibmad/src/dump.c b/libibmad/src/dump.c
index 3d8593d..254106b 100644
--- a/libibmad/src/dump.c
+++ b/libibmad/src/dump.c
@@ -40,6 +40,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <inttypes.h>
 #include <netinet/in.h>
 
 #include <mad.h>
@@ -63,11 +64,7 @@ mad_dump_int(char *buf, int bufsz, void *val, int valsz)
 	case 6:
 	case 7:
 	case 8:
-#if __WORDSIZE == 64
-		snprintf(buf, bufsz, "%lu", *(uint64_t *)val);
-#else
-		snprintf(buf, bufsz, "%llu", *(uint64_t *)val);
-#endif
+		snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val);
 		break;
 	default:
 		IBWARN("bad int sz %d", valsz);
@@ -93,11 +90,7 @@ mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
 	case 6:
 	case 7:
 	case 8:
-#if __WORDSIZE == 64
-		snprintf(buf, bufsz, "%lu", *(uint64_t *)val);
-#else
-		snprintf(buf, bufsz, "%llu", *(uint64_t *)val);
-#endif
+		snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val);
 		break;
 	default:
 		IBWARN("bad int sz %u", valsz);
@@ -121,33 +114,18 @@ mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
 	case 4:
 		snprintf(buf, bufsz, "0x%08x", *(uint32_t *)val);
 		break;
-#if __WORDSIZE == 64
 	case 5:
-		snprintf(buf, bufsz, "0x%010lx", *(uint64_t *)val & 0xfffffffffflu);
+		snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val & 0xffffffffffllu);
 		break;
 	case 6:
-		snprintf(buf, bufsz, "0x%012lx", *(uint64_t *)val & 0xfffffffffffflu);
+		snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val & 0xffffffffffffllu);
 		break;
 	case 7:
-		snprintf(buf, bufsz, "0x%014lx", *(uint64_t *)val & 0xfffffffffffffflu);
+		snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val & 0xffffffffffffffllu);
 		break;
 	case 8:
-		snprintf(buf, bufsz, "0x%016lx", *(uint64_t *)val);
+		snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *)val);
 		break;
-#else
-	case 5:
-		snprintf(buf, bufsz, "0x%010llx", *(uint64_t *)val & 0xffffffffffllu);
-		break;
-	case 6:
-		snprintf(buf, bufsz, "0x%012llx", *(uint64_t *)val & 0xffffffffffffllu);
-		break;
-	case 7:
-		snprintf(buf, bufsz, "0x%014llx", *(uint64_t *)val & 0xffffffffffffffllu);
-		break;
-	case 8:
-		snprintf(buf, bufsz, "0x%016llx", *(uint64_t *)val);
-		break;
-#endif
 	default:
 		IBWARN("bad int sz %d", valsz);
 		buf[0] = 0;
@@ -170,33 +148,18 @@ mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
 	case 4:
 		snprintf(buf, bufsz, "%08x", *(uint32_t *)val);
 		break;
-#if __WORDSIZE == 64
-	case 5:
-		snprintf(buf, bufsz, "%010lx", *(uint64_t *)val & 0xfffffffffflu);
-		break;
-	case 6:
-		snprintf(buf, bufsz, "%012lx", *(uint64_t *)val & 0xfffffffffffflu);
-		break;
-	case 7:
-		snprintf(buf, bufsz, "%014lx", *(uint64_t *)val & 0xfffffffffffffflu);
-		break;
-	case 8:
-		snprintf(buf, bufsz, "%016lx", *(uint64_t *)val);
-		break;
-#else
 	case 5:
-		snprintf(buf, bufsz, "%010llx", *(uint64_t *)val & 0xffffffffffllu);
+		snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val & 0xffffffffffllu);
 		break;
 	case 6:
-		snprintf(buf, bufsz, "%012llx", *(uint64_t *)val & 0xffffffffffffllu);
+		snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val & 0xffffffffffffllu);
 		break;
 	case 7:
-		snprintf(buf, bufsz, "%014llx", *(uint64_t *)val & 0xffffffffffffffllu);
+		snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val & 0xffffffffffffffllu);
 		break;
 	case 8:
-		snprintf(buf, bufsz, "%016llx", *(uint64_t *)val);
+		snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *)val);
 		break;
-#endif
 	default:
 		IBWARN("bad int sz %d", valsz);
 		buf[0] = 0;
diff --git a/libibmad/src/portid.c b/libibmad/src/portid.c
index dde1161..056b03d 100644
--- a/libibmad/src/portid.c
+++ b/libibmad/src/portid.c
@@ -41,6 +41,7 @@
 #include <pthread.h>
 #include <sys/time.h>
 #include <string.h>
+#include <inttypes.h>
 
 #include <mad.h>
 #include <infiniband/common.h>
@@ -70,11 +71,7 @@ portid2str(ib_portid_t *portid)
 	if (portid->lid > 0) {
 		s += sprintf(s, "Lid %d", portid->lid);
 		if (portid->grh_present) {
-#if __WORDSIZE == 64
-			s += sprintf(s, " Gid 0x%lx%lx",
-#else
-			s += sprintf(s, " Gid 0x%Lx%Lx",
-#endif
+			s += sprintf(s, " Gid 0x%" PRIx64 "%" PRIx64,
 					ntohll(*(uint64_t *)portid->gid),
 					ntohll(*(uint64_t *)(portid->gid+8)));
 		}
diff --git a/opensm/include/opensm/st.h b/opensm/include/opensm/st.h
index f32d3bb..30cc308 100644
--- a/opensm/include/opensm/st.h
+++ b/opensm/include/opensm/st.h
@@ -49,11 +49,7 @@
 #endif				/* __cplusplus */
 
 BEGIN_C_DECLS
-#if (__WORDSIZE == 64) || defined (_WIN64)
-#define st_ptr_t unsigned long long
-#else
 #define st_ptr_t unsigned long
-#endif
 typedef st_ptr_t st_data_t;
 
 #define ST_DATA_T_DEFINED
diff --git a/opensm/opensm/osm_db_pack.c b/opensm/opensm/osm_db_pack.c
index de5550f..bf56169 100644
--- a/opensm/opensm/osm_db_pack.c
+++ b/opensm/opensm/osm_db_pack.c
@@ -48,11 +48,7 @@ static inline void __osm_pack_guid(uint64_t guid, char *p_guid_str)
 
 static inline uint64_t __osm_unpack_guid(char *p_guid_str)
 {
-#if __WORDSIZE == 64
-	return (strtoul(p_guid_str, NULL, 0));
-#else
-	return (strtoull(p_guid_str, NULL, 0));
-#endif
+	return strtoull(p_guid_str, NULL, 0);
 }
 
 static inline void
diff --git a/opensm/opensm/osm_prtn_config.c b/opensm/opensm/osm_prtn_config.c
index 811b9eb..7889e35 100644
--- a/opensm/opensm/osm_prtn_config.c
+++ b/opensm/opensm/osm_prtn_config.c
@@ -56,14 +56,6 @@
 #include <opensm/osm_subnet.h>
 #include <opensm/osm_log.h>
 
-#if __WORDSIZE == 64
-#define STRTO_IB_NET64(str, end, base) strtoul(str, end, base)
-#else
-#define STRTO_IB_NET64(str, end, base) strtoull(str, end, base)
-#endif
-
-/*
- */
 struct part_conf {
 	osm_log_t *p_log;
 	osm_subn_t *p_subn;
@@ -230,7 +222,7 @@ static int partition_add_port(unsigned lineno, struct part_conf *conf,
 		guid = cl_ntoh64(conf->p_subn->sm_port_guid);
 	} else {
 		char *end;
-		guid = STRTO_IB_NET64(name, &end, 0);
+		guid = strtoull(name, &end, 0);
 		if (!guid || *end)
 			return -1;
 	}
diff --git a/opensm/opensm/osm_qos_parser.y b/opensm/opensm/osm_qos_parser.y
index edfa25c..8cae5f3 100644
--- a/opensm/opensm/osm_qos_parser.y
+++ b/opensm/opensm/osm_qos_parser.y
@@ -2420,11 +2420,7 @@ static char * __parser_strip_white(char * str)
 
 static void __parser_str2uint64(uint64_t * p_val, char * str)
 {
-#if __WORDSIZE == 64
-   *p_val = strtoul(str, NULL, 0);
-#else
    *p_val = strtoull(str, NULL, 0);
-#endif
 }
 
 /***************************************************
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index 2fe21bc..f9eb714 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -497,11 +497,7 @@ opts_unpack_net64(IN char *p_req_key,
 	uint64_t val;
 
 	if (!strcmp(p_req_key, p_key)) {
-#if __WORDSIZE == 64
-		val = strtoul(p_val_str, NULL, 0);
-#else
 		val = strtoull(p_val_str, NULL, 0);
-#endif
 		if (cl_hton64(val) != *p_val) {
 			char buff[128];
 			sprintf(buff,
-- 
1.5.3.4.206.g58ba4




More information about the general mailing list