@@ -106,3 +106,164 @@ int safe_pthread_barrier_init(const char *file, const int lineno,
106106
107107 return rval ;
108108}
109+
110+ int safe_pthread_mutexattr_init (const char * file , const int lineno ,
111+ pthread_mutexattr_t * attr )
112+ {
113+ int ret ;
114+
115+ ret = pthread_mutexattr_init (attr );
116+
117+ if (ret ) {
118+ tst_brk_ (file , lineno , TBROK ,
119+ "pthread_mutexattr_init(%p) failed: %s" ,
120+ attr , tst_strerrno (ret ));
121+ }
122+
123+ return ret ;
124+ }
125+
126+ int safe_pthread_mutexattr_destroy (const char * file , const int lineno ,
127+ pthread_mutexattr_t * attr )
128+ {
129+ int ret ;
130+
131+ ret = pthread_mutexattr_destroy (attr );
132+
133+ if (ret ) {
134+ tst_brk_ (file , lineno , TBROK ,
135+ "pthread_mutexattr_destroy(%p) failed: %s" ,
136+ attr , tst_strerrno (ret ));
137+ }
138+
139+ return ret ;
140+ }
141+
142+ int safe_pthread_mutexattr_settype (const char * file , const int lineno ,
143+ pthread_mutexattr_t * attr , int type )
144+ {
145+ int ret ;
146+
147+ ret = pthread_mutexattr_settype (attr , type );
148+
149+ if (ret ) {
150+ tst_brk_ (file , lineno , TBROK ,
151+ "pthread_mutexattr_settype(%p, %d) failed: %s" ,
152+ attr , type , tst_strerrno (ret ));
153+ }
154+
155+ return ret ;
156+ }
157+
158+ int safe_pthread_mutex_init (const char * file , const int lineno ,
159+ pthread_mutex_t * mutex , const pthread_mutexattr_t * attr )
160+ {
161+ int ret ;
162+
163+ ret = pthread_mutex_init (mutex , attr );
164+
165+ if (ret ) {
166+ tst_brk_ (file , lineno , TBROK ,
167+ "pthread_mutex_init(%p, %p) failed: %s" ,
168+ mutex , attr , tst_strerrno (ret ));
169+ }
170+
171+ return ret ;
172+ }
173+
174+ int safe_pthread_mutex_destroy (const char * file , const int lineno ,
175+ pthread_mutex_t * mutex )
176+ {
177+ int ret ;
178+
179+ ret = pthread_mutex_destroy (mutex );
180+
181+ if (ret ) {
182+ tst_brk_ (file , lineno , TBROK ,
183+ "pthread_mutex_destroy(%p) failed: %s" ,
184+ mutex , tst_strerrno (ret ));
185+ }
186+
187+ return ret ;
188+ }
189+
190+ int safe_pthread_mutex_lock (const char * file , const int lineno ,
191+ pthread_mutex_t * mutex )
192+ {
193+ int ret ;
194+
195+ ret = pthread_mutex_lock (mutex );
196+
197+ if (ret ) {
198+ tst_brk_ (file , lineno , TBROK ,
199+ "pthread_mutex_lock(%p) failed: %s" ,
200+ mutex , tst_strerrno (ret ));
201+ }
202+
203+ return ret ;
204+ }
205+
206+ int safe_pthread_mutex_trylock (const char * file , const int lineno ,
207+ pthread_mutex_t * mutex )
208+ {
209+ int ret ;
210+
211+ ret = pthread_mutex_trylock (mutex );
212+
213+ if (ret && ret != EBUSY ) {
214+ tst_brk_ (file , lineno , TBROK ,
215+ "pthread_mutex_trylock(%p) failed: %s" ,
216+ mutex , tst_strerrno (ret ));
217+ }
218+
219+ return ret ;
220+ }
221+
222+ int safe_pthread_mutex_timedlock (const char * file , const int lineno ,
223+ pthread_mutex_t * mutex , const struct timespec * abstime )
224+ {
225+ int ret ;
226+
227+ ret = pthread_mutex_timedlock (mutex , abstime );
228+
229+ if (ret && ret != ETIMEDOUT ) {
230+ tst_brk_ (file , lineno , TBROK ,
231+ "pthread_mutex_timedlock(%p, {%lld, %ld}) failed: %s" ,
232+ mutex , (long long )abstime -> tv_sec , abstime -> tv_nsec ,
233+ tst_strerrno (ret ));
234+ }
235+
236+ return ret ;
237+ }
238+
239+ int safe_pthread_mutex_unlock (const char * file , const int lineno ,
240+ pthread_mutex_t * mutex )
241+ {
242+ int ret ;
243+
244+ ret = pthread_mutex_unlock (mutex );
245+
246+ if (ret ) {
247+ tst_brk_ (file , lineno , TBROK ,
248+ "pthread_mutex_unlock(%p) failed: %s" ,
249+ mutex , tst_strerrno (ret ));
250+ }
251+
252+ return ret ;
253+ }
254+
255+ int safe_pthread_kill (const char * file , const int lineno ,
256+ pthread_t thread , int sig )
257+ {
258+ int ret ;
259+
260+ ret = pthread_kill (thread , sig );
261+
262+ if (ret ) {
263+ tst_brk_ (file , lineno , TBROK ,
264+ "pthread_kill(..., %d) failed: %s" ,
265+ sig , tst_strerrno (ret ));
266+ }
267+
268+ return ret ;
269+ }
0 commit comments