1
1

As requested move back the alloc and return to macros instead of static inlined functions.

This commit was SVN r8762.
Этот коммит содержится в:
George Bosilca 2006-01-19 23:58:04 +00:00
родитель d5d16c2162
Коммит 29c80875a8

Просмотреть файл

@ -298,55 +298,59 @@ static inline void mca_bml_base_prepare_dst(mca_bml_base_btl_t* bml_btl,
} }
} }
static inline mca_btl_base_descriptor_t*
mca_bml_base_btl_des_alloc( mca_bml_base_btl_t* bml_btl,
size_t alloc_size,
size_t seg_size )
{
mca_btl_base_descriptor_t* des;
if( NULL != (des = bml_btl->btl_cache) ) {
#if OMPI_HAVE_THREAD_SUPPORT #if OMPI_HAVE_THREAD_SUPPORT
/* atomically acquire the cached descriptor */ #define MCA_BML_BASE_BTL_DES_ALLOC(bml_btl, des, alloc_size, seg_size) \
if(opal_atomic_cmpset_ptr(&bml_btl->btl_cache, des, NULL) == 0) { do { \
des = bml_btl->btl_alloc(bml_btl->btl, alloc_size); mca_btl_base_descriptor_t* des; \
} \
if( NULL != (des = bml_btl->btl_cache) ) { \
/* atomically acquire the cached descriptor */ \
if(opal_atomic_cmpset_ptr(&bml_btl->btl_cache, \
des, NULL) == 0) { \
des = bml_btl->btl_alloc(bml_btl->btl, alloc_size); \
} \
} else { \
des = bml_btl->btl_alloc(bml_btl->btl, alloc_size); \
} \
des->des_src->seg_len = seg_size; \
des->des_context = (void*) bml_btl; \
} while(0)
#else #else
bml_btl->btl_cache = NULL; #define MCA_BML_BASE_BTL_DES_ALLOC(bml_btl, des, alloc_size, seg_size) \
#endif do { \
} else { mca_btl_base_descriptor_t* des; \
des = bml_btl->btl_alloc(bml_btl->btl, alloc_size); \
} if( NULL != (des = bml_btl->btl_cache) ) { \
des->des_src->seg_len = seg_size; bml_btl->btl_cache = NULL; \
des->des_context = (void*) bml_btl; } else { \
return des; des = bml_btl->btl_alloc(bml_btl->btl, alloc_size); \
} } \
#define MCA_BML_BASE_BTL_DES_ALLOC(bml_btl, des, alloc_size, seg_size) \ des->des_src->seg_len = seg_size; \
des = mca_bml_base_btl_des_alloc( bml_btl, alloc_size, seg_size ) des->des_context = (void*) bml_btl; \
} while(0)
#endif /* OMPI_HAVE_THREAD_SUPPORT */
/** /**
* Return a descriptor * Return a descriptor
*/ */
static inline void mca_bml_base_btl_des_return( mca_bml_base_btl_t* bml_btl,
mca_btl_base_descriptor_t* des)
{
#if OMPI_HAVE_THREAD_SUPPORT #if OMPI_HAVE_THREAD_SUPPORT
if( opal_atomic_cmpset_ptr(&bml_btl->btl_cache,NULL,des) == 0 ) { #define MCA_BML_BASE_BTL_DES_RETURN( bml_btl, descriptor ) \
do { \
if( opal_atomic_cmpset_ptr(&bml_btl->btl_cache, \
NULL,descriptor) == 0 ) { \
bml_btl->btl_free( bml_btl->btl, descriptor ); \
} \
} while (0)
#else #else
if( NULL == bml_btl->btl_cache ) {
bml_btl->btl_cache = des;
} else {
#endif
bml_btl->btl_free( bml_btl->btl, des );
}
}
#define MCA_BML_BASE_BTL_DES_RETURN( bml_btl, descriptor ) \ #define MCA_BML_BASE_BTL_DES_RETURN( bml_btl, descriptor ) \
do { \ do { \
mca_bml_base_btl_des_return( bml_btl, descriptor ); \ if( NULL == bml_btl->btl_cache ) { \
descriptor = NULL; \ bml_btl->btl_cache = descriptor; \
} while(0) } else { \
bml_btl->btl_free( bml_btl->btl, descriptor ); \
} \
} while(0)
#endif /* OMPI_HAVE_THREAD_SUPPORT */
/* /*
* BML component interface functions and datatype. * BML component interface functions and datatype.