• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
4  */
5 
6 #include <pthread.h>
7 #include <stdio.h>
8 
9 #define TST_NO_DEFAULT_MAIN
10 #include "tst_test.h"
11 
safe_pthread_create(const char * file,const int lineno,pthread_t * thread_id,const pthread_attr_t * attr,void * (* thread_fn)(void *),void * arg)12 int safe_pthread_create(const char *file, const int lineno,
13 			pthread_t *thread_id, const pthread_attr_t *attr,
14 			void *(*thread_fn)(void *), void *arg)
15 {
16 	int rval;
17 
18 	rval = pthread_create(thread_id, attr, thread_fn, arg);
19 
20 	if (rval) {
21 		tst_brk_(file, lineno, TBROK,
22 			 "pthread_create(%p,%p,%p,%p) failed: %s", thread_id,
23 			 attr, thread_fn, arg, tst_strerrno(rval));
24 	}
25 
26 	return rval;
27 }
28 
safe_pthread_join(const char * file,const int lineno,pthread_t thread_id,void ** retval)29 int safe_pthread_join(const char *file, const int lineno,
30 		      pthread_t thread_id, void **retval)
31 {
32 	int rval;
33 
34 	rval = pthread_join(thread_id, retval);
35 
36 	if (rval) {
37 		tst_brk_(file, lineno, TBROK,
38 			 "pthread_join(..., %p) failed: %s",
39 			 retval, tst_strerrno(rval));
40 	}
41 
42 	return rval;
43 }
44