1 /* $NetBSD: once.h,v 1.1 2024/02/18 20:57:56 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 #ifndef ISC_ONCE_H 17 #define ISC_ONCE_H 1 18 19 /*! \file */ 20 21 #include <pthread.h> 22 23 #include <isc/platform.h> 24 #include <isc/result.h> 25 26 typedef pthread_once_t isc_once_t; 27 28 #define ISC_ONCE_INIT PTHREAD_ONCE_INIT 29 30 /* XXX We could do fancier error handling... */ 31 32 #define isc_once_do(op, f) \ 33 ((pthread_once((op), (f)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) 34 35 #endif /* ISC_ONCE_H */ 36