1 /* $NetBSD: tid.h,v 1.2 2025/01/26 16:25:43 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 #include <inttypes.h> 19 20 #include <isc/lang.h> 21 #include <isc/thread.h> 22 23 ISC_LANG_BEGINDECLS 24 25 #define ISC_TID_UNKNOWN UINT32_MAX 26 27 uint32_t 28 isc_tid_count(void); 29 /*%< 30 * Returns the number of threads. 31 */ 32 33 extern thread_local uint32_t isc__tid_local; 34 35 static inline uint32_t 36 isc_tid(void) { 37 return isc__tid_local; 38 } 39 /*%< 40 * Returns the thread ID of the currently-running loop. 41 */ 42 43 /* Private */ 44 45 void 46 isc__tid_init(uint32_t tid); 47 48 void 49 isc__tid_initcount(uint32_t count); 50 51 ISC_LANG_ENDDECLS 52