1+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12/*
23 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34 * University Research and Technology
1718 *
1819 * $HEADER$
1920 */
21+
2022#include <unistd.h>
2123
2224#include "opal/mca/threads/argobots/threads_argobots.h"
@@ -51,47 +53,53 @@ OBJ_CLASS_INSTANCE(opal_thread_t,
5153 opal_object_t ,
5254 opal_thread_construct , NULL );
5355
54- static inline ABT_thread opal_thread_get_argobots_self (void ) {
56+ static inline ABT_thread opal_thread_get_argobots_self (void )
57+ {
5558 ABT_thread self ;
5659 ABT_thread_self (& self );
5760 return self ;
5861}
5962
60- static void opal_thread_argobots_wrapper (void * arg ) {
61- opal_thread_t * t = (opal_thread_t * ) arg ;
62- t -> t_ret = ((void * (* )(void * )) t -> t_run )(t );
63+ static void opal_thread_argobots_wrapper (void * arg )
64+ {
65+ opal_thread_t * t = (opal_thread_t * )arg ;
66+ t -> t_ret = ((void * (* )(void * ))t -> t_run )(t );
6367}
6468
6569opal_thread_t * opal_thread_get_self (void )
6670{
67- ensure_init_argobots ();
71+ opal_threads_argobots_ensure_init ();
6872 opal_thread_t * t = OBJ_NEW (opal_thread_t );
6973 t -> t_handle = opal_thread_get_argobots_self ();
7074 return t ;
7175}
7276
7377bool opal_thread_self_compare (opal_thread_t * t )
7478{
75- ensure_init_argobots ();
76- return t -> t_handle == opal_thread_get_argobots_self () ;
79+ opal_threads_argobots_ensure_init ();
80+ return opal_thread_get_argobots_self () == t -> t_handle ;
7781}
7882
79- int opal_thread_join (opal_thread_t * t , void * * thr_return ) {
80- ensure_init_argobots ();
83+ int opal_thread_join (opal_thread_t * t , void * * thr_return )
84+ {
85+ opal_threads_argobots_ensure_init ();
8186 int rc = ABT_thread_free (& t -> t_handle );
82- if (thr_return )
87+ if (thr_return ) {
8388 * thr_return = t -> t_ret ;
89+ }
8490 t -> t_handle = ABT_THREAD_NULL ;
85- return (rc == 0 ) ? OPAL_SUCCESS : OPAL_ERROR ;
91+ return (0 == rc ) ? OPAL_SUCCESS : OPAL_ERROR ;
8692}
8793
88- void opal_thread_set_main () {
89- ensure_init_argobots ();
94+ void opal_thread_set_main ()
95+ {
96+ opal_threads_argobots_ensure_init ();
9097 opal_main_thread = opal_thread_get_argobots_self ();
9198}
9299
93- int opal_thread_start (opal_thread_t * t ) {
94- ensure_init_argobots ();
100+ int opal_thread_start (opal_thread_t * t )
101+ {
102+ opal_threads_argobots_ensure_init ();
95103 int rc ;
96104 if (OPAL_ENABLE_DEBUG ) {
97105 if (NULL == t -> t_run || t -> t_handle != ABT_THREAD_NULL ) {
@@ -105,32 +113,35 @@ int opal_thread_start(opal_thread_t *t) {
105113 opal_thread_argobots_wrapper , t ,
106114 ABT_THREAD_ATTR_NULL , & t -> t_handle );
107115
108- return (rc == 0 ) ? OPAL_SUCCESS : OPAL_ERROR ;
116+ return (0 == rc ) ? OPAL_SUCCESS : OPAL_ERROR ;
109117}
110118
111119opal_class_t opal_thread_t_class ;
112120
113121int opal_tsd_key_create (opal_tsd_key_t * key , opal_tsd_destructor_t destructor )
114122{
115- ensure_init_argobots ();
123+ opal_threads_argobots_ensure_init ();
116124 int rc ;
117125 rc = ABT_key_create (destructor , key );
118126 if ((0 == rc ) && (opal_thread_get_argobots_self () == opal_main_thread )) {
119- opal_tsd_key_values = (struct opal_tsd_key_value * )realloc (opal_tsd_key_values , (opal_tsd_key_values_count + 1 ) * sizeof (struct opal_tsd_key_value ));
127+ opal_tsd_key_values = (struct opal_tsd_key_value * )
128+ realloc (opal_tsd_key_values , (opal_tsd_key_values_count + 1 ) *
129+ sizeof (struct opal_tsd_key_value ));
120130 opal_tsd_key_values [opal_tsd_key_values_count ].key = * key ;
121131 opal_tsd_key_values [opal_tsd_key_values_count ].destructor = destructor ;
122- opal_tsd_key_values_count ++ ;
132+ opal_tsd_key_values_count ++ ;
123133 }
124134 return rc ;
125135}
126136
127137int opal_tsd_keys_destruct (void )
128138{
129- ensure_init_argobots ();
139+ opal_threads_argobots_ensure_init ();
130140 int i ;
131- void * ptr ;
132- for (i = 0 ; i < opal_tsd_key_values_count ; i ++ ) {
133- if (OPAL_SUCCESS == opal_tsd_getspecific (opal_tsd_key_values [i ].key , & ptr )) {
141+ void * ptr ;
142+ for (i = 0 ; i < opal_tsd_key_values_count ; i ++ ) {
143+ if (OPAL_SUCCESS ==
144+ opal_tsd_getspecific (opal_tsd_key_values [i ].key , & ptr )) {
134145 if (NULL != opal_tsd_key_values [i ].destructor ) {
135146 opal_tsd_key_values [i ].destructor (ptr );
136147 opal_tsd_setspecific (opal_tsd_key_values [i ].key , NULL );
0 commit comments