Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] RFC: Add static initializer for opal_mutex_t
From: Jeff Squyres (jsquyres) (jsquyres_at_[hidden])
Date: 2013-06-07 12:08:26


Nathan forgot to mention that we didn't have this before because of Windows. But now we don't have Windows support, so...

On Jun 7, 2013, at 9:01 AM, "Hjelm, Nathan T" <hjelmn_at_[hidden]> wrote:

> What: Add a static initializer for opal_mutex_t for both posix and solaris threads.
>
> Why: Enables the use of opal locks that don't have to be OBJ_CONSTRUCT'ed.
>
> When: This is a trivial addition but I would like some review/testing of the code (I don't have solaris). Setting timeout to Tuesday, June 11, 2013
>
>
> diff --git a/opal/threads/mutex_unix.h b/opal/threads/mutex_unix.h
> index 27528e6..28b1744 100644
> --- a/opal/threads/mutex_unix.h
> +++ b/opal/threads/mutex_unix.h
> @@ -81,6 +81,25 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_mutex_t);
> * POSIX threads
> ************************************************************************/
>
> +#if !OPAL_ENABLE_MULTI_THREADS && OPAL_ENABLE_DEBUG
> +#define OPAL_MUTEX_STATIC_INIT \
> + { \
> + .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
> + .m_lock_pthread = PTHREAD_MUTEX_INITIALIZER, \
> + .m_lock_debug = 0, \
> + .m_lock_file = NULL, \
> + .m_lock_line = 0, \
> + .m_lock_atomic = 0 \
> + }
> +#else
> +#define OPAL_MUTEX_STATIC_INIT \
> + { \
> + .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
> + .m_lock_pthread = PTHREAD_MUTEX_INITIALIZER, \
> + .m_lock_atomic = 0 \
> + }
> +#endif
> +
> static inline int opal_mutex_trylock(opal_mutex_t *m)
> {
> #if OPAL_ENABLE_DEBUG
> @@ -130,6 +149,25 @@ static inline void opal_mutex_unlock(opal_mutex_t *m)
> * Solaris threads
> ************************************************************************/
>
> +#if !OPAL_ENABLE_MULTI_THREADS && OPAL_ENABLE_DEBUG
> +#define OPAL_MUTEX_STATIC_INIT \
> + { \
> + .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
> + .m_lock_solaris = DEFAULTMUTEX, \
> + .m_lock_debug = 0, \
> + .m_lock_file = NULL, \
> + .m_lock_line = 0, \
> + .m_lock_atomic = 0 \
> + }
> +#else
> +#define OPAL_MUTEX_STATIC_INIT \
> + { \
> + .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
> + .m_lock_solaris = DEFAULTMUTEX, \
> + .m_lock_atomic = 0 \
> + }
> +#endif
> +
>
> static inline int opal_mutex_trylock(opal_mutex_t *m)
> {
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/