Vector sincosf for x86_64 and tests.
[glibc.git] / debug / strncat_chk.c
blob2951d05f68cf401ac7fda242d6f1f1a31fb26d1c
1 /* Copyright (C) 1991-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <string.h>
20 #include <memcopy.h>
23 char *
24 __strncat_chk (s1, s2, n, s1len)
25 char *s1;
26 const char *s2;
27 size_t n;
28 size_t s1len;
30 char c;
31 char *s = s1;
33 /* Find the end of S1. */
36 if (__glibc_unlikely (s1len-- == 0))
37 __chk_fail ();
38 c = *s1++;
40 while (c != '\0');
42 /* Make S1 point before next character, so we can increment
43 it while memory is read (wins on pipelined cpus). */
44 ++s1len;
45 s1 -= 2;
47 if (n >= 4)
49 size_t n4 = n >> 2;
52 if (__glibc_unlikely (s1len-- == 0))
53 __chk_fail ();
54 c = *s2++;
55 *++s1 = c;
56 if (c == '\0')
57 return s;
58 if (__glibc_unlikely (s1len-- == 0))
59 __chk_fail ();
60 c = *s2++;
61 *++s1 = c;
62 if (c == '\0')
63 return s;
64 if (__glibc_unlikely (s1len-- == 0))
65 __chk_fail ();
66 c = *s2++;
67 *++s1 = c;
68 if (c == '\0')
69 return s;
70 if (__glibc_unlikely (s1len-- == 0))
71 __chk_fail ();
72 c = *s2++;
73 *++s1 = c;
74 if (c == '\0')
75 return s;
76 } while (--n4 > 0);
77 n &= 3;
80 while (n > 0)
82 if (__glibc_unlikely (s1len-- == 0))
83 __chk_fail ();
84 c = *s2++;
85 *++s1 = c;
86 if (c == '\0')
87 return s;
88 n--;
91 if (c != '\0')
93 if (__glibc_unlikely (s1len-- == 0))
94 __chk_fail ();
95 *++s1 = '\0';
98 return s;