[openib-general] [PATCH] osm/complib: clean #ifdef __KERNEL__

Sasha Khapyorsky sashak at voltaire.com
Mon Feb 27 11:37:58 PST 2006


Hello,

This removes obsolete #ifdef __KERNEL__ from complib

Sasha.


Remove annoying #ifdef __KERNEL__ from complib

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>

---

 osm/include/complib/cl_atomic.h       |   86 --------------------------
 osm/include/complib/cl_debug_osd.h    |  109 ---------------------------------
 osm/include/complib/cl_event_osd.h    |   27 --------
 osm/include/complib/cl_spinlock_osd.h |   40 ------------
 osm/include/complib/cl_thread_osd.h   |   39 ------------
 osm/include/complib/cl_timer_osd.h    |   23 -------
 osm/include/complib/cl_types_osd.h    |  102 +------------------------------
 7 files changed, 9 insertions(+), 417 deletions(-)

diff --git a/osm/include/complib/cl_atomic.h b/osm/include/complib/cl_atomic.h
index ad2fda5..176dba8 100644
--- a/osm/include/complib/cl_atomic.h
+++ b/osm/include/complib/cl_atomic.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -216,90 +216,6 @@ cl_atomic_sub(
 *	Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add,
 *	cl_atomic_xchg, cl_atomic_comp_xchg
 *********/
-#ifdef __KERNEL__
-
-/****f* Component Library: Atomic Operations/cl_atomic_xchg
-* NAME
-*	cl_atomic_xchg
-*
-* DESCRIPTION
-*	The cl_atomic_xchg function atomically sets a value of a
-*	32-bit signed integer and returns the initial value.
-*
-* SYNOPSIS
-*/
-int32_t
-cl_atomic_xchg(
-	IN	atomic32_t* const	p_value,
-	IN	const int32_t		new_value );
-/*
-* PARAMETERS
-*	p_value
-*		[in] Pointer to a 32-bit integer to exchange with new_value.
-*
-*	new_value
-*		[in] Value to assign.
-*
-* RETURN VALUE
-*	Returns the initial value pointed to by p_value.
-*
-* NOTES
-*	The provided value is exchanged with new_value and its initial value
-*	returned in one atomic operation.
-*
-*	cl_atomic_xchg maintains data consistency without requiring additional
-*	synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-*	Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add,
-*	cl_atomic_sub, cl_atomic_comp_xchg
-*********/
-
-
-/****f* Component Library: Atomic Operations/cl_atomic_comp_xchg
-* NAME
-*	cl_atomic_comp_xchg
-*
-* DESCRIPTION
-*	The cl_atomic_comp_xchg function atomically compares a 32-bit signed
-*	integer to a desired value, sets that integer to the
-*	specified value if equal, and returns the initial value.
-*
-* SYNOPSIS
-*/
-int32_t
-cl_atomic_comp_xchg(
-	IN	atomic32_t* const	p_value,
-	IN	const int32_t		compare,
-	IN	const int32_t		new_value );
-/*
-* PARAMETERS
-*	p_value
-*		[in] Pointer to a 32-bit integer to exchange with new_value.
-*
-*	compare
-*		[in] Value to compare to the value pointed to by p_value.
-*
-*	new_value
-*		[in] Value to assign if the value pointed to by p_value is equal to
-*		the value specified by the compare parameter.
-*
-* RETURN VALUE
-*	Returns the initial value of the variable pointed to by p_value.
-*
-* NOTES
-*	The value pointed to by p_value is compared to the value specified by the
-*	compare parameter.  If the two values are equal, the p_value variable is
-*	set to new_value.  The initial value pointed to by p_value is returned.
-*
-*	cl_atomic_comp_xchg maintains data consistency without requiring additional
-*	synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-*	Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add,
-*	cl_atomic_sub, cl_atomic_xchg
-*********/
-#endif /* __KERNEL__ */
 
 END_C_DECLS
 
diff --git a/osm/include/complib/cl_debug_osd.h b/osm/include/complib/cl_debug_osd.h
index 2cd17a0..8f3c2a8 100644
--- a/osm/include/complib/cl_debug_osd.h
+++ b/osm/include/complib/cl_debug_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -80,111 +80,6 @@ BEGIN_C_DECLS
 #define PRIdSIZE_T	"d"
 #endif 
 
-#ifdef __KERNEL__
-
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/interrupt.h>
-
-
-/* Linux Kernel Mode */
-#if __WORDSIZE == 64
-#define __PRI64_PREFIX	"l"
-#else
-#define __PRI64_PREFIX	"L"
-#endif
-
-
-#define PRId64		__PRI64_PREFIX"d"
-#define PRIo64		__PRI64_PREFIX"o"
-#define PRIu64		__PRI64_PREFIX"u"
-#define PRIx64		__PRI64_PREFIX"x"
-
-void cl_printk( char *message, ... );	/* see cl_debug.c */
-
-
-#ifndef	PRINTK_LVL
-#define PRINTK_LVL KERN_INFO
-#endif
-
-#if defined (_DEBUG_)
-
-#if defined (CONFIG_GDB)
-#define cl_msg_out		printk
-#define cl_dbg_out		printk
-#else
-#define cl_msg_out	cl_printk
-#define cl_dbg_out	cl_printk
-#endif
-
-#else /* not _DEBUG_ */
-#define cl_msg_out		cl_printk
-#define cl_dbg_out		foo
-#endif	/* _DEBUG_ */
-
-
-/*
- * The following macros are used internally by the CL_ENTER, CL_TRACE,
- * CL_TRACE_EXIT, and CL_EXIT macros.
- */
-
-#if defined (CONFIG_SMP)
-
-#define _CL_DBG_ENTER	\
-	("~%d:%s%s%s() [\n", smp_processor_id(), __MODULE__, \
-	__MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_EXIT	\
-	("~%d:%s%s%s() ]\n", smp_processor_id(), __MODULE__, \
-	__MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_INFO	\
-	("~%d:%s%s%s(): ", smp_processor_id(), __MODULE__, \
-	__MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_ERROR	\
-	("~%d:%s%s%s() !ERROR!: ", smp_processor_id(), __MODULE__, \
-	__MOD_DELIMITER__, __func__)
-
-#else
-
-#define _CL_DBG_ENTER	\
-	("%s%s%s() [\n", __MODULE__, __MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_EXIT	\
-	("%s%s%s() ]\n", __MODULE__, __MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_INFO	\
-	("%s%s%s(): ", __MODULE__, __MOD_DELIMITER__, __func__)
-
-#define _CL_DBG_ERROR	\
-	("%s%s%s() !ERROR!: ", __MODULE__, __MOD_DELIMITER__, __func__)
-
-#endif
-
-#ifdef CONFIG_X86
-#define CL_CHK_STK												\
-{																\
-	uint32_t __CL_ESP__;										\
-	__asm__ __volatile__("movl %%esp,%0" : "=r" (__CL_ESP__));	\
-	if (((uint32_t)current + sizeof(struct task_struct) +		\
-		(in_interrupt() ? 300: 1024)) > __CL_ESP__)				\
-	{															\
-		cl_msg_out("stack corruption detected!!!\n");			\
-		cl_msg_out("::::::::esp(0x%x) top(0x%x)::::::::\n",__CL_ESP__,\
-			((uint32_t)current + sizeof(struct task_struct) +	\
-			(in_interrupt() ? 300: 1024)));						\
-		CL_ASSERT (0);											\
-	}															\
-}
-#else
-#define CL_CHK_STK	/* We do not do checks for 64 for now... */
-#endif
-
-
-#else	/* __KERNEL__ */
-
-/* Linux User Mode */
 #include <inttypes.h>
 #include <stdio.h>
 
@@ -215,8 +110,6 @@ void cl_printk( char *message, ... );	/*
 
 #define CL_CHK_STK
 
-#endif	/* __KERNEL__ */
-
 END_C_DECLS
 
 #endif	/* _CL_DEBUG_OSD_H_ */
diff --git a/osm/include/complib/cl_event_osd.h b/osm/include/complib/cl_event_osd.h
index 762cd33..dd497fe 100644
--- a/osm/include/complib/cl_event_osd.h
+++ b/osm/include/complib/cl_event_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -64,29 +64,6 @@
 
 BEGIN_C_DECLS
 
-#ifdef __KERNEL__
-
-/* Linux Kernel Mode. */
-#include <linux/sched.h>
-
-
-/*
- * Linux kernel mode specific data structure for the event object.
- * Users should not access these variables directly.
- */
-typedef struct _cl_event_t
-{
-	wait_queue_head_t	wait_queue;
-	boolean_t			signaled;
-	boolean_t			manual_reset;
-	cl_spinlock_t		spinlock;
-	cl_state_t			state;
-
-} cl_event_t;
-
-#else	/* __KERNEL__ */
-
-/* Linux User Mode. */
 #include <pthread.h>	/* usr/include */
 
 
@@ -104,8 +81,6 @@ typedef struct _cl_event_t
 
 } cl_event_t;
 
-#endif	/* __KERNEL__ */
-
 END_C_DECLS
 
 #endif	/* _CL_EVENT_OSD_H_ */
diff --git a/osm/include/complib/cl_spinlock_osd.h b/osm/include/complib/cl_spinlock_osd.h
index 95afd4e..e8c6d14 100644
--- a/osm/include/complib/cl_spinlock_osd.h
+++ b/osm/include/complib/cl_spinlock_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -61,42 +61,6 @@
 BEGIN_C_DECLS
 
 #include <complib/cl_types.h>
-
-
-#ifdef __KERNEL__
-
-/* Linux Kernel Mode. */
-#include <linux/spinlock.h>
-#include <asm/system.h>
-#include <asm/atomic.h>
-
-typedef enum
-{
-	SPIN_LVL_INVALID,
-	SPIN_LVL_TASKLET,
-	SPIN_LVL_INTERRUPT
-} cl_spin_level_t;
-
-/*
- * Spinlock object definition.
- */
-typedef struct _cl_spinlock_t
-{
-	spinlock_t			lock;
-	unsigned long		flags;
-	cl_state_t			state;
-	cl_spin_level_t		level;
-#ifdef _DEBUG_
-	boolean_t			locked;
-	struct task_struct	*owner;
-	int					cpuid;
-#endif
-
-} cl_spinlock_t;
-
-#else	/* __KERNEL__ */
-
-/* Linux User Mode. */
 #include <pthread.h>			/* usr/include/ */
 
 typedef struct _cl_spinlock_t
@@ -106,8 +70,6 @@ typedef struct _cl_spinlock_t
 
 } cl_spinlock_t;
 
-#endif	/* __KERNEL__ */
-
 END_C_DECLS
 
 #endif /* _CL_SPINLOCK_OSD_H_ */
diff --git a/osm/include/complib/cl_thread_osd.h b/osm/include/complib/cl_thread_osd.h
index 24ee476..9e596a0 100644
--- a/osm/include/complib/cl_thread_osd.h
+++ b/osm/include/complib/cl_thread_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -62,41 +62,6 @@ BEGIN_C_DECLS
 
 #include <complib/cl_types.h>
 #include <complib/cl_event.h>
-
-#ifdef __KERNEL__
-
-/* Linux Kernel Mode. */
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-
-/* bit position 0 for thread wait flag */
-#define THREAD_WAKEUP		(0)
-
-/* Milli Secs per tick, since there are  HZ ticks per second */
-#define MISECS_PER_TICK		(1000/HZ)
-
-/* Linux kernel mode thread object structure definition. */
-typedef struct _cl_thread_osd_t
-{
-	char				name[16];
-	wait_queue_head_t	wqueue;
-	struct task_struct	*task;
-
-	cl_event_t			kill_event;
-	cl_state_t			state;
-
-} cl_thread_osd_t;
-
-
-static inline boolean_t
-cl_is_blockable ( void )
-{
-	return ( (in_interrupt()) ? FALSE : TRUE );
-}
-
-#else	/* __KERNEL__ */
-
-/* Linux User Mode. */
 #include <pthread.h>
 
 /* Linux user mode thread object structure definition. */
@@ -113,8 +78,6 @@ cl_is_blockable ( void )
 	return TRUE;
 }
 
-#endif	/* __KERNEL__ */
-
 END_C_DECLS
 
 #endif	/* _CL_THREAD_OSD_H_ */
diff --git a/osm/include/complib/cl_timer_osd.h b/osm/include/complib/cl_timer_osd.h
index 85738fa..abab65d 100644
--- a/osm/include/complib/cl_timer_osd.h
+++ b/osm/include/complib/cl_timer_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -63,25 +63,6 @@
 
 BEGIN_C_DECLS
 
-#ifdef __KERNEL__
-
-/* Linux Kernel Mode. */
-#include <linux/timer.h>
-
-
-typedef struct _cl_timer_t
-{
-	struct timer_list		timer;
-	cl_state_t				state;
-	cl_pfn_timer_callback_t	pfn_callback;
-	const void				*context;
-	boolean_t				in_timer_cb;
-
-} cl_timer_t;
-
-#else	/* __KERNEL__ */
-
-/* Linux User Mode. */
 #include <complib/cl_qlist.h>
 #include <pthread.h>
 
@@ -116,8 +97,6 @@ __cl_timer_prov_create( void );
 void
 __cl_timer_prov_destroy( void );
 
-#endif	/* __KERNEL__ */
-
 END_C_DECLS
 
 #endif	/* _CL_TIMER_OSD_H_ */
diff --git a/osm/include/complib/cl_types_osd.h b/osm/include/complib/cl_types_osd.h
index 84b07d5..a6ab980 100644
--- a/osm/include/complib/cl_types_osd.h
+++ b/osm/include/complib/cl_types_osd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
@@ -73,100 +73,6 @@ BEGIN_C_DECLS
 #define cl_break
 #endif
 
-#ifdef __KERNEL__
-#include <linux/config.h>
-
-/*
- * Linux Kernel Mode
- */
-
-#if defined (_DEBUG_) && defined (CONFIG_X86_REMOTE_DEBUG)
-#define CONFIG_GDB
-#endif
-
-#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
-#define MODVERSIONS		/* turn it on */
-#endif
-
-#ifdef MODVERSIONS
-#include <linux/modversions.h>
-#endif
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/init.h>
-
-#ifndef LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif
-
-#if defined (_DEBUG_)
-
-#if defined (CONFIG_GDB)
-extern int gdb_initialized;
-
-#define CL_ASSERT( __exp__ )										\
-{																\
-	if( !(__exp__) )											\
-	{															\
-		if (!gdb_initialized)									\
-		{														\
-			panic( "Assertion failed: %s, file %s, line %d\n",	\
-					#__exp__, __FILE__, __LINE__ );				\
-		}														\
-		else													\
-		{														\
-			printk( "Assertion failed: %s, file %s, line %d\n",	\
-					#__exp__, __FILE__, __LINE__ );				\
-			printk ("Entering GDB...\n");						\
-			cl_break();											\
-		}														\
-	}															\
-}
-#elif defined (CONFIG_KDB) /* not CONFIG_GDB */
-#include <linux/kdb.h>
-#undef cl_break
-#define cl_break()	KDB_ENTER()
-
-#define CL_ASSERT( __exp__ )										\
-{																\
-	if( !(__exp__) )											\
-	{															\
-			printk( "Assertion failed: %s, file %s, line %d\n",	\
-					#__exp__, __FILE__, __LINE__ );				\
-			printk ("Entering KDB...\n");						\
-			cl_break();											\
-	}															\
-}
-#else /* not CONFIG_GDB and not CONFIG_KDB */
-#undef cl_break
-#define cl_break()
-
-#define CL_ASSERT( __exp__ )									\
-{															\
-	if( !(__exp__) )										\
-	{														\
-		panic( "Assertion failed: %s, file %s, line %d\n",	\
-				#__exp__, __FILE__, __LINE__ );				\
-	}														\
-}
-#endif /* CONFIG_GDB */
-
-#else /* not _DEBUG_ */
-#undef cl_break
-#define cl_break()
-#define CL_ASSERT( __exp__ )
-#endif	/* _DEBUG_ */
-
-#define cl_panic	panic
-
-#else	/* __KERNEL__ */
-
-/*
- * Linux User Mode
- */
 #include <inttypes.h>
 #include <assert.h>
 #include <string.h>
@@ -178,14 +84,12 @@ extern int gdb_initialized;
 #define CL_ASSERT( __exp__ )
 #endif	/* _DEBUG_ */
 
-#endif /* __KERNEL__ */
-
 /*
  * Types not explicitly defined are native to the platform.
  */
 typedef unsigned long		uintn_t;
-typedef long				intn_t;
-typedef int					boolean_t;
+typedef long			intn_t;
+typedef int			boolean_t;
 typedef volatile int32_t	atomic32_t;
 
 #ifndef NULL



More information about the general mailing list