Home | History | Annotate | Line # | Download | only in isc
      1 /*	$NetBSD: mutex.c,v 1.3 2025/01/26 16:25:37 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 /*! \file */
     17 
     18 #include <errno.h>
     19 #include <stdbool.h>
     20 #include <stdio.h>
     21 #include <sys/time.h>
     22 #include <time.h>
     23 
     24 #include <isc/mutex.h>
     25 #include <isc/once.h>
     26 #include <isc/strerr.h>
     27 #include <isc/string.h>
     28 #include <isc/util.h>
     29 
     30 #include "mutex_p.h"
     31 
     32 pthread_mutexattr_t isc__mutex_init_attr;
     33 static isc_once_t init_once = ISC_ONCE_INIT;
     34 
     35 static void
     36 mutex_initialize(void) {
     37 	RUNTIME_CHECK(pthread_mutexattr_init(&isc__mutex_init_attr) == 0);
     38 #if ISC_MUTEX_ERROR_CHECK
     39 	RUNTIME_CHECK(pthread_mutexattr_settype(&isc__mutex_init_attr,
     40 						PTHREAD_MUTEX_ERRORCHECK) == 0);
     41 #elif HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
     42 	RUNTIME_CHECK(pthread_mutexattr_settype(&isc__mutex_init_attr,
     43 						PTHREAD_MUTEX_ADAPTIVE_NP) ==
     44 		      0);
     45 #endif
     46 }
     47 
     48 void
     49 isc__mutex_initialize(void) {
     50 	isc_once_do(&init_once, mutex_initialize);
     51 }
     52 
     53 void
     54 isc__mutex_shutdown(void) {
     55 	/* noop */;
     56 }
     57