[openib-general] [PATCH] Opensm - type changing in st.h/c files

Yael Kalka yael at mellanox.co.il
Wed Feb 8 00:50:19 PST 2006


Hi Hal,

There was a problem with some of the types defined when compiling on
64bit windows machines. The following patch adds support for these as
well.

Thanks,
Yael

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

Index: include/opensm/st.h
===================================================================
--- include/opensm/st.h	(revision 5307)
+++ include/opensm/st.h	(working copy)
@@ -50,14 +50,21 @@
 
 BEGIN_C_DECLS
 
-typedef unsigned long st_data_t;
+#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
 
 typedef struct st_table st_table;
 
 struct st_hash_type {
   int (*compare)(void *, void *);
-  int (*hash)(void *);
+  st_ptr_t (*hash)(void *);
 };
 
 struct st_table {
Index: opensm/st.c
===================================================================
--- opensm/st.c	(revision 5307)
+++ opensm/st.c	(working copy)
@@ -41,7 +41,6 @@
 #  include <config.h>
 #endif /* HAVE_CONFIG_H */
 
-#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -73,7 +72,7 @@ struct st_table_entry {
  *
  */
 static int numcmp(void *, void *);
-static int numhash(void *);
+static st_ptr_t numhash(void *);
 static struct st_hash_type type_numhash = {
   numcmp,
   numhash,
@@ -83,7 +82,7 @@ static struct st_hash_type type_numhash 
 /* extern int strcmp(const char *, const char *); */ 
 static int strhash(const char *);
 
-static inline int st_strhash(void *key)
+static inline st_ptr_t st_strhash(void *key)
 {
   return strhash((const char *)key);
 }
@@ -619,12 +618,12 @@ static int
 numcmp(x, y)
      void *x, *y;
 {
-  return (long)x != (long)y;
+  return (st_ptr_t)x != (st_ptr_t)y;
 }
 
-static int
+static st_ptr_t
 numhash(n)
      void *n;
 {
-  return (long)n;
+  return (st_ptr_t)n;
 }




More information about the general mailing list