1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * SPDX-License-Identifier: MPL-2.0 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 #ifndef ISC_ONCE_H 15 #define ISC_ONCE_H 1 16 17 /*! \file */ 18 19 #include <pthread.h> 20 21 #include <isc/platform.h> 22 #include <isc/result.h> 23 24 typedef pthread_once_t isc_once_t; 25 26 #define ISC_ONCE_INIT PTHREAD_ONCE_INIT 27 28 /* XXX We could do fancier error handling... */ 29 30 #define isc_once_do(op, f) \ 31 ((pthread_once((op), (f)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) 32 33 #endif /* ISC_ONCE_H */ 34