Line | Count | Source (jump to first uncovered line) |
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 | | /*! \file */ |
15 | | |
16 | | #include <isc/crypto.h> |
17 | | #include <isc/hash.h> |
18 | | #include <isc/iterated_hash.h> |
19 | | #include <isc/md.h> |
20 | | #include <isc/mem.h> |
21 | | #include <isc/os.h> |
22 | | #include <isc/refcount.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 "mem_p.h" |
30 | | #include "mutex_p.h" |
31 | | #include "os_p.h" |
32 | | #include "thread_p.h" |
33 | | |
34 | | /*** |
35 | | *** Functions |
36 | | ***/ |
37 | | |
38 | | static isc_refcount_t isc__lib_references = 0; |
39 | | |
40 | | void |
41 | | isc__lib_initialize(void); |
42 | | void |
43 | | isc__lib_shutdown(void); |
44 | | |
45 | | void |
46 | 44 | isc__lib_initialize(void) { |
47 | 44 | if (isc_refcount_increment0(&isc__lib_references) > 0) { |
48 | 22 | return; |
49 | 22 | } |
50 | | |
51 | 22 | rcu_register_thread(); |
52 | 22 | isc__os_initialize(); |
53 | 22 | isc__mutex_initialize(); |
54 | 22 | isc__mem_initialize(); |
55 | 22 | isc__log_initialize(); |
56 | 22 | isc__crypto_initialize(); |
57 | 22 | isc__uv_initialize(); |
58 | 22 | isc__xml_initialize(); |
59 | 22 | isc__hash_initialize(); |
60 | 22 | isc__iterated_hash_initialize(); |
61 | 22 | (void)isc_os_ncpus(); |
62 | 22 | } |
63 | | |
64 | | void |
65 | 0 | isc__lib_shutdown(void) { |
66 | 0 | if (isc_refcount_decrement(&isc__lib_references) > 1) { |
67 | 0 | return; |
68 | 0 | } |
69 | | |
70 | 0 | rcu_barrier(); |
71 | 0 | rcu_unregister_thread(); |
72 | |
|
73 | 0 | isc__iterated_hash_shutdown(); |
74 | 0 | isc__xml_shutdown(); |
75 | 0 | isc__uv_shutdown(); |
76 | 0 | isc__crypto_shutdown(); |
77 | 0 | isc__log_shutdown(); |
78 | 0 | isc__mem_shutdown(); |
79 | 0 | isc__mutex_shutdown(); |
80 | 0 | isc__os_shutdown(); |
81 | 0 | } |