/src/httrack/src/htsthread.h
Line | Count | Source |
1 | | /* ------------------------------------------------------------ */ |
2 | | /* |
3 | | HTTrack Website Copier, Offline Browser for Windows and Unix |
4 | | Copyright (C) 1998 Xavier Roche and other contributors |
5 | | |
6 | | SPDX-License-Identifier: GPL-3.0-or-later |
7 | | |
8 | | This program is free software: you can redistribute it and/or modify |
9 | | it under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation, either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | | |
21 | | Ethical use: we kindly ask that you NOT use this software to harvest email |
22 | | addresses or to collect any other private information about people. Doing so |
23 | | would dishonor our work and waste the many hours we have spent on it. |
24 | | |
25 | | Please visit our Website: http://www.httrack.com |
26 | | */ |
27 | | |
28 | | /* ------------------------------------------------------------ */ |
29 | | /* File: Threads */ |
30 | | /* Author: Xavier Roche */ |
31 | | /* ------------------------------------------------------------ */ |
32 | | |
33 | | #ifndef HTS_DEFTHREAD |
34 | | #define HTS_DEFTHREAD |
35 | | |
36 | | #include "htsglobal.h" |
37 | | #include "httrack-library.h" |
38 | | #ifndef _WIN32 |
39 | | #include <pthread.h> |
40 | | #endif |
41 | | #include "htswin32.h" |
42 | | #ifndef USE_BEGINTHREAD |
43 | | #error needs USE_BEGINTHREAD |
44 | | #endif |
45 | | |
46 | | #ifdef _WIN32 |
47 | | struct htsmutex_s { |
48 | | HANDLE handle; |
49 | | }; |
50 | | #else /* #ifdef _WIN32 */ |
51 | | struct htsmutex_s { |
52 | | pthread_mutex_t handle; |
53 | | }; |
54 | | #endif /* #ifdef _WIN32 */ |
55 | | |
56 | | /* Publish an int another thread polls, and observe one. A plain store and load |
57 | | carry no ordering. The compiler, or arm64 hardware, may move the payload |
58 | | after the flag and leave a reader with stale data. An aligned 32-bit access |
59 | | never tears, so only the ordering needs saying. */ |
60 | | static HTS_INLINE HTS_UNUSED void hts_store_release_int(volatile int *dst, |
61 | 2 | int value) { |
62 | | #ifdef _MSC_VER |
63 | | MemoryBarrier(); |
64 | | *(volatile int *) dst = value; |
65 | | #else |
66 | 2 | __atomic_store_n(dst, value, __ATOMIC_RELEASE); |
67 | 2 | #endif |
68 | 2 | } Unexecuted instantiation: fuzz-singlefile.c:hts_store_release_int htslib.c:hts_store_release_int Line | Count | Source | 61 | 2 | int value) { | 62 | | #ifdef _MSC_VER | 63 | | MemoryBarrier(); | 64 | | *(volatile int *) dst = value; | 65 | | #else | 66 | 2 | __atomic_store_n(dst, value, __ATOMIC_RELEASE); | 67 | 2 | #endif | 68 | 2 | } |
Unexecuted instantiation: htsfetch.c:hts_store_release_int Unexecuted instantiation: htspsl.c:hts_store_release_int Unexecuted instantiation: htscore.c:hts_store_release_int Unexecuted instantiation: htshash.c:hts_store_release_int Unexecuted instantiation: htscache.c:hts_store_release_int Unexecuted instantiation: htsback.c:hts_store_release_int Unexecuted instantiation: htsftp.c:hts_store_release_int Unexecuted instantiation: htsparse.c:hts_store_release_int Unexecuted instantiation: htsname.c:hts_store_release_int Unexecuted instantiation: htsrobots.c:hts_store_release_int Unexecuted instantiation: htstools.c:hts_store_release_int Unexecuted instantiation: htswizard.c:hts_store_release_int Unexecuted instantiation: htsthread.c:hts_store_release_int Unexecuted instantiation: htsbauth.c:hts_store_release_int Unexecuted instantiation: htsbundle.c:hts_store_release_int Unexecuted instantiation: htscoremain.c:hts_store_release_int Unexecuted instantiation: htscatchurl.c:hts_store_release_int Unexecuted instantiation: htscrashtest.c:hts_store_release_int Unexecuted instantiation: htscodec.c:hts_store_release_int Unexecuted instantiation: htswarc.c:hts_store_release_int Unexecuted instantiation: htschanges.c:hts_store_release_int Unexecuted instantiation: htssinglefile.c:hts_store_release_int Unexecuted instantiation: htssitemap.c:hts_store_release_int Unexecuted instantiation: htsproxy.c:hts_store_release_int Unexecuted instantiation: htszlib.c:hts_store_release_int Unexecuted instantiation: htsconcat.c:hts_store_release_int Unexecuted instantiation: htsselftest.c:hts_store_release_int Unexecuted instantiation: htsback_selftest.c:hts_store_release_int Unexecuted instantiation: htsselftest_util.c:hts_store_release_int Unexecuted instantiation: htscache_selftest.c:hts_store_release_int Unexecuted instantiation: htscharset_selftest.c:hts_store_release_int Unexecuted instantiation: htscmdline_selftest.c:hts_store_release_int Unexecuted instantiation: htscookie_selftest.c:hts_store_release_int Unexecuted instantiation: htsdns_selftest.c:hts_store_release_int Unexecuted instantiation: htsfetch_selftest.c:hts_store_release_int Unexecuted instantiation: htspsl_selftest.c:hts_store_release_int Unexecuted instantiation: htsbundle_selftest.c:hts_store_release_int Unexecuted instantiation: htsfilters_selftest.c:hts_store_release_int Unexecuted instantiation: htsheader_selftest.c:hts_store_release_int Unexecuted instantiation: htsio_selftest.c:hts_store_release_int Unexecuted instantiation: htslib_selftest.c:hts_store_release_int Unexecuted instantiation: htslines_selftest.c:hts_store_release_int Unexecuted instantiation: htsmime_selftest.c:hts_store_release_int Unexecuted instantiation: htsname_selftest.c:hts_store_release_int Unexecuted instantiation: htsnet_selftest.c:hts_store_release_int Unexecuted instantiation: htsopt_selftest.c:hts_store_release_int Unexecuted instantiation: htsparse_selftest.c:hts_store_release_int Unexecuted instantiation: htstools_selftest.c:hts_store_release_int Unexecuted instantiation: htswarc_selftest.c:hts_store_release_int Unexecuted instantiation: htswizard_selftest.c:hts_store_release_int |
69 | | |
70 | 0 | static HTS_INLINE HTS_UNUSED int hts_load_acquire_int(const volatile int *src) { |
71 | | #ifdef _MSC_VER |
72 | | const int value = *(const volatile int *) src; |
73 | | |
74 | | MemoryBarrier(); |
75 | | return value; |
76 | | #else |
77 | 0 | return __atomic_load_n(src, __ATOMIC_ACQUIRE); |
78 | 0 | #endif |
79 | 0 | } Unexecuted instantiation: fuzz-singlefile.c:hts_load_acquire_int Unexecuted instantiation: htslib.c:hts_load_acquire_int Unexecuted instantiation: htsfetch.c:hts_load_acquire_int Unexecuted instantiation: htspsl.c:hts_load_acquire_int Unexecuted instantiation: htscore.c:hts_load_acquire_int Unexecuted instantiation: htshash.c:hts_load_acquire_int Unexecuted instantiation: htscache.c:hts_load_acquire_int Unexecuted instantiation: htsback.c:hts_load_acquire_int Unexecuted instantiation: htsftp.c:hts_load_acquire_int Unexecuted instantiation: htsparse.c:hts_load_acquire_int Unexecuted instantiation: htsname.c:hts_load_acquire_int Unexecuted instantiation: htsrobots.c:hts_load_acquire_int Unexecuted instantiation: htstools.c:hts_load_acquire_int Unexecuted instantiation: htswizard.c:hts_load_acquire_int Unexecuted instantiation: htsthread.c:hts_load_acquire_int Unexecuted instantiation: htsbauth.c:hts_load_acquire_int Unexecuted instantiation: htsbundle.c:hts_load_acquire_int Unexecuted instantiation: htscoremain.c:hts_load_acquire_int Unexecuted instantiation: htscatchurl.c:hts_load_acquire_int Unexecuted instantiation: htscrashtest.c:hts_load_acquire_int Unexecuted instantiation: htscodec.c:hts_load_acquire_int Unexecuted instantiation: htswarc.c:hts_load_acquire_int Unexecuted instantiation: htschanges.c:hts_load_acquire_int Unexecuted instantiation: htssinglefile.c:hts_load_acquire_int Unexecuted instantiation: htssitemap.c:hts_load_acquire_int Unexecuted instantiation: htsproxy.c:hts_load_acquire_int Unexecuted instantiation: htszlib.c:hts_load_acquire_int Unexecuted instantiation: htsconcat.c:hts_load_acquire_int Unexecuted instantiation: htsselftest.c:hts_load_acquire_int Unexecuted instantiation: htsback_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsselftest_util.c:hts_load_acquire_int Unexecuted instantiation: htscache_selftest.c:hts_load_acquire_int Unexecuted instantiation: htscharset_selftest.c:hts_load_acquire_int Unexecuted instantiation: htscmdline_selftest.c:hts_load_acquire_int Unexecuted instantiation: htscookie_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsdns_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsfetch_selftest.c:hts_load_acquire_int Unexecuted instantiation: htspsl_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsbundle_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsfilters_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsheader_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsio_selftest.c:hts_load_acquire_int Unexecuted instantiation: htslib_selftest.c:hts_load_acquire_int Unexecuted instantiation: htslines_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsmime_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsname_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsnet_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsopt_selftest.c:hts_load_acquire_int Unexecuted instantiation: htsparse_selftest.c:hts_load_acquire_int Unexecuted instantiation: htstools_selftest.c:hts_load_acquire_int Unexecuted instantiation: htswarc_selftest.c:hts_load_acquire_int Unexecuted instantiation: htswizard_selftest.c:hts_load_acquire_int |
80 | | |
81 | | /* Add one to a counter other threads also update, and return its new value. */ |
82 | 53.3k | static HTS_INLINE HTS_UNUSED int hts_increment_int(volatile int *dst) { |
83 | | #ifdef _MSC_VER |
84 | | return (int) InterlockedIncrement((volatile LONG *) dst); |
85 | | #else |
86 | 53.3k | return __atomic_add_fetch(dst, 1, __ATOMIC_RELAXED); |
87 | 53.3k | #endif |
88 | 53.3k | } Unexecuted instantiation: fuzz-singlefile.c:hts_increment_int Unexecuted instantiation: htslib.c:hts_increment_int Unexecuted instantiation: htsfetch.c:hts_increment_int Unexecuted instantiation: htspsl.c:hts_increment_int htscore.c:hts_increment_int Line | Count | Source | 82 | 53.3k | static HTS_INLINE HTS_UNUSED int hts_increment_int(volatile int *dst) { | 83 | | #ifdef _MSC_VER | 84 | | return (int) InterlockedIncrement((volatile LONG *) dst); | 85 | | #else | 86 | 53.3k | return __atomic_add_fetch(dst, 1, __ATOMIC_RELAXED); | 87 | 53.3k | #endif | 88 | 53.3k | } |
Unexecuted instantiation: htshash.c:hts_increment_int Unexecuted instantiation: htscache.c:hts_increment_int Unexecuted instantiation: htsback.c:hts_increment_int Unexecuted instantiation: htsftp.c:hts_increment_int Unexecuted instantiation: htsparse.c:hts_increment_int Unexecuted instantiation: htsname.c:hts_increment_int Unexecuted instantiation: htsrobots.c:hts_increment_int Unexecuted instantiation: htstools.c:hts_increment_int Unexecuted instantiation: htswizard.c:hts_increment_int Unexecuted instantiation: htsthread.c:hts_increment_int Unexecuted instantiation: htsbauth.c:hts_increment_int Unexecuted instantiation: htsbundle.c:hts_increment_int Unexecuted instantiation: htscoremain.c:hts_increment_int Unexecuted instantiation: htscatchurl.c:hts_increment_int Unexecuted instantiation: htscrashtest.c:hts_increment_int Unexecuted instantiation: htscodec.c:hts_increment_int Unexecuted instantiation: htswarc.c:hts_increment_int Unexecuted instantiation: htschanges.c:hts_increment_int Unexecuted instantiation: htssinglefile.c:hts_increment_int Unexecuted instantiation: htssitemap.c:hts_increment_int Unexecuted instantiation: htsproxy.c:hts_increment_int Unexecuted instantiation: htszlib.c:hts_increment_int Unexecuted instantiation: htsconcat.c:hts_increment_int Unexecuted instantiation: htsselftest.c:hts_increment_int Unexecuted instantiation: htsback_selftest.c:hts_increment_int Unexecuted instantiation: htsselftest_util.c:hts_increment_int Unexecuted instantiation: htscache_selftest.c:hts_increment_int Unexecuted instantiation: htscharset_selftest.c:hts_increment_int Unexecuted instantiation: htscmdline_selftest.c:hts_increment_int Unexecuted instantiation: htscookie_selftest.c:hts_increment_int Unexecuted instantiation: htsdns_selftest.c:hts_increment_int Unexecuted instantiation: htsfetch_selftest.c:hts_increment_int Unexecuted instantiation: htspsl_selftest.c:hts_increment_int Unexecuted instantiation: htsbundle_selftest.c:hts_increment_int Unexecuted instantiation: htsfilters_selftest.c:hts_increment_int Unexecuted instantiation: htsheader_selftest.c:hts_increment_int Unexecuted instantiation: htsio_selftest.c:hts_increment_int Unexecuted instantiation: htslib_selftest.c:hts_increment_int Unexecuted instantiation: htslines_selftest.c:hts_increment_int Unexecuted instantiation: htsmime_selftest.c:hts_increment_int Unexecuted instantiation: htsname_selftest.c:hts_increment_int Unexecuted instantiation: htsnet_selftest.c:hts_increment_int Unexecuted instantiation: htsopt_selftest.c:hts_increment_int Unexecuted instantiation: htsparse_selftest.c:hts_increment_int Unexecuted instantiation: htstools_selftest.c:hts_increment_int Unexecuted instantiation: htswarc_selftest.c:hts_increment_int Unexecuted instantiation: htswizard_selftest.c:hts_increment_int |
89 | | |
90 | | /* Relaxed atomic access to a 64-bit counter that another thread updates, such |
91 | | as an FTP slot's byte count. 32-bit non-MSVC hosts get a plain access, which |
92 | | can tear, because a 64-bit atomic there may need libatomic. */ |
93 | | #if defined(_MSC_VER) || \ |
94 | | (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ >= 8) |
95 | | #define HTS_LLINT_ATOMIC 1 |
96 | | #endif |
97 | | |
98 | | static HTS_INLINE HTS_UNUSED LLint |
99 | 0 | hts_load_relaxed_llint(const volatile LLint *src) { |
100 | | #ifdef _MSC_VER |
101 | | return InterlockedCompareExchange64((volatile LONG64 *) src, 0, 0); |
102 | | #elif defined(HTS_LLINT_ATOMIC) |
103 | | return __atomic_load_n(src, __ATOMIC_RELAXED); |
104 | | #else |
105 | | return *src; |
106 | | #endif |
107 | 0 | } Unexecuted instantiation: fuzz-singlefile.c:hts_load_relaxed_llint Unexecuted instantiation: htslib.c:hts_load_relaxed_llint Unexecuted instantiation: htsfetch.c:hts_load_relaxed_llint Unexecuted instantiation: htspsl.c:hts_load_relaxed_llint Unexecuted instantiation: htscore.c:hts_load_relaxed_llint Unexecuted instantiation: htshash.c:hts_load_relaxed_llint Unexecuted instantiation: htscache.c:hts_load_relaxed_llint Unexecuted instantiation: htsback.c:hts_load_relaxed_llint Unexecuted instantiation: htsftp.c:hts_load_relaxed_llint Unexecuted instantiation: htsparse.c:hts_load_relaxed_llint Unexecuted instantiation: htsname.c:hts_load_relaxed_llint Unexecuted instantiation: htsrobots.c:hts_load_relaxed_llint Unexecuted instantiation: htstools.c:hts_load_relaxed_llint Unexecuted instantiation: htswizard.c:hts_load_relaxed_llint Unexecuted instantiation: htsthread.c:hts_load_relaxed_llint Unexecuted instantiation: htsbauth.c:hts_load_relaxed_llint Unexecuted instantiation: htsbundle.c:hts_load_relaxed_llint Unexecuted instantiation: htscoremain.c:hts_load_relaxed_llint Unexecuted instantiation: htscatchurl.c:hts_load_relaxed_llint Unexecuted instantiation: htscrashtest.c:hts_load_relaxed_llint Unexecuted instantiation: htscodec.c:hts_load_relaxed_llint Unexecuted instantiation: htswarc.c:hts_load_relaxed_llint Unexecuted instantiation: htschanges.c:hts_load_relaxed_llint Unexecuted instantiation: htssinglefile.c:hts_load_relaxed_llint Unexecuted instantiation: htssitemap.c:hts_load_relaxed_llint Unexecuted instantiation: htsproxy.c:hts_load_relaxed_llint Unexecuted instantiation: htszlib.c:hts_load_relaxed_llint Unexecuted instantiation: htsconcat.c:hts_load_relaxed_llint Unexecuted instantiation: htsselftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsback_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsselftest_util.c:hts_load_relaxed_llint Unexecuted instantiation: htscache_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htscharset_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htscmdline_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htscookie_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsdns_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsfetch_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htspsl_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsbundle_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsfilters_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsheader_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsio_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htslib_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htslines_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsmime_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsname_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsnet_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsopt_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htsparse_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htstools_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htswarc_selftest.c:hts_load_relaxed_llint Unexecuted instantiation: htswizard_selftest.c:hts_load_relaxed_llint |
108 | | |
109 | | static HTS_INLINE HTS_UNUSED void hts_store_relaxed_llint(volatile LLint *dst, |
110 | 0 | LLint value) { |
111 | | #ifdef _MSC_VER |
112 | | InterlockedExchange64((volatile LONG64 *) dst, value); |
113 | | #elif defined(HTS_LLINT_ATOMIC) |
114 | | __atomic_store_n(dst, value, __ATOMIC_RELAXED); |
115 | | #else |
116 | | *dst = value; |
117 | | #endif |
118 | 0 | } Unexecuted instantiation: fuzz-singlefile.c:hts_store_relaxed_llint Unexecuted instantiation: htslib.c:hts_store_relaxed_llint Unexecuted instantiation: htsfetch.c:hts_store_relaxed_llint Unexecuted instantiation: htspsl.c:hts_store_relaxed_llint Unexecuted instantiation: htscore.c:hts_store_relaxed_llint Unexecuted instantiation: htshash.c:hts_store_relaxed_llint Unexecuted instantiation: htscache.c:hts_store_relaxed_llint Unexecuted instantiation: htsback.c:hts_store_relaxed_llint Unexecuted instantiation: htsftp.c:hts_store_relaxed_llint Unexecuted instantiation: htsparse.c:hts_store_relaxed_llint Unexecuted instantiation: htsname.c:hts_store_relaxed_llint Unexecuted instantiation: htsrobots.c:hts_store_relaxed_llint Unexecuted instantiation: htstools.c:hts_store_relaxed_llint Unexecuted instantiation: htswizard.c:hts_store_relaxed_llint Unexecuted instantiation: htsthread.c:hts_store_relaxed_llint Unexecuted instantiation: htsbauth.c:hts_store_relaxed_llint Unexecuted instantiation: htsbundle.c:hts_store_relaxed_llint Unexecuted instantiation: htscoremain.c:hts_store_relaxed_llint Unexecuted instantiation: htscatchurl.c:hts_store_relaxed_llint Unexecuted instantiation: htscrashtest.c:hts_store_relaxed_llint Unexecuted instantiation: htscodec.c:hts_store_relaxed_llint Unexecuted instantiation: htswarc.c:hts_store_relaxed_llint Unexecuted instantiation: htschanges.c:hts_store_relaxed_llint Unexecuted instantiation: htssinglefile.c:hts_store_relaxed_llint Unexecuted instantiation: htssitemap.c:hts_store_relaxed_llint Unexecuted instantiation: htsproxy.c:hts_store_relaxed_llint Unexecuted instantiation: htszlib.c:hts_store_relaxed_llint Unexecuted instantiation: htsconcat.c:hts_store_relaxed_llint Unexecuted instantiation: htsselftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsback_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsselftest_util.c:hts_store_relaxed_llint Unexecuted instantiation: htscache_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htscharset_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htscmdline_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htscookie_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsdns_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsfetch_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htspsl_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsbundle_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsfilters_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsheader_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsio_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htslib_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htslines_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsmime_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsname_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsnet_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsopt_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htsparse_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htstools_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htswarc_selftest.c:hts_store_relaxed_llint Unexecuted instantiation: htswizard_selftest.c:hts_store_relaxed_llint |
119 | | |
120 | | /* Read a lock hts_mutexlock() may be publishing right now. It builds the lock |
121 | | on first use and publishes it with a compare-and-swap, which is a release, so |
122 | | this read has to be the matching acquire, or a thread sees the pointer and |
123 | | still reads stale bytes inside the lock body. x86 never reorders two loads |
124 | | and so hides that, but arm64 does reorder them. */ |
125 | 0 | static HTS_INLINE HTS_UNUSED htsmutex hts_load_acquire_mutex(htsmutex *src) { |
126 | | #ifdef _MSC_VER |
127 | | /* Every lock and unlock runs this, so take the free form. The caller reads |
128 | | the lock body through the pointer this returns, so that load depends on |
129 | | this one and no compiler or x86 core may hoist it above: the ordering |
130 | | rests on the address dependency, not on /volatile:ms, which no macro can |
131 | | even test for. ARM reorders dependent loads, hence the fence there. */ |
132 | | htsmutex const value = *(htsmutex volatile *) src; |
133 | | |
134 | | #if defined(_M_ARM) || defined(_M_ARM64) |
135 | | MemoryBarrier(); |
136 | | #endif |
137 | | return value; |
138 | | #else |
139 | 0 | return __atomic_load_n(src, __ATOMIC_ACQUIRE); |
140 | 0 | #endif |
141 | 0 | } Unexecuted instantiation: fuzz-singlefile.c:hts_load_acquire_mutex Unexecuted instantiation: htslib.c:hts_load_acquire_mutex Unexecuted instantiation: htsfetch.c:hts_load_acquire_mutex Unexecuted instantiation: htspsl.c:hts_load_acquire_mutex Unexecuted instantiation: htscore.c:hts_load_acquire_mutex Unexecuted instantiation: htshash.c:hts_load_acquire_mutex Unexecuted instantiation: htscache.c:hts_load_acquire_mutex Unexecuted instantiation: htsback.c:hts_load_acquire_mutex Unexecuted instantiation: htsftp.c:hts_load_acquire_mutex Unexecuted instantiation: htsparse.c:hts_load_acquire_mutex Unexecuted instantiation: htsname.c:hts_load_acquire_mutex Unexecuted instantiation: htsrobots.c:hts_load_acquire_mutex Unexecuted instantiation: htstools.c:hts_load_acquire_mutex Unexecuted instantiation: htswizard.c:hts_load_acquire_mutex Unexecuted instantiation: htsthread.c:hts_load_acquire_mutex Unexecuted instantiation: htsbauth.c:hts_load_acquire_mutex Unexecuted instantiation: htsbundle.c:hts_load_acquire_mutex Unexecuted instantiation: htscoremain.c:hts_load_acquire_mutex Unexecuted instantiation: htscatchurl.c:hts_load_acquire_mutex Unexecuted instantiation: htscrashtest.c:hts_load_acquire_mutex Unexecuted instantiation: htscodec.c:hts_load_acquire_mutex Unexecuted instantiation: htswarc.c:hts_load_acquire_mutex Unexecuted instantiation: htschanges.c:hts_load_acquire_mutex Unexecuted instantiation: htssinglefile.c:hts_load_acquire_mutex Unexecuted instantiation: htssitemap.c:hts_load_acquire_mutex Unexecuted instantiation: htsproxy.c:hts_load_acquire_mutex Unexecuted instantiation: htszlib.c:hts_load_acquire_mutex Unexecuted instantiation: htsconcat.c:hts_load_acquire_mutex Unexecuted instantiation: htsselftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsback_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsselftest_util.c:hts_load_acquire_mutex Unexecuted instantiation: htscache_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htscharset_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htscmdline_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htscookie_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsdns_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsfetch_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htspsl_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsbundle_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsfilters_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsheader_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsio_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htslib_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htslines_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsmime_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsname_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsnet_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsopt_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htsparse_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htstools_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htswarc_selftest.c:hts_load_acquire_mutex Unexecuted instantiation: htswizard_selftest.c:hts_load_acquire_mutex |
142 | | |
143 | | /* Also runs 'tail(arg)' on the worker once the body is over, and only when this |
144 | | returns 0. A thread runner (see hts_set_thread_runner()) that recovers from a |
145 | | fault returns without running the rest of the body, so cleanup the engine |
146 | | needs goes here. Not exported, because no caller outside the library spawns a |
147 | | worker. */ |
148 | | HTS_CHECK_RESULT int hts_newthread_tail(void (*fun)(void *arg), void *arg, |
149 | | void (*tail)(void *arg)); |
150 | | |
151 | | /* HTS_TRUE where a thread runner recovered from a fault, so a worker stopped |
152 | | halfway through its body. Read on the crawl thread, which turns it into a |
153 | | stop in back_check_worker_fault(). */ |
154 | | hts_boolean hts_worker_faulted(void); |
155 | | /* Forget any fault, and take the next round so that a worker an earlier mirror |
156 | | abandoned cannot abort this one. Called by a mirror as it starts. */ |
157 | | void hts_worker_fault_clear(void); |
158 | | |
159 | | #ifdef HTS_INTERNAL_BYTECODE |
160 | | /* Thread initialization */ |
161 | | void htsthread_init(void); |
162 | | void htsthread_uninit(void); |
163 | | #endif |
164 | | |
165 | | #endif |