From 68f01e7101463e6652addb2a48fd62df71ea422c Mon Sep 17 00:00:00 2001 From: Wolfgang Hommel Date: Mon, 28 Feb 2022 15:19:08 +0100 Subject: Limit glibc auto-sensing to compilation on glibc systems (addresses #369) --- src/libfaketime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libfaketime.c b/src/libfaketime.c index 5ac0300..34644bc 100644 --- a/src/libfaketime.c +++ b/src/libfaketime.c @@ -32,6 +32,8 @@ #include #ifdef __linux__ #include +#endif +#ifdef __GLIBC__ #include #endif #include @@ -3570,7 +3572,9 @@ bool needs_forced_monotonic_fix(char *function_name) { bool result = false; char *env_var; +#ifdef __GLIBC__ const char *glibc_version_string = gnu_get_libc_version(); +#endif if (function_name == NULL) return false; @@ -3585,6 +3589,7 @@ bool needs_forced_monotonic_fix(char *function_name) } else { +#ifdef __GLIBC__ /* Here we try to derive the necessity for a forced monotonic fix * * based on glibc version. What could possibly go wrong? */ @@ -3600,12 +3605,18 @@ bool needs_forced_monotonic_fix(char *function_name) result = true; } else +#endif result = false; // avoid forced monotonic fixes unless really necessary } if (getenv("FAKETIME_DEBUG") != NULL) +#ifdef __GLIBC__ fprintf(stderr, "libfaketime: forced monotonic fix for %s = %s (glibc version %s)\n", function_name, result ? "yes":"no", glibc_version_string); +#else + fprintf(stderr, "libfaketime: forced monotonic fix for %s = %s (not glibc-compiled)\n", + function_name, result ? "yes":"no"); +#endif return result; } -- cgit v1.2.1