Our wrapper function for the real pthread_create() */
| 82 | |
| 83 | /* Our wrapper function for the real pthread_create() */ |
| 84 | int pthread_create(pthread_t *__restrict thread, |
| 85 | __const pthread_attr_t *__restrict attr, |
| 86 | void * (*start_routine)(void *), |
| 87 | void *__restrict arg) |
| 88 | { |
| 89 | wrapper_t wrapper_data; |
| 90 | int i_return; |
| 91 | |
| 92 | /* Initialize the wrapper structure */ |
| 93 | wrapper_data.start_routine = start_routine; |
| 94 | wrapper_data.arg = arg; |
| 95 | getitimer(ITIMER_PROF, &wrapper_data.itimer); |
| 96 | pthread_cond_init(&wrapper_data.wait, NULL); |
| 97 | pthread_mutex_init(&wrapper_data.lock, NULL); |
| 98 | pthread_mutex_lock(&wrapper_data.lock); |
| 99 | |
| 100 | /* The real pthread_create call */ |
| 101 | i_return = pthread_create_orig(thread, |
| 102 | attr, |
| 103 | &wrapper_routine, |
| 104 | &wrapper_data); |
| 105 | |
| 106 | /* If the thread was successfully spawned, wait for the data |
| 107 | * to be released */ |
| 108 | if(i_return == 0) |
| 109 | { |
| 110 | pthread_cond_wait(&wrapper_data.wait, &wrapper_data.lock); |
| 111 | } |
| 112 | |
| 113 | pthread_mutex_unlock(&wrapper_data.lock); |
| 114 | pthread_mutex_destroy(&wrapper_data.lock); |
| 115 | pthread_cond_destroy(&wrapper_data.wait); |
| 116 | |
| 117 | return i_return; |
| 118 | } |
| 119 |
no outgoing calls
no test coverage detected