[openib-general] [PATCH] Opensm - osmt_service.c - changes for windows

Yael Kalka yael at mellanox.co.il
Mon Feb 13 05:22:06 PST 2006


Hi Hal,

The following patch changes some of the includes for the windows
compilation.
Also there are fixes of type casting.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: osmtest/osmt_service.c
===================================================================
--- osmtest/osmt_service.c	(revision 5380)
+++ osmtest/osmt_service.c	(working copy)
@@ -50,7 +50,11 @@
 
 /* next error code: 16A    */
 
+#ifndef __WIN__
 #include <unistd.h>
+#else
+#include <time.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -487,7 +491,7 @@ osmt_get_service_by_id_and_name ( IN osm
   osmtest_req_context_t context;
   osmv_query_req_t req;
   ib_service_record_t svc_rec,*p_rec;
-  uint16_t num_recs = 0;
+  uint32_t num_recs = 0;
   osmv_user_query_t user;
 
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_id );
@@ -611,7 +615,7 @@ osmt_get_service_by_id ( IN osmtest_t * 
   osmtest_req_context_t context;
   osmv_query_req_t req;
   ib_service_record_t svc_rec,*p_rec;
-  uint16_t num_recs = 0;
+  uint32_t num_recs = 0;
   osmv_user_query_t user;
 
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_id );
@@ -733,7 +737,7 @@ osmt_get_service_by_name_and_key ( IN os
   osmtest_req_context_t context;
   osmv_query_req_t req;
   ib_service_record_t svc_rec,*p_rec;
-  uint16_t num_recs = 0;
+  uint32_t num_recs = 0;
   osmv_user_query_t user;
 
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_name_and_key );
@@ -865,7 +869,7 @@ osmt_get_service_by_name( IN osmtest_t *
   osmv_query_req_t req;
   ib_service_record_t* p_rec;
   ib_svc_name_t service_name;
-  uint16_t num_recs = 0;
+  uint32_t num_recs = 0;
 
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_name );
 
@@ -977,12 +981,12 @@ ib_api_status_t
 osmt_get_all_services_and_check_names( IN osmtest_t * const p_osmt,
                                        IN ib_svc_name_t * const p_valid_service_names_arr,
                                        IN uint8_t    num_of_valid_names,
-                                       OUT uint16_t *num_services) {
+                                       OUT uint32_t *num_services) {
   ib_api_status_t status = IB_SUCCESS;
   osmtest_req_context_t context;
   osmv_query_req_t req;
   ib_service_record_t* p_rec;
-  uint16_t num_recs = 0,i,j;
+  uint32_t num_recs = 0,i,j;
   uint8_t *p_checked_names;
 
   OSM_LOG_ENTER(&p_osmt->log, osmt_get_all_services_and_check_names );
@@ -1071,8 +1075,8 @@ osmt_get_all_services_and_check_names( I
                    "osmt_get_all_services_and_check_names: "
                    "-I- Comparing source name : >%s<, with record name : >%s<, idx : %d\n",
                    p_valid_service_names_arr[j],p_rec->service_name, p_checked_names[j]);     
-          if ( strcmp((const char *)p_valid_service_names_arr[j],
-                      (const char *)p_rec->service_name) == 0 )
+          if ( strcmp(p_valid_service_names_arr[j],
+                      p_rec->service_name) == 0 )
           {
               osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
                        "osmt_get_all_services_and_check_names: "
@@ -1236,18 +1240,22 @@ osmt_run_service_records_flow( IN osmtes
 #ifdef VENDOR_RMPP_SUPPORT
   /* This array contain only the valid names after registering vs SM */
   ib_svc_name_t   service_valid_names[3];
-  uint16_t num_recs = 0;
+  uint32_t num_recs = 0;
 #endif
 
   OSM_LOG_ENTER( &p_osmt->log,  osmt_run_service_records_flow);
 
   /* Init Service names */
   for (i=0 ; i<=6 ; i++ ) {
-    uint64_t rand = random()-(uint64_t)i;
-    id[i] = abs(pid - rand);
+#ifdef __WIN__
+    uint64_t rand_val = rand()-(uint64_t)i;
+#else
+    uint64_t rand_val = random()-(uint64_t)i;
+#endif
+    id[i] = abs((int)(pid - rand_val));
     /* Just to be unique any place on any host */
     sprintf((char*)(service_name[i]),
-            "osmt.srvc.%" PRIu64 ".%" PRIu64, rand,pid);
+            "osmt.srvc.%" PRIu64 ".%" PRIu64, rand_val,pid);
     /*printf("-I- Service Name is : %s, ID is : 0x%" PRIx64 "\n",service_name[i],id[i]);*/
   }
   status = osmt_register_service(




More information about the general mailing list