From 0d155048397c88db09a25989450568e25af8f44c Mon Sep 17 00:00:00 2001 From: fche Date: Thu, 11 Aug 2005 16:53:45 +0000 Subject: [PATCH] 2005-08-11 Frank Ch. Eigler * translate.cxx (emit_function): Add an extra { } around the function body visitation. * tapset/timestamp_functions.stp: New file. * tapset/builtin_conversions.stp: Aggregated from [hex]string. * tapset/builtin_logging.stp: Aggregated from log/warn/printk. --- ChangeLog | 8 ++++++++ tapset/builtin_conversions.stp | 14 ++++++++++++++ tapset/builtin_hexstring.stp | 7 ------- tapset/builtin_log.stp | 7 ------- tapset/builtin_logging.stp | 21 +++++++++++++++++++++ tapset/builtin_printk.stp | 7 ------- tapset/builtin_string.stp | 7 ------- tapset/builtin_warn.stp | 7 ------- tapset/timestamp_functions.stp | 19 +++++++++++++++++++ translate.cxx | 3 +++ 10 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 tapset/builtin_conversions.stp delete mode 100644 tapset/builtin_hexstring.stp delete mode 100644 tapset/builtin_log.stp create mode 100644 tapset/builtin_logging.stp delete mode 100644 tapset/builtin_printk.stp delete mode 100644 tapset/builtin_string.stp delete mode 100644 tapset/builtin_warn.stp create mode 100644 tapset/timestamp_functions.stp diff --git a/ChangeLog b/ChangeLog index a01ea51e5..ceb87964b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-08-11 Frank Ch. Eigler + + * translate.cxx (emit_function): Add an extra { } around the + function body visitation. + * tapset/timestamp_functions.stp: New file. + * tapset/builtin_conversions.stp: Aggregated from [hex]string. + * tapset/builtin_logging.stp: Aggregated from log/warn/printk. + 2005-08-11 Frank Ch. Eigler * tapsets.cxx: Tweak hex/decimal printing for consistency. diff --git a/tapset/builtin_conversions.stp b/tapset/builtin_conversions.stp new file mode 100644 index 000000000..5c0230d48 --- /dev/null +++ b/tapset/builtin_conversions.stp @@ -0,0 +1,14 @@ +function _hexstring (num) %{ + sprintf (THIS->__retvalue, "0x%llx", (long long) THIS->num); +%} + +function hexstring (num) { + return "" . _hexstring (num + 0) +} +function _string (num) %{ + sprintf (THIS->__retvalue, "%lld", (long long) THIS->num); +%} + +function string (num) { + return "" . _string (num + 0) +} diff --git a/tapset/builtin_hexstring.stp b/tapset/builtin_hexstring.stp deleted file mode 100644 index c441bbc43..000000000 --- a/tapset/builtin_hexstring.stp +++ /dev/null @@ -1,7 +0,0 @@ -function _hexstring (num) %{ - sprintf (THIS->__retvalue, "%llx", (long long) THIS->num); -%} - -function hexstring (num) { - return "" . _hexstring (num + 0) -} diff --git a/tapset/builtin_log.stp b/tapset/builtin_log.stp deleted file mode 100644 index 3d1a0aaf8..000000000 --- a/tapset/builtin_log.stp +++ /dev/null @@ -1,7 +0,0 @@ -function _log (msg) %{ - _stp_log (THIS->msg); -%} - -function log (msg) { - _log (msg . "") -} diff --git a/tapset/builtin_logging.stp b/tapset/builtin_logging.stp new file mode 100644 index 000000000..51fb97e4b --- /dev/null +++ b/tapset/builtin_logging.stp @@ -0,0 +1,21 @@ +function _log (msg) %{ + _stp_log (THIS->msg); +%} + +function log (msg) { + _log (msg . "") +} +function _printk (msg) %{ + printk (KERN_INFO "%s\n", THIS->msg); +%} + +function printk (msg) { + _printk (msg . "") +} +function _warn (msg) %{ + _stp_warn (THIS->msg); +%} + +function warn (msg) { + _warn (msg . "") +} diff --git a/tapset/builtin_printk.stp b/tapset/builtin_printk.stp deleted file mode 100644 index 81826849f..000000000 --- a/tapset/builtin_printk.stp +++ /dev/null @@ -1,7 +0,0 @@ -function _printk (msg) %{ - printk (KERN_INFO "%s\n", THIS->msg); -%} - -function printk (msg) { - _printk (msg . "") -} diff --git a/tapset/builtin_string.stp b/tapset/builtin_string.stp deleted file mode 100644 index d068febb8..000000000 --- a/tapset/builtin_string.stp +++ /dev/null @@ -1,7 +0,0 @@ -function _string (num) %{ - sprintf (THIS->__retvalue, "%lld", (long long) THIS->num); -%} - -function string (num) { - return "" . _string (num + 0) -} diff --git a/tapset/builtin_warn.stp b/tapset/builtin_warn.stp deleted file mode 100644 index 97289ee07..000000000 --- a/tapset/builtin_warn.stp +++ /dev/null @@ -1,7 +0,0 @@ -function _warn (msg) %{ - _stp_warn (THIS->msg); -%} - -function warn (msg) { - _warn (msg . "") -} diff --git a/tapset/timestamp_functions.stp b/tapset/timestamp_functions.stp new file mode 100644 index 000000000..f8e1ea4ef --- /dev/null +++ b/tapset/timestamp_functions.stp @@ -0,0 +1,19 @@ +%{ +#include +%} + +// return in milliseconds since epoch +function gettimeofday_ms () %{ + struct timeval tm; + do_gettimeofday (& tm); + THIS->__retvalue = (tm.tv_sec * 1000) + (tm.tv_usec / 1000); +%} + +// return in seconds since epoch +function gettimeofday_s () %{ + struct timeval tm; + do_gettimeofday (& tm); + THIS->__retvalue = tm.tv_sec; +%} + +// likewise jiffies, monotonic_clock ... diff --git a/translate.cxx b/translate.cxx index 8806e5023..b2a44563d 100644 --- a/translate.cxx +++ b/translate.cxx @@ -771,7 +771,10 @@ c_unparser::emit_function (functiondecl* v) o->newline() << retvalue.init(); } + o->newline(1) << "{"; // in case body is embeddedcode with decls v->body->visit (this); + o->newline(-1) << "}"; + this->current_function = 0; o->newline(-1) << "out:"; -- 2.43.5