From 45a2f2d8d30103f74b20ae19cd61be1f775c5ddb Mon Sep 17 00:00:00 2001 From: lovro Date: Sun, 1 Dec 2013 11:25:31 -0800 Subject: [PATCH] Fix build without glibc Summary: The preprocessor does not follow normal rules of && evaluation, tries to evaluate __GLIBC_PREREQ(2, 12) even though the defined() check fails. This breaks the build if __GLIBC_PREREQ is absent. Test Plan: Try adding #undef __GLIBC_PREREQ above the offending line, build no longer breaks Reviewed By: igor Blame Rev: 4c81383628db46d35b674000a3668b5a9a2498a6 --- util/env_posix.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index 16c3d1c61..dd052bb25 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -1398,11 +1398,13 @@ class PosixEnv : public Env { (unsigned long)t); // Set the thread name to aid debugging -#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ) && (__GLIBC_PREREQ(2, 12)) +#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 12) char name_buf[16]; snprintf(name_buf, sizeof name_buf, "rocksdb:bg%zu", bgthreads_.size()); name_buf[sizeof name_buf - 1] = '\0'; pthread_setname_np(t, name_buf); +#endif #endif bgthreads_.push_back(t);