xref: /netbsd-src/external/mpl/bind/dist/lib/isc/lib.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: lib.c,v 1.12 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 <isc/hash.h>
19 #include <isc/iterated_hash.h>
20 #include <isc/md.h>
21 #include <isc/mem.h>
22 #include <isc/os.h>
23 #include <isc/tls.h>
24 #include <isc/urcu.h>
25 #include <isc/util.h>
26 #include <isc/uv.h>
27 #include <isc/xml.h>
28 
29 #include "config.h"
30 #include "mem_p.h"
31 #include "mutex_p.h"
32 #include "os_p.h"
33 
34 #ifndef ISC_CONSTRUCTOR
35 #error Either __attribute__((constructor|destructor))__ or DllMain support needed to compile BIND 9.
36 #endif
37 
38 /***
39  *** Functions
40  ***/
41 
42 void
43 isc__initialize(void) ISC_CONSTRUCTOR;
44 void
45 isc__shutdown(void) ISC_DESTRUCTOR;
46 
47 void
48 isc__initialize(void) {
49 	isc__os_initialize();
50 	isc__mutex_initialize();
51 	isc__mem_initialize();
52 	isc__tls_initialize();
53 	isc__uv_initialize();
54 	isc__xml_initialize();
55 	isc__md_initialize();
56 	isc__hash_initialize();
57 	isc__iterated_hash_initialize();
58 	(void)isc_os_ncpus();
59 	rcu_register_thread();
60 }
61 
62 void
63 isc__shutdown(void) {
64 	isc__iterated_hash_shutdown();
65 	isc__md_shutdown();
66 	isc__xml_shutdown();
67 	isc__uv_shutdown();
68 	isc__tls_shutdown();
69 	isc__mem_shutdown();
70 	isc__mutex_shutdown();
71 	isc__os_shutdown();
72 	/* should be after isc__mem_shutdown() which calls rcu_barrier() */
73 	rcu_unregister_thread();
74 }
75