]> sourceware.org Git - systemtap.git/commitdiff
2006-04-17 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Mon, 17 Apr 2006 19:18:56 +0000 (19:18 +0000)
committerhunt <hunt>
Mon, 17 Apr 2006 19:18:56 +0000 (19:18 +0000)
* endian.stp (set_endian): New function.

tapset/ChangeLog
tapset/endian.stp
tapset/logging.stp

index bdad3877d436ea640c53801a7ee2a29c69d13d8e..a1cbf049c908e596a96ec5839fa2ee3f5c81a8f2 100644 (file)
@@ -1,3 +1,7 @@
+2006-04-17  Martin Hunt  <hunt@redhat.com>
+
+       * endian.stp (set_endian): New function.
+
 2006-03-06  Martin Hunt  <hunt@redhat.com>
 
        * system.stp: New tapset. 
index 26b3a05a924695988df6ad15a794477006009fe0..ddcc254638a6f7d4bbedbad92a6201c1293909cf 100644 (file)
@@ -1,47 +1,31 @@
+# set the default endianess for binary printf
+# val:   0 - native (default)
+#        1 - little endian
+#        2 - big endian
+function set_endian:long (val:long) %{
+       _stp_endian = THIS->val;        
+%}
+
 function big_endian2:long (val:long) %{
-#ifdef __LITTLE_ENDIAN
-        THIS->__retvalue = swab16(THIS->val);
-#else
-        THIS->__retvalue = THIS->val & 0xffff;
-#endif
+       THIS->__retvalue = cpu_to_be16(THIS->val);
 %}
 
 function big_endian4:long (val:long) %{
-#ifdef __LITTLE_ENDIAN
-        THIS->__retvalue = swab32(THIS->val);
-#else
-        THIS->__retvalue = THIS->val & 0xffffffff;
-#endif
+       THIS->__retvalue = cpu_to_be32(THIS->val);
 %}
 
 function big_endian8:long (val:long) %{
-#ifdef __LITTLE_ENDIAN
-        THIS->__retvalue = swab64(THIS->val);
-#else
-        THIS->__retvalue = THIS->val;
-#endif
+       THIS->__retvalue = cpu_to_be64(THIS->val);
 %}
 
 function little_endian2:long (val:long) %{
-#ifndef __LITTLE_ENDIAN
-        THIS->__retvalue = swab16(THIS->val);
-#else
-        THIS->__retvalue = THIS->val & 0xffff;
-#endif
+       THIS->__retvalue = cpu_to_le16(THIS->val);
 %}
 
 function little_endian4:long (val:long) %{
-#ifndef __LITTLE_ENDIAN
-        THIS->__retvalue = swab32(THIS->val);
-#else
-        THIS->__retvalue = THIS->val & 0xffffffff;
-#endif
+       THIS->__retvalue = cpu_to_le32(THIS->val);
 %}
 
 function little_endian8:long (val:long) %{
-#ifndef __LITTLE_ENDIAN
-        THIS->__retvalue = swab64(THIS->val);
-#else
-        THIS->__retvalue = THIS->val;
-#endif
+       THIS->__retvalue = cpu_to_le64(THIS->val);
 %}
index a3fcac049189a10372419d0a5e74118af1fbee3f..659ef38929476b0b067149db455fb75d2e1e1424 100644 (file)
@@ -6,9 +6,10 @@
 // Public License (GPL); either version 2, or (at your option) any
 // later version.
 
-// send a string out with a newline
+// Write a message to the console (actually stderr). A newline is appended 
+// if the string does not end in one.
 function log (msg:string) %{
-    _stp_printf ("%s\n", THIS->msg);
+    _stp_log (THIS->msg);
 %}
 
 function warn (msg:string) %{
This page took 0.028611 seconds and 5 git commands to generate.