]> sourceware.org Git - systemtap.git/commitdiff
PR5648: Fix memcpy's endianess issue.
authorMasami Hiramatsu <mhiramat@redhat.com>
Wed, 7 May 2008 23:23:18 +0000 (19:23 -0400)
committerMasami Hiramatsu <mhiramat@redhat.com>
Wed, 7 May 2008 23:23:18 +0000 (19:23 -0400)
runtime/ChangeLog
runtime/vsprintf.c

index 8410b91834df95b62b1c318d5f4e385ad97c24ee..0a66a28bd0bb67bde8f23100eaf09a97760694df 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-06  Masami Hiramatsu  <mhiramat@redhat.com>
+
+       PR 5648
+       * vsprintf.c (_stp_vsnprintf): Fix memcpy's endianess issue.
+
 2008-05-05  Frank Ch. Eigler  <fche@elastic.org>
 
        PR 6481.
index dcaa1bc374e958c1314c45cc1426681ca38f71eb..4ffcf72e27006e7e9b17e4af1a95f859aeba0fea 100644 (file)
@@ -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';
This page took 0.031361 seconds and 5 git commands to generate.