-#ifdef __KERNEL__
-
-static inline void
-lnet_res_lock(void)
-{
- cfs_spin_lock(&the_lnet.ln_res_lock);
-}
-
-static inline void
-lnet_res_unlock(void)
-{
- cfs_spin_unlock(&the_lnet.ln_res_lock);
-}
-
-#define LNET_LOCK() cfs_spin_lock(&the_lnet.ln_lock)
-#define LNET_UNLOCK() cfs_spin_unlock(&the_lnet.ln_lock)
-#define LNET_MUTEX_LOCK(m) cfs_mutex_lock(m)
-#define LNET_MUTEX_UNLOCK(m) cfs_mutex_unlock(m)
-#else
-# ifndef HAVE_LIBPTHREAD
-#define LNET_SINGLE_THREADED_LOCK(l) \
-do { \
- LASSERT ((l) == 0); \
- (l) = 1; \
-} while (0)
-
-#define LNET_SINGLE_THREADED_UNLOCK(l) \
-do { \
- LASSERT ((l) == 1); \
- (l) = 0; \
-} while (0)
-
-#define LNET_LOCK() LNET_SINGLE_THREADED_LOCK(the_lnet.ln_lock)
-#define LNET_UNLOCK() LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_lock)
-#define LNET_MUTEX_LOCK(m) LNET_SINGLE_THREADED_LOCK(*(m))
-#define LNET_MUTEX_UNLOCK(m) LNET_SINGLE_THREADED_UNLOCK(*(m))
-
-#define lnet_res_lock() \
- LNET_SINGLE_THREADED_LOCK(the_lnet.ln_res_lock)
-#define lnet_res_unlock() \
- LNET_SINGLE_THREADED_UNLOCK(the_lnet.ln_res_lock)
-
-# else
-#define LNET_LOCK() pthread_mutex_lock(&the_lnet.ln_lock)
-#define LNET_UNLOCK() pthread_mutex_unlock(&the_lnet.ln_lock)
-#define LNET_MUTEX_LOCK(m) pthread_mutex_lock(m)
-#define LNET_MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
-#define lnet_res_lock() pthread_mutex_lock(&the_lnet.ln_res_lock)
-#define lnet_res_unlock() pthread_mutex_unlock(&the_lnet.ln_res_lock)
-
-# endif
-#endif
-
-#define MAX_PORTALS 64
-
-/* these are only used by code with LNET_USE_LIB_FREELIST, but we still
- * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */
-#define LNET_FL_MAX_MES 2048
-#define LNET_FL_MAX_MDS 2048
-#define LNET_FL_MAX_EQS 512
-#define LNET_FL_MAX_MSGS 2048 /* Outstanding messages */
-
-#ifdef LNET_USE_LIB_FREELIST
-
-int lnet_freelist_init(lnet_freelist_t *fl, int n, int size);
-void lnet_freelist_fini(lnet_freelist_t *fl);
-
-static inline void *
-lnet_freelist_alloc (lnet_freelist_t *fl)
-{
- /* ALWAYS called with liblock held */
- lnet_freeobj_t *o;
-
- if (cfs_list_empty (&fl->fl_list))
- return (NULL);
-
- o = cfs_list_entry (fl->fl_list.next, lnet_freeobj_t, fo_list);
- cfs_list_del (&o->fo_list);
- return ((void *)&o->fo_contents);
-}
-
-static inline void
-lnet_freelist_free (lnet_freelist_t *fl, void *obj)
-{
- /* ALWAYS called with liblock held */
- lnet_freeobj_t *o = cfs_list_entry (obj, lnet_freeobj_t, fo_contents);
-
- cfs_list_add (&o->fo_list, &fl->fl_list);
-}
-