From 304c5527fb95a038cb115dce3a16dde4a68c99f4 Mon Sep 17 00:00:00 2001 From: Liubov Dmitrieva Date: Fri, 14 Dec 2012 18:41:37 +0400 Subject: Inappropriate code style for Intel MPX in debug/strcpy_chk.c Use different version if MPX enabled. --- debug/strcpy_chk.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/debug/strcpy_chk.c b/debug/strcpy_chk.c index 81bf46f992..ba6da70190 100644 --- a/debug/strcpy_chk.c +++ b/debug/strcpy_chk.c @@ -27,6 +27,7 @@ __strcpy_chk (dest, src, destlen) char *dest; const char *src; size_t destlen; +#ifndef __CHKP__ { char c; char *s = (char *) src; @@ -65,3 +66,45 @@ __strcpy_chk (dest, src, destlen) return dest; } +#else +{ + char c; + char *s = (char *) src; + char *d = (char *) dest; + + while (__builtin_expect (destlen >= 4, 0)) + { + c = s[0]; + d[0] = c; + if (c == '\0') + return dest; + c = s[1]; + d[1] = c; + if (c == '\0') + return dest; + c = s[2]; + d[2] = c; + if (c == '\0') + return dest; + c = s[3]; + d[3] = c; + if (c == '\0') + return dest; + destlen -= 4; + d += 4; + s += 4; + } + + do + { + if (__builtin_expect (destlen-- == 0, 0)) + __chk_fail (); + c = *s; + *(d++) = c; + s++; + } + while (c != '\0'); + + return dest; +} +#endif -- cgit 1.4.1