// build/run probes
-// Copyright (C) 2005, 2006 Red Hat Inc.
+// Copyright (C) 2005-2007 Red Hat Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Create makefile
+ // Clever hacks copied from vmware modules
+ o << "stap_check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo \"$(1)\"; else echo \"$(2)\"; fi)" << endl;
+ o << "stap_check_build = " /* << "set -x; " */ << "$(shell if $(CC) $(CPPFLAGS) $(CFLAGS_KERNEL) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=\\\"" << s.module_name << "\\\" -Werror -S -o /dev/null -xc $(1) > /dev/null 2>&1; then echo \"$(2)\"; else echo \"$(3)\"; fi)" << endl;
+
+ o << "SYSTEMTAP_RUNTIME = \"" << s.runtime_path << "\"" << endl;
+
+ // "autoconf" options go here
+
+ // enum hrtimer_mode renaming near 2.6.21; see tapsets.cxx hrtimer_derived_probe_group::emit_module_decls
+ o << "CFLAGS += $(call stap_check_build, $(SYSTEMTAP_RUNTIME)/autoconf-hrtimer-rel.c, -DSTAPCONF_HRTIMER_REL,)" << endl;
+
+
for (unsigned i=0; i<s.macros.size(); i++)
o << "CFLAGS += -D " << lex_cast_qstring(s.macros[i]) << endl;
s.op->newline(-1) << "};";
s.op->newline();
+ // autoconf: adapt to HRTIMER_REL -> HRTIMER_MODE_REL renaming near 2.6.21
+ s.op->newline() << "#ifdef STAPCONF_HRTIMER_REL";
+ s.op->newline() << "#define HRTIMER_MODE_REL HRTIMER_REL";
+ s.op->newline() << "#endif";
+
// The function signature changed in 2.6.21.
- if (strverscmp(s.kernel_base_release.c_str(), "2.6.21") < 0)
- s.op->newline() << "static int ";
- else
- s.op->newline() << "static enum hrtimer_restart ";
- s.op->line() << "enter_hrtimer_probe (struct hrtimer *timer) {";
+ s.op->newline() << "#ifdef STAPCONF_HRTIMER_REL";
+ s.op->newline() << "static int ";
+ s.op->newline() << "#else";
+ s.op->newline() << "static enum hrtimer_restart ";
+ s.op->newline() << "#endif";
+ s.op->newline() << "enter_hrtimer_probe (struct hrtimer *timer) {";
s.op->newline(1) << "int rc = HRTIMER_NORESTART;";
s.op->newline() << "struct stap_hrtimer_probe *stp = container_of(timer, struct stap_hrtimer_probe, hrtimer);";
void
hrtimer_derived_probe_group::emit_module_init (systemtap_session& s)
{
- const char *rel;
if (probes.empty()) return;
- // The enumeration names changed in 2.6.21.
- if (strverscmp(s.kernel_base_release.c_str(), "2.6.21") < 0)
- rel = "HRTIMER_REL";
- else
- rel = "HRTIMER_MODE_REL";
-
s.op->newline() << "{";
s.op->newline(1) << "struct timespec res;";
s.op->newline() << "hrtimer_get_res (CLOCK_MONOTONIC, &res);";
s.op->newline() << "for (i=0; i<" << probes.size() << "; i++) {";
s.op->newline(1) << "struct stap_hrtimer_probe* stp = & stap_hrtimer_probes [i];";
s.op->newline() << "probe_point = stp->pp;";
- s.op->newline() << "hrtimer_init (& stp->hrtimer, CLOCK_MONOTONIC, " << rel << ");";
+ s.op->newline() << "hrtimer_init (& stp->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);";
s.op->newline() << "stp->hrtimer.function = & enter_hrtimer_probe;";
// There is no hrtimer field to identify *this* (i-th) probe handler
// callback. So instead we'll deduce it at entry time.
s.op->newline() << "(void) hrtimer_start (& stp->hrtimer, ";
emit_interval (s.op);
- s.op->line() << ", " << rel << ");";
+ s.op->line() << ", HRTIMER_MODE_REL);";
// Note: no partial failure rollback is needed: hrtimer_start only
// "fails" if the timer was already active, which cannot be.
s.op->newline(-1) << "}"; // for loop