2000-12-29 01:29:56 +00:00
|
|
|
/*
|
2011-01-04 23:47:14 +00:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-12-29 01:29:56 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2000-12-29 01:29:56 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
2000-12-29 01:29:56 +00:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
2000-12-29 01:29:56 +00:00
|
|
|
|
2005-07-12 01:00:20 +00:00
|
|
|
#include <errno.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2000-12-29 01:29:56 +00:00
|
|
|
#include <stdio.h>
|
2020-03-09 16:17:26 +01:00
|
|
|
#include <sys/time.h>
|
2000-12-29 01:29:56 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include <isc/mutex.h>
|
|
|
|
#include <isc/once.h>
|
2018-08-28 15:43:44 -07:00
|
|
|
#include <isc/strerr.h>
|
|
|
|
#include <isc/string.h>
|
2015-02-26 14:43:45 +05:30
|
|
|
#include <isc/util.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
|
2022-07-13 13:19:32 +02:00
|
|
|
#include "mutex_p.h"
|
|
|
|
|
|
|
|
pthread_mutexattr_t isc__mutex_init_attr;
|
|
|
|
static isc_once_t init_once = ISC_ONCE_INIT;
|
2015-02-26 14:43:45 +05:30
|
|
|
|
|
|
|
static void
|
2022-07-13 13:19:32 +02:00
|
|
|
mutex_initialize(void) {
|
|
|
|
RUNTIME_CHECK(pthread_mutexattr_init(&isc__mutex_init_attr) == 0);
|
2024-02-05 09:03:41 +01:00
|
|
|
#if ISC_MUTEX_ERROR_CHECK && defined(PTHREAD_MUTEX_ERRORCHECK_NP)
|
|
|
|
RUNTIME_CHECK(pthread_mutexattr_settype(&isc__mutex_init_attr,
|
|
|
|
PTHREAD_MUTEX_ERRORCHECK_NP) ==
|
|
|
|
0);
|
|
|
|
#elif defined(PTHREAD_MUTEX_ADAPTIVE_NP)
|
2022-07-13 13:19:32 +02:00
|
|
|
RUNTIME_CHECK(pthread_mutexattr_settype(&isc__mutex_init_attr,
|
|
|
|
PTHREAD_MUTEX_ADAPTIVE_NP) ==
|
|
|
|
0);
|
2015-02-26 14:43:45 +05:30
|
|
|
#endif /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
|
2022-07-13 13:19:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
isc__mutex_initialize(void) {
|
2022-10-14 16:10:41 +02:00
|
|
|
isc_once_do(&init_once, mutex_initialize);
|
2022-07-13 13:19:32 +02:00
|
|
|
}
|
2015-02-26 14:43:45 +05:30
|
|
|
|
2022-07-13 13:19:32 +02:00
|
|
|
void
|
|
|
|
isc__mutex_shutdown(void) {
|
|
|
|
/* noop */;
|
|
|
|
}
|