Skip to content

Commit 91f0447

Browse files
TCMalloc Teamcopybara-github
authored andcommitted
Conditionally enable process_vm_readv based on glibc version.
PiperOrigin-RevId: 959276375
1 parent 802d446 commit 91f0447

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tcmalloc/internal/util.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include <string.h>
2222
#if defined(__linux__)
2323
#include <sys/uio.h>
24+
#if defined(__GLIBC__) && \
25+
((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 15))
26+
#define HAS_PROCESS_VM_READV 1
27+
#endif
2428
#endif // defined(__linux__)
2529
#include <unistd.h>
2630

@@ -130,7 +134,7 @@ bool SafeCopyMemory(const void* src, void* dst, size_t size) {
130134
if (src == nullptr || dst == nullptr || size == 0) {
131135
return false;
132136
}
133-
#if defined(__linux__)
137+
#if defined(HAS_PROCESS_VM_READV)
134138
struct iovec local_iov;
135139
local_iov.iov_base = dst;
136140
local_iov.iov_len = size;
@@ -144,7 +148,7 @@ bool SafeCopyMemory(const void* src, void* dst, size_t size) {
144148
return bytes == static_cast<ssize_t>(size);
145149
#else
146150
return false;
147-
#endif // defined(__linux__)
151+
#endif // defined(HAS_PROCESS_VM_READV)
148152
}
149153

150154
} // namespace tcmalloc_internal

0 commit comments

Comments
 (0)