summaryrefslogtreecommitdiffstats
path: root/runtime/vsprintf.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2008-05-07 19:23:18 -0400
committerMasami Hiramatsu <mhiramat@redhat.com>2008-05-07 19:23:18 -0400
commit56d9a530202979fed9544131aa2e53bf2da0c7de (patch)
tree3a3b97cf20f57a98c76e40015153aa4c54ca2121 /runtime/vsprintf.c
parent100ae9d775be39068b7918f7d8c1079d254494eb (diff)
downloadsystemtap-steved-56d9a530202979fed9544131aa2e53bf2da0c7de.tar.gz
systemtap-steved-56d9a530202979fed9544131aa2e53bf2da0c7de.tar.xz
systemtap-steved-56d9a530202979fed9544131aa2e53bf2da0c7de.zip
PR5648: Fix memcpy's endianess issue.
Diffstat (limited to 'runtime/vsprintf.c')
-rw-r--r--runtime/vsprintf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c
index dcaa1bc3..4ffcf72e 100644
--- a/runtime/vsprintf.c
+++ b/runtime/vsprintf.c
@@ -248,6 +248,11 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
++str;
}
}
+#ifdef __ia64__
+ if ((str + precision - 1) <= end)
+ memcpy(str, &num, precision); //to prevent unaligned access
+ str += precision;
+#else
switch(precision) {
case 1:
if(str <= end)
@@ -256,21 +261,22 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
break;
case 2:
if((str + 1) <= end)
- memcpy(str, &num, 2);
+ *(int16_t *)str = (int16_t)num;
str+=2;
break;
case 4:
if((str + 3) <= end)
- memcpy(str, &num, 4);
+ *(int32_t *)str = num;
str+=4;
break;
default: // "%.8b" by default
case 8:
if((str + 7) <= end)
- memcpy(str, &num, 8);
+ *(int64_t *)str = num;
str+=8;
break;
}
+#endif
while (len < field_width--) {
if (str <= end)
*str = '\0';