1 /* $NetBSD: thread.h,v 1.2 2024/02/21 22:52:31 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #pragma once 17 18 /*! \file */ 19 20 #include <pthread.h> 21 #if HAVE_THREADS_H 22 #include <threads.h> 23 #endif 24 25 #if defined(HAVE_PTHREAD_NP_H) 26 #include <pthread_np.h> 27 #endif /* if defined(HAVE_PTHREAD_NP_H) */ 28 29 #include <isc/lang.h> 30 #include <isc/result.h> 31 32 extern thread_local size_t isc_tid_v; 33 34 ISC_LANG_BEGINDECLS 35 36 typedef pthread_t isc_thread_t; 37 typedef void *isc_threadresult_t; 38 typedef void *isc_threadarg_t; 39 typedef isc_threadresult_t (*isc_threadfunc_t)(isc_threadarg_t); 40 41 void 42 isc_thread_create(isc_threadfunc_t, isc_threadarg_t, isc_thread_t *); 43 44 void 45 isc_thread_join(isc_thread_t thread, isc_threadresult_t *result); 46 47 void 48 isc_thread_yield(void); 49 50 void 51 isc_thread_setname(isc_thread_t thread, const char *name); 52 53 #define isc_thread_self (uintptr_t) pthread_self 54 55 ISC_LANG_ENDDECLS 56