[llvm-branch-commits] [NFC][sanitizer] Switch to `gnu_get_libc_version` (PR #108724)

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Sep 15 22:45:12 PDT 2024


================
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
 
 __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
                                                    int *patch) {
-#  ifdef _CS_GNU_LIBC_VERSION
-  char buf[64];
-  uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
-  if (len >= sizeof(buf))
-    return false;
-  buf[len] = 0;
-  static const char kGLibC[] = "glibc ";
-  if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
-    return false;
-  const char *p = buf + sizeof(kGLibC) - 1;
+#  ifdef SANITIZER_GLIBC
+  const char *p = gnu_get_libc_version();
   *major = internal_simple_strtoll(p, &p, 10);
+  // Caller do not expect anything else.
----------------
MaskRay wrote:

Caller does not expect

https://github.com/llvm/llvm-project/pull/108724


More information about the llvm-branch-commits mailing list