+# 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);
%}
// 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) %{