Skip to contentSkip to conversation

opensm/complib: redundant redeclarations

PATCH New Yevgeny Kliteynik 1 participant 1 message Feb 1, 2010 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/complib: redundant redeclarations

Hi Sasha,

There are couple of places in complib headers that cause compiler to complain:

cl_atomic.h:73: warning: redundant redeclaration of 'cl_atomic_inc' cl_atomic_osd.h:58: warning: previous definition of 'cl_atomic_inc' was here

cl_atomic.h:104: warning: redundant redeclaration of 'cl_atomic_dec' cl_atomic_osd.h:69: warning: previous definition of 'cl_atomic_dec' was here

cl_atomic.h:136: warning: redundant redeclaration of 'cl_atomic_add' cl_atomic_osd.h:81: warning: previous definition of 'cl_atomic_add' was here

cl_atomic.h:171: warning: redundant redeclaration of 'cl_atomic_sub' cl_atomic_osd.h:93: warning: previous definition of 'cl_atomic_sub' was here

cl_thread.h:346: warning: redundant redeclaration of 'cl_is_blockable' cl_thread_osd.h:63: warning: previous definition of 'cl_is_blockable' was here

In general, here's the problem:

We have cl_file.h and cl_file_osd.h. cl_file.h has include directive for cl_file_osd.h cl_file.h has the following definition of function:

    int foo();

cl_file_osd.h has another function definition, but this time it also has implementation:

    static inline int foo() { ..... }

Any preferable way to fix this?

Get rid of the _osd.h files and have the functions implementation included in the usual .h file?

Define some *_HAVE_OSD flag in the _osd.h file
and enclose function declaration in the usual .h
file with #ifndef?

The following patch implements option 2.

This patch is also kind of an RFC, so let
me what you think. Any other ideas?

---
 opensm/include/complib/cl_atomic.h     |    8 ++++++++
 opensm/include/complib/cl_atomic_osd.h |    4 ++++
 opensm/include/complib/cl_thread.h     |    2 ++
 opensm/include/complib/cl_thread_osd.h |    1 +
 4 files changed, 15 insertions(+), 0 deletions(-)
opensm/include/complib/cl_atomic.h +8 -0
index 92620ee..7e343d7 100644
@@ -70,7 +70,9 @@ BEGIN_C_DECLS
 *
 * SYNOPSIS
 */
+#ifndef _OSD_CL_ATOMIC_INC
 int32_t cl_atomic_inc(IN atomic32_t * const p_value);
+#endif
 /*
 * PARAMETERS
 *	p_value
@@ -101,7 +103,9 @@ int32_t cl_atomic_inc(IN atomic32_t * const p_value);
 *
 * SYNOPSIS
 */
+#ifndef _OSD_CL_ATOMIC_DEC
 int32_t cl_atomic_dec(IN atomic32_t * const p_value);
+#endif
 /*
 * PARAMETERS
 *	p_value
@@ -132,8 +136,10 @@ int32_t cl_atomic_dec(IN atomic32_t * const p_value);
 *
 * SYNOPSIS
 */
+#ifndef _OSD_CL_ATOMIC_ADD
 int32_t
 cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment);
+#endif
 /*
 * PARAMETERS
 *	p_value
@@ -167,8 +173,10 @@ cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment);
 *
 * SYNOPSIS
 */
+#ifndef _OSD_CL_ATOMIC_SUB
 int32_t
 cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement);
+#endif
 /*
 * PARAMETERS
 *	p_value
opensm/include/complib/cl_atomic_osd.h +4 -0
index ac14f8a..43d1b77 100644
@@ -54,6 +54,7 @@
 
 BEGIN_C_DECLS extern cl_spinlock_t cl_atomic_spinlock;
 
+#define _OSD_CL_ATOMIC_INC
 static inline int32_t cl_atomic_inc(IN atomic32_t * const p_value)
 {
 	int32_t new_val;
@@ -65,6 +66,7 @@ static inline int32_t cl_atomic_inc(IN atomic32_t * const p_value)
 	return (new_val);
 }
 
+#define _OSD_CL_ATOMIC_DEC
 static inline int32_t cl_atomic_dec(IN atomic32_t * const p_value)
 {
 	int32_t new_val;
@@ -76,6 +78,7 @@ static inline int32_t cl_atomic_dec(IN atomic32_t * const p_value)
 	return (new_val);
 }
 
+#define _OSD_CL_ATOMIC_ADD
 static inline int32_t
 cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment)
 {
@@ -88,6 +91,7 @@ cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment)
 	return (new_val);
 }
 
+#define _OSD_CL_ATOMIC_SUB
 static inline int32_t
 cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement)
 {
opensm/include/complib/cl_thread.h +2 -0
index 0a622a1..b7ee1ca 100644
@@ -343,7 +343,9 @@ boolean_t cl_is_current_thread(IN const cl_thread_t * const p_thread);
 *
 * SYNOPSIS
 */
+#ifndef _OSD_CL_IS_BLOCKABLE
 boolean_t cl_is_blockable(void);
+#endif
 /*
 * RETURN VALUE
 *	TRUE
opensm/include/complib/cl_thread_osd.h +1 -0
index ad7df90..50fb6f7 100644
@@ -59,6 +59,7 @@ typedef struct _cl_thread_osd_t {
 	cl_state_t state;
 } cl_thread_osd_t;
 
+#define _OSD_CL_IS_BLOCKABLE
 static inline boolean_t cl_is_blockable(void)
 {
 	return TRUE;
Signature · 7 lines
1.5.1.4


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html