[ofa-general] [Patch 3 of 4] uDAPL v2: OFW changes - extension debug, build issues, ptr check macro

Arlin Davis arlin.r.davis at intel.com
Thu Jan 3 11:55:42 PST 2008


Common code -
   Missing DAT_API defs
   casting to fix build issues
   bitmaps for extension debug 
   DAPL_BAD_PTR macro
 
Signed-off by: Stan Smith <stan.smith at intel.com>
Signed-off by: Arlin Davis <ardavis at ichips.intel.com>

diff --git a/dapl/common/dapl_ep_connect.c b/dapl/common/dapl_ep_connect.c
index 0998edc..12d391f 100755
--- a/dapl/common/dapl_ep_connect.c
+++ b/dapl/common/dapl_ep_connect.c
@@ -260,7 +260,7 @@ dapl_ep_connect (
 
     max_req_pdata_size = dapls_ib_private_data_size (NULL, DAPL_PDATA_CONN_REQ);
 
-    if (private_data_size + req_hdr_size > max_req_pdata_size) 
+    if (private_data_size + req_hdr_size > (DAT_COUNT)max_req_pdata_size) 
     {
 	dapl_os_unlock ( &ep_ptr->header.lock );
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
diff --git a/dapl/common/dapl_ep_create.c b/dapl/common/dapl_ep_create.c
index 0362ac3..9e6bd9c 100644
--- a/dapl/common/dapl_ep_create.c
+++ b/dapl/common/dapl_ep_create.c
@@ -64,7 +64,7 @@
  *	DAT_INVALID_ATTRIBUTE
  *	DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN
+DAT_RETURN DAT_API
 dapl_ep_create (
     IN  DAT_IA_HANDLE           ia_handle,
     IN  DAT_PZ_HANDLE           pz_handle,
@@ -148,7 +148,7 @@ dapl_ep_create (
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
 	goto bail;
     }
-    if ((unsigned long)ep_attr  &  3)
+    if (DAPL_BAD_PTR(ep_attr))
     {
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
 	goto bail;
diff --git a/dapl/common/dapl_ep_create_with_srq.c b/dapl/common/dapl_ep_create_with_srq.c
index b62f53b..e288670 100644
--- a/dapl/common/dapl_ep_create_with_srq.c
+++ b/dapl/common/dapl_ep_create_with_srq.c
@@ -164,7 +164,8 @@ dapl_ep_create_with_srq (
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
 	goto bail;
     }
-    if ((unsigned long)ep_attr  &  3)
+
+    if ( DAPL_BAD_PTR(ep_attr) )
     {
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
 	goto bail;
diff --git a/dapl/common/dapl_get_consumer_context.c b/dapl/common/dapl_get_consumer_context.c
index 142b57b..c143d59 100644
--- a/dapl/common/dapl_get_consumer_context.c
+++ b/dapl/common/dapl_get_consumer_context.c
@@ -67,7 +67,7 @@ dapl_get_consumer_context (
 
     header = (DAPL_HEADER *)dat_handle;
     if ( ((header) == NULL) ||
-	 ((unsigned long)(header) & 3) ||
+	 DAPL_BAD_PTR(header) ||
 	 (header->magic != DAPL_MAGIC_IA &&
 	  header->magic != DAPL_MAGIC_EVD &&
 	  header->magic != DAPL_MAGIC_EP &&
@@ -81,7 +81,7 @@ dapl_get_consumer_context (
 	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
 	goto bail;
     }
-    if ( context == NULL || ((unsigned long)(header) & 3) )
+    if ( context == NULL || DAPL_BAD_PTR(header) )
     {
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
 	goto bail;
diff --git a/dapl/common/dapl_get_handle_type.c b/dapl/common/dapl_get_handle_type.c
index 156d758..c970b77 100644
--- a/dapl/common/dapl_get_handle_type.c
+++ b/dapl/common/dapl_get_handle_type.c
@@ -68,7 +68,7 @@ dapl_get_handle_type (
 
     header = (DAPL_HEADER *)dat_handle;
     if ( ((header) == NULL) ||
-	 ((unsigned long)(header) & 3) ||
+	 DAPL_BAD_PTR(header) ||
 	 (header->magic != DAPL_MAGIC_IA &&
 	  header->magic != DAPL_MAGIC_EVD &&
 	  header->magic != DAPL_MAGIC_EP &&
diff --git a/dapl/common/dapl_ring_buffer_util.c b/dapl/common/dapl_ring_buffer_util.c
index 7484234..730f5df 100644
--- a/dapl/common/dapl_ring_buffer_util.c
+++ b/dapl/common/dapl_ring_buffer_util.c
@@ -342,7 +342,7 @@ dapls_rbuf_adjust (
     pos = dapl_os_atomic_read (&rbuf->head);
     while ( pos != dapl_os_atomic_read (&rbuf->tail) )
     {
-	rbuf->base[pos] = rbuf->base[pos] + offset;
+	rbuf->base[pos] = (void*)((char*)rbuf->base[pos] + offset);
 	pos =  (pos + 1) & rbuf->lim; /* verify in range */
     }
 }
diff --git a/dapl/common/dapl_set_consumer_context.c b/dapl/common/dapl_set_consumer_context.c
index e43be33..2043b57 100644
--- a/dapl/common/dapl_set_consumer_context.c
+++ b/dapl/common/dapl_set_consumer_context.c
@@ -68,7 +68,7 @@ dapl_set_consumer_context (
 
     header = (DAPL_HEADER *)dat_handle;
     if ( ((header) == NULL) ||
-	 ((unsigned long) (header) & 3) ||
+	 DAPL_BAD_PTR(header) ||
 	 (header->magic != DAPL_MAGIC_IA &&
 	  header->magic != DAPL_MAGIC_EVD &&
 	  header->magic != DAPL_MAGIC_EP &&
diff --git a/dapl/common/dapl_srq_create.c b/dapl/common/dapl_srq_create.c
index 66e9d0e..b03bbd6 100644
--- a/dapl/common/dapl_srq_create.c
+++ b/dapl/common/dapl_srq_create.c
@@ -115,7 +115,7 @@ dapl_srq_create (
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
 	goto bail;
     }
-    if ((unsigned long)srq_attr  &  3)
+    if (DAPL_BAD_PTR(srq_attr))
     {
 	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
 	goto bail;
diff --git a/dapl/include/dapl.h b/dapl/include/dapl.h
index ade101b..6375d29 100755
--- a/dapl/include/dapl.h
+++ b/dapl/include/dapl.h
@@ -161,15 +161,26 @@ typedef enum dapl_qp_state
  *                                                                   *
  *********************************************************************/
 
+#if defined (sun) || defined(__sun) || defined(_sun_) || defined (__solaris__) 
+#define DAPL_BAD_PTR(a) ((unsigned long)(a) & 3)
+#elif defined(__linux__)
+#define DAPL_BAD_PTR(a) ((unsigned long)(a) & 3)
+#elif defined(_WIN64)
+#define DAPL_BAD_PTR(a) ((unsigned long)((DAT_UINT64)(a)) & 3)
+#elif defined(_WIN32)
+#define DAPL_BAD_PTR(a) ((unsigned long)((DAT_UINT64)(a)) & 3)
+#endif
+
 /*
  * Simple macro to verify a handle is bad. Conditions:
  * - pointer is NULL
  * - pointer is not word aligned
  * - pointer's magic number is wrong
  */
+
 #define DAPL_BAD_HANDLE(h, magicNum) (				\
 	    ((h) == NULL) ||					\
-	    ((unsigned long)(h) & 3) ||				\
+	    DAPL_BAD_PTR(h) ||					\
 	    (((DAPL_HEADER *)(h))->magic != (magicNum)))
 
 #define DAPL_MIN(a, b)        ((a < b) ? (a) : (b))
diff --git a/dapl/include/dapl_debug.h b/dapl/include/dapl_debug.h
index a3bdcf6..76db8fd 100644
--- a/dapl/include/dapl_debug.h
+++ b/dapl/include/dapl_debug.h
@@ -85,7 +85,16 @@ extern DAPL_DBG_DEST 	g_dapl_dbg_dest;
 extern void dapl_internal_dbg_log ( DAPL_DBG_TYPE type,  const char *fmt,  ...);
 
 #else  /* !DAPL_DBG */
+
+#if defined(_WIN32) || defined(_WIN64)
+/* sigh - no support for (...) in macros. Compiler should optimize this away */
+static __inline void dapl_dbg_log ( DAPL_DBG_TYPE type,  const char *fmt,  ...)
+{
+}
+#else
 #define dapl_dbg_log(...)
+#endif
+
 #endif /* !DAPL_DBG */
 
 /*
@@ -112,7 +121,8 @@ extern void dapl_internal_dbg_log ( DAPL_DBG_TYPE type,  const char *fmt,  ...);
 #define DCNT_EVD_DEQUEUE_NOT_FOUND	18
 #define DCNT_TIMER_SET			19
 #define DCNT_TIMER_CANCEL		20
-#define DCNT_NUM_COUNTERS		21
+#define DCNT_EXTENSION			21
+#define DCNT_NUM_COUNTERS		22
 #define DCNT_ALL_COUNTERS               DCNT_NUM_COUNTERS
 
 #if defined(DAPL_COUNTERS)





More information about the general mailing list