Branch data Line data Source code
1 : : // Copyright 2012-2020 David Robillard <d@drobilla.net> 2 : : // SPDX-License-Identifier: ISC 3 : : 4 : : #include <zix/thread.h> 5 : : 6 : : #include "../errno_status.h" 7 : : 8 : : #include <zix/status.h> 9 : : 10 : : #include <pthread.h> 11 : : 12 : : #include <stddef.h> 13 : : 14 : : ZixStatus 15 : 9 : zix_thread_create(ZixThread* thread, 16 : : size_t stack_size, 17 : : ZixThreadFunc function, 18 : : void* arg) 19 : : { 20 : : pthread_attr_t attr; 21 : 9 : pthread_attr_init(&attr); 22 : 9 : pthread_attr_setstacksize(&attr, stack_size); 23 : : 24 : 9 : const int ret = pthread_create(thread, NULL, function, arg); 25 : : 26 : 9 : pthread_attr_destroy(&attr); 27 : 9 : return zix_errno_status(ret); 28 : : } 29 : : 30 : : ZixStatus 31 : 9 : zix_thread_join(ZixThread thread) 32 : : { 33 : 9 : return pthread_join(thread, NULL) ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; 34 : : }