summaryrefslogtreecommitdiffstats
path: root/tapset/socket.stp
diff options
context:
space:
mode:
authorWenji Huang <wenji.huang@oracle.com>2009-03-06 00:16:50 -0500
committerWenji Huang <wenji.huang@oracle.com>2009-03-06 00:16:50 -0500
commitfb3b52a7346202fea1905ed680a3256d372a7b03 (patch)
tree6ee3213ce8c7737377b0fe4291bb69a7fc4ac9a0 /tapset/socket.stp
parent4a05792180ad1299f499b5dbd77d5d4e9c4970fb (diff)
downloadsystemtap-steved-fb3b52a7346202fea1905ed680a3256d372a7b03.tar.gz
systemtap-steved-fb3b52a7346202fea1905ed680a3256d372a7b03.tar.xz
systemtap-steved-fb3b52a7346202fea1905ed680a3256d372a7b03.zip
PR9871: use @cast in tapset
Rewrite some functions using type casting to get rid of embedded C code in nfs, scsi, signal, socket, rpc, task and vfs tapset. Signed-off-by: Wenji Huang <wenji.huang@oracle.com>
Diffstat (limited to 'tapset/socket.stp')
-rw-r--r--tapset/socket.stp68
1 files changed, 29 insertions, 39 deletions
diff --git a/tapset/socket.stp b/tapset/socket.stp
index 842dbfc4..3271d4f7 100644
--- a/tapset/socket.stp
+++ b/tapset/socket.stp
@@ -922,53 +922,43 @@ function _get_sock_size:long (iov:long, nr_segs:long)
%}
function _sock_prot_num:long (sock:long)
-%{ /* pure */
- struct socket *sktp = (struct socket *)(long)(THIS->sock);
- struct sock *skp = sktp? kread(&(sktp->sk)) : NULL;
- if (skp == NULL)
- THIS->__retvalue = -1;
+{
+ skp = sock? @cast(sock, "socket", "kernel")->sk : 0
+ if (skp == 0)
+ return -1
else
- THIS->__retvalue = kread(&(skp->sk_protocol));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(skp, "sock", "kernel")->sk_protocol
+}
function _sock_fam_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- const struct proto_ops *ops = sockp? kread(&(sockp->ops)) : NULL;
- if (ops == NULL)
- THIS->__retvalue = -1;
+{
+ ops = sock? @cast(sock, "socket", "kernel")->ops : 0
+ if (ops == 0)
+ return -1
else
- THIS->__retvalue = kread(&(ops->family));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(ops, "proto_ops", "kernel")->family
+}
function _sock_state_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
+{
+ if (sock == 0)
+ return -1
else
- THIS->__retvalue = kread(&(sockp->state));
- CATCH_DEREF_FAULT();
-%}
+ return @cast(sock, "socket", "kernel")->state
+}
function _sock_type_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
- else
- THIS->__retvalue = kread(&(sockp->type));
- CATCH_DEREF_FAULT();
-%}
+{
+ if (sock == 0)
+ return -1
+ else
+ return @cast(sock, "socket", "kernel")->type
+}
function _sock_flags_num:long (sock:long)
-%{ /* pure */
- struct socket *sockp = (struct socket *)(long)(THIS->sock);
- if (sockp == NULL)
- THIS->__retvalue = -1;
- else
- THIS->__retvalue = kread(&(sockp->flags));
- CATCH_DEREF_FAULT();
-%}
+{
+ if (sock == 0)
+ return -1
+ else
+ return @cast(sock, "socket", "kernel")->flags
+}