Re: [PATCH 14/16] perf kvm: reuse some code ofperf_kvm__timerfd_create()

From: Ingo Molnar
Date: Thu Sep 12 2013 - 09:09:02 EST



btw., I tried to build perf on a really old distro that has no timerfd.h,
and got:

builtin-kvm.c:22:25: error: sys/timerfd.h: No such file or directory
cc1: warnings being treated as errors
builtin-kvm.c: In function âperf_kvm__timerfd_createâ:
builtin-kvm.c:967: warning: implicit declaration of function âtimerfd_createâ
builtin-kvm.c:967: warning: nested extern declaration of âtimerfd_createâ
builtin-kvm.c:967: error: âTFD_NONBLOCKâ undeclared (first use in this function)
builtin-kvm.c:967: error: (Each undeclared identifier is reported only once
builtin-kvm.c:967: error: for each function it appears in.)
builtin-kvm.c:978: warning: implicit declaration of function âtimerfd_settimeâ
builtin-kvm.c:978: warning: nested extern declaration of âtimerfd_settimeâ
make: *** [builtin-kvm.o] Error 1
make: *** Waiting for unfinished jobs....

The quick patch below made it build - but it's incomplete, I have not
filled in the config/* details to generate HAVE_TIMERFD, I only made
builtin-kvm.o build.

Thanks,

Ingo

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 935d522..5cae8f2 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -19,7 +19,22 @@
#include "util/top.h"

#include <sys/prctl.h>
-#include <sys/timerfd.h>
+#ifdef HAVE_TIMERFD
+# include <sys/timerfd.h>
+#else
+# define TFD_NONBLOCK -1
+static int timerfd_create(clockid_t __clock_id __maybe_unused, int __flags __maybe_unused)
+{
+ return -1;
+}
+static int timerfd_settime(int __ufd __maybe_unused, int __flags __maybe_unused,
+ const struct itimerspec *__utmr __maybe_unused,
+ struct itimerspec *__otmr __maybe_unused)
+{
+ return -1;
+}
+
+#endif

#include <termios.h>
#include <semaphore.h>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/