summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Hommel <wolf@code-wizards.com>2022-02-28 15:19:08 +0100
committerWolfgang Hommel <wolf@code-wizards.com>2022-02-28 15:19:08 +0100
commit68f01e7101463e6652addb2a48fd62df71ea422c (patch)
tree82f0a9359cf49c8a0379555f59fe42dbec664533
parenta8d6a7690617a97d0e566f65e772e41c799e992d (diff)
downloadlibfaketime-68f01e7101463e6652addb2a48fd62df71ea422c.tar.gz
Limit glibc auto-sensing to compilation on glibc systems (addresses #369)
-rw-r--r--src/libfaketime.c11
1 files changed, 11 insertions, 0 deletions
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 <poll.h>
#ifdef __linux__
#include <sys/epoll.h>
+#endif
+#ifdef __GLIBC__
#include <gnu/libc-version.h>
#endif
#include <time.h>
@@ -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;
}