|
14 | 14 |
|
15 | 15 | #include "sanitizer_common/sanitizer_atomic.h" |
16 | 16 | #include "sanitizer_common/sanitizer_errno.h" |
| 17 | +#include "sanitizer_common/sanitizer_glibc_version.h" |
17 | 18 | #include "sanitizer_common/sanitizer_libc.h" |
18 | 19 | #include "sanitizer_common/sanitizer_linux.h" |
19 | 20 | #include "sanitizer_common/sanitizer_platform_limits_netbsd.h" |
@@ -1613,47 +1614,40 @@ TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) { |
1613 | 1614 | FdAccess(thr, pc, fd); |
1614 | 1615 | return REAL(__fxstat)(version, fd, buf); |
1615 | 1616 | } |
1616 | | -#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat) |
| 1617 | + |
| 1618 | +TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) { |
| 1619 | + SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf); |
| 1620 | + if (fd > 0) |
| 1621 | + FdAccess(thr, pc, fd); |
| 1622 | + return REAL(__fxstat64)(version, fd, buf); |
| 1623 | +} |
| 1624 | +#define TSAN_MAYBE_INTERCEPT___FXSTAT TSAN_INTERCEPT(__fxstat); TSAN_INTERCEPT(__fxstat64) |
1617 | 1625 | #else |
1618 | 1626 | #define TSAN_MAYBE_INTERCEPT___FXSTAT |
1619 | 1627 | #endif |
1620 | 1628 |
|
| 1629 | +#if !SANITIZER_GLIBC || __GLIBC_PREREQ(2, 33) |
1621 | 1630 | TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) { |
1622 | | -#if SANITIZER_GLIBC |
1623 | | - SCOPED_TSAN_INTERCEPTOR(__fxstat, 0, fd, buf); |
1624 | | - if (fd > 0) |
1625 | | - FdAccess(thr, pc, fd); |
1626 | | - return REAL(__fxstat)(0, fd, buf); |
1627 | | -#else |
1628 | 1631 | SCOPED_TSAN_INTERCEPTOR(fstat, fd, buf); |
1629 | 1632 | if (fd > 0) |
1630 | 1633 | FdAccess(thr, pc, fd); |
1631 | 1634 | return REAL(fstat)(fd, buf); |
1632 | | -#endif |
1633 | | -} |
1634 | | - |
1635 | | -#if SANITIZER_GLIBC |
1636 | | -TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) { |
1637 | | - SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf); |
1638 | | - if (fd > 0) |
1639 | | - FdAccess(thr, pc, fd); |
1640 | | - return REAL(__fxstat64)(version, fd, buf); |
1641 | 1635 | } |
1642 | | -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 TSAN_INTERCEPT(__fxstat64) |
| 1636 | +# define TSAN_MAYBE_INTERCEPT_FSTAT TSAN_INTERCEPT(fstat) |
1643 | 1637 | #else |
1644 | | -#define TSAN_MAYBE_INTERCEPT___FXSTAT64 |
| 1638 | +# define TSAN_MAYBE_INTERCEPT_FSTAT |
1645 | 1639 | #endif |
1646 | 1640 |
|
1647 | | -#if SANITIZER_GLIBC |
| 1641 | +#if __GLIBC_PREREQ(2, 33) |
1648 | 1642 | TSAN_INTERCEPTOR(int, fstat64, int fd, void *buf) { |
1649 | | - SCOPED_TSAN_INTERCEPTOR(__fxstat64, 0, fd, buf); |
| 1643 | + SCOPED_TSAN_INTERCEPTOR(fstat64, fd, buf); |
1650 | 1644 | if (fd > 0) |
1651 | 1645 | FdAccess(thr, pc, fd); |
1652 | | - return REAL(__fxstat64)(0, fd, buf); |
| 1646 | + return REAL(fstat64)(fd, buf); |
1653 | 1647 | } |
1654 | | -#define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
| 1648 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64) |
1655 | 1649 | #else |
1656 | | -#define TSAN_MAYBE_INTERCEPT_FSTAT64 |
| 1650 | +# define TSAN_MAYBE_INTERCEPT_FSTAT64 |
1657 | 1651 | #endif |
1658 | 1652 |
|
1659 | 1653 | TSAN_INTERCEPTOR(int, open, const char *name, int oflag, ...) { |
@@ -2985,10 +2979,9 @@ void InitializeInterceptors() { |
2985 | 2979 |
|
2986 | 2980 | TSAN_INTERCEPT(pthread_once); |
2987 | 2981 |
|
2988 | | - TSAN_INTERCEPT(fstat); |
2989 | 2982 | TSAN_MAYBE_INTERCEPT___FXSTAT; |
| 2983 | + TSAN_MAYBE_INTERCEPT_FSTAT; |
2990 | 2984 | TSAN_MAYBE_INTERCEPT_FSTAT64; |
2991 | | - TSAN_MAYBE_INTERCEPT___FXSTAT64; |
2992 | 2985 | TSAN_INTERCEPT(open); |
2993 | 2986 | TSAN_MAYBE_INTERCEPT_OPEN64; |
2994 | 2987 | TSAN_INTERCEPT(creat); |
|
0 commit comments