public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "mjw at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sources.redhat.com
Subject: [Bug tapsets/9871] use @cast() instead of embedded-c whereever possible
Date: Fri, 27 Feb 2009 21:25:00 -0000	[thread overview]
Message-ID: <20090227144630.31174.qmail@sourceware.org> (raw)
In-Reply-To: <20090219182252.9871.fche@redhat.com>


------- Additional Comments From mjw at redhat dot com  2009-02-27 14:46 -------
I did one small rewrite of tapset/inet_sock.stp, which is nicely smaller now. It
does still need a small tidbit of embedded C because we cannot easily cast
between basic types/unions, see the new daddr_to_string.

function inet_get_local_port:long(sock:long)
{
%(kernel_v < "2.6.21" %?
  port = @cast(sock, "inet_sock", "kernel")->inet->num;
%:
  port = @cast(sock, "inet_sock", "kernel")->num;
%)
  return port;
}

// Get IP source address string given a pointer to a kernel socket.
function inet_get_ip_source:string(sock:long)
{
%(kernel_v < "2.6.21" %?
  daddr = @cast(sock, "inet_sock", "kernel")->inet->daddr;
%:
  daddr = @cast(sock, "inet_sock", "kernel")->daddr;
%)
  return daddr_to_string(daddr);
}

// Turns a daddr as found in an inet_sock into a dotted ip string.
function daddr_to_string:string(daddr:long)
%{ /* pure */
	union { __u32 d; unsigned char addr[4]; } u;
	u.d = THIS->daddr;
	sprintf(THIS->__retvalue, "%d.%d.%d.%d",
			u.addr[0], u.addr[1], u.addr[2], u.addr[3]);
%}

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9871

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

  reply	other threads:[~2009-02-27 14:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-19 22:53 [Bug tapsets/9871] New: " fche at redhat dot com
2009-02-27 21:25 ` mjw at redhat dot com [this message]
2009-03-05 16:29 ` [Bug tapsets/9871] " wenji dot huang at oracle dot com
2009-03-05 17:00 ` mjw at redhat dot com
2009-03-06 10:40 ` wenji dot huang at oracle dot com
2009-03-07 22:13 ` fche at redhat dot com
2009-03-09 20:56 ` jkenisto at us dot ibm dot com
2009-03-09 21:05 ` jistone at redhat dot com
2009-03-10  3:00 ` jkenisto at us dot ibm dot com
2009-03-10  3:37 ` jistone at redhat dot com
2009-03-12  3:19 ` jistone at redhat dot com
2009-04-29 16:37 ` nuhn at physik dot rwth-aachen dot de
2010-03-26 18:27 ` dsmith at redhat dot com
2010-03-30 20:57 ` dsmith at redhat dot com
2010-04-05 17:30 ` dsmith at redhat dot com
2010-04-05 19:56 ` dsmith at redhat dot com
2010-04-06 15:06 ` dsmith at redhat dot com
2010-04-06 16:37 ` dsmith at redhat dot com
2010-04-07 14:44 ` dsmith at redhat dot com
2010-04-12 12:47   ` Steve Dickson
2010-04-23  0:21     ` David Smith
2010-04-07 21:14 ` dsmith at redhat dot com
2010-05-12 12:43 ` dsmith at redhat dot com
2010-05-13  0:24 ` dsmith at redhat dot com
2010-09-27 14:46 ` dsmith at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090227144630.31174.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).