Coverage Report

Created: 2023-06-07 06:23

/src/bind9/lib/isc/tid.c
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
#include <stdlib.h>
15
#include <sys/types.h>
16
#include <unistd.h>
17
18
#include <isc/lang.h>
19
#include <isc/thread.h>
20
#include <isc/tid.h>
21
#include <isc/util.h>
22
23
/**
24
 * Private
25
 */
26
thread_local uint32_t tid_local = ISC_TID_UNKNOWN;
27
28
/*
29
 * Zero is a better nonsense value in this case than ISC_TID_UNKNOWN;
30
 * avoids things like trying to allocate 32GB of per-thread counters.
31
 */
32
static uint32_t tid_count = 0;
33
34
/**
35
 * Protected
36
 */
37
38
void
39
0
isc__tid_init(uint32_t tid) {
40
0
  REQUIRE(tid_local == ISC_TID_UNKNOWN || tid_local == tid);
41
0
  tid_local = tid;
42
0
}
43
44
void
45
2
isc__tid_initcount(uint32_t count) {
46
2
  REQUIRE(tid_count == 0 || tid_count == count);
47
2
  tid_count = count;
48
2
}
49
50
/**
51
 * Public
52
 */
53
54
uint32_t
55
0
isc_tid_count(void) {
56
0
  return (tid_count);
57
0
}