Skip to content

Commit 3d87e21

Browse files
authored
[NFC][sanitizer] Consolidate version checking branches of ThreadDescriptorSizeFallback (#108912)
1 parent e5bc842 commit 3d87e21

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,22 @@ static uptr ThreadDescriptorSizeFallback() {
283283
return 0;
284284
# endif
285285

286+
# if SANITIZER_RISCV64
287+
int major;
288+
int minor;
289+
int patch;
290+
if (GetLibcVersion(&major, &minor, &patch) && major == 2) {
291+
// TODO: consider adding an optional runtime check for an unknown (untested)
292+
// glibc version
293+
if (minor <= 28) // WARNING: the highest tested version is 2.29
294+
return 1772; // no guarantees for this one
295+
if (minor <= 31)
296+
return 1772; // tested against glibc 2.29, 2.31
297+
return 1936; // tested against glibc 2.32
298+
}
299+
return 0;
300+
# endif
301+
286302
# if defined(__s390__) || defined(__sparc__)
287303
// The size of a prefix of TCB including pthread::{specific_1stblock,specific}
288304
// suffices. Just return offsetof(struct pthread, specific_used), which hasn't
@@ -301,22 +317,6 @@ static uptr ThreadDescriptorSizeFallback() {
301317
return 1856; // from glibc 2.36
302318
# endif
303319

304-
# if SANITIZER_RISCV64
305-
int major;
306-
int minor;
307-
int patch;
308-
if (GetLibcVersion(&major, &minor, &patch) && major == 2) {
309-
// TODO: consider adding an optional runtime check for an unknown (untested)
310-
// glibc version
311-
if (minor <= 28) // WARNING: the highest tested version is 2.29
312-
return 1772; // no guarantees for this one
313-
if (minor <= 31)
314-
return 1772; // tested against glibc 2.29, 2.31
315-
return 1936; // tested against glibc 2.32
316-
}
317-
return 0;
318-
# endif
319-
320320
# if defined(__aarch64__)
321321
// The sizeof (struct pthread) is the same from GLIBC 2.17 to 2.22.
322322
return 1776;

0 commit comments

Comments
 (0)