1 /* Copyright (C) 2004 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # error "Never use <bits/string3.h> directly; include <string.h> instead."
23 /* XXX This is temporarily. We should not redefine any of the symbols
24 and instead integrate the error checking into the original
43 #define memcpy(dest, src, len) \
44 ((__bos0 (dest) != (size_t) -1) \
45 ? __builtin___memcpy_chk (dest, src, len, __bos0 (dest)) \
46 : __memcpy_ichk (dest, src, len))
47 static __inline__
void *
48 __attribute__ ((__always_inline__
))
49 __memcpy_ichk (void *__restrict __dest
, const void *__restrict __src
,
52 return __builtin___memcpy_chk (__dest
, __src
, __len
, __bos0 (__dest
));
56 #define memmove(dest, src, len) \
57 ((__bos0 (dest) != (size_t) -1) \
58 ? __builtin___memmove_chk (dest, src, len, __bos0 (dest)) \
59 : __memmove_ichk (dest, src, len))
60 static __inline__
void *
61 __attribute__ ((__always_inline__
))
62 __memmove_ichk (void *__dest
, const void *__src
, size_t __len
)
64 return __builtin___memmove_chk (__dest
, __src
, __len
, __bos0 (__dest
));
69 # define mempcpy(dest, src, len) \
70 ((__bos0 (dest) != (size_t) -1) \
71 ? __builtin___mempcpy_chk (dest, src, len, __bos0 (dest)) \
72 : __mempcpy_ichk (dest, src, len))
73 static __inline__
void *
74 __attribute__ ((__always_inline__
))
75 __mempcpy_ichk (void *__restrict __dest
, const void *__restrict __src
,
78 return __builtin___mempcpy_chk (__dest
, __src
, __len
, __bos0 (__dest
));
83 #define memset(dest, ch, len) \
84 ((__bos0 (dest) != (size_t) -1) \
85 ? __builtin___memset_chk (dest, ch, len, __bos0 (dest)) \
86 : __memset_ichk (dest, ch, len))
87 static __inline__
void *
88 __attribute__ ((__always_inline__
))
89 __memset_ichk (void *__dest
, int __ch
, size_t __len
)
91 return __builtin___memset_chk (__dest
, __ch
, __len
, __bos0 (__dest
));
95 # define bcopy(src, dest, len) ((void) \
96 ((__bos0 (dest) != (size_t) -1) \
97 ? __builtin___memmove_chk (dest, src, len, __bos0 (dest)) \
98 : __memmove_ichk (dest, src, len)))
99 # define bzero(dest, len) ((void) \
100 ((__bos0 (dest) != (size_t) -1) \
101 ? __builtin___memset_chk (dest, '\0', len, __bos0 (dest)) \
102 : __memset_ichk (dest, '\0', len)))
106 #define strcpy(dest, src) \
107 ((__bos (dest) != (size_t) -1) \
108 ? __builtin___strcpy_chk (dest, src, __bos (dest)) \
109 : __strcpy_ichk (dest, src))
110 static __inline__
char *
111 __attribute__ ((__always_inline__
))
112 __strcpy_ichk (char *__restrict __dest
, const char *__restrict __src
)
114 return __builtin___strcpy_chk (__dest
, __src
, __bos (__dest
));
119 # define stpcpy(dest, src) \
120 ((__bos (dest) != (size_t) -1) \
121 ? __builtin___stpcpy_chk (dest, src, __bos (dest)) \
122 : __stpcpy_ichk (dest, src))
123 static __inline__
char *
124 __attribute__ ((__always_inline__
))
125 __stpcpy_ichk (char *__restrict __dest
, const char *__restrict __src
)
127 return __builtin___stpcpy_chk (__dest
, __src
, __bos (__dest
));
132 #define strncpy(dest, src, len) \
133 ((__bos (dest) != (size_t) -1) \
134 ? __builtin___strncpy_chk (dest, src, len, __bos (dest)) \
135 : __strncpy_ichk (dest, src, len))
136 static __inline__
char *
137 __attribute__ ((__always_inline__
))
138 __strncpy_ichk (char *__restrict __dest
, const char *__restrict __src
,
141 return __builtin___strncpy_chk (__dest
, __src
, __len
, __bos (__dest
));
145 #define strcat(dest, src) \
146 ((__bos (dest) != (size_t) -1) \
147 ? __builtin___strcat_chk (dest, src, __bos (dest)) \
148 : __strcat_ichk (dest, src))
149 static __inline__
char *
150 __attribute__ ((__always_inline__
))
151 __strcat_ichk (char *__restrict __dest
, const char *__restrict __src
)
153 return __builtin___strcat_chk (__dest
, __src
, __bos (__dest
));
157 #define strncat(dest, src, len) \
158 ((__bos (dest) != (size_t) -1) \
159 ? __builtin___strncat_chk (dest, src, len, __bos (dest)) \
160 : __strncat_ichk (dest, src, len))
161 static __inline__
char *
162 __attribute__ ((__always_inline__
))
163 __strncat_ichk (char *__restrict __dest
, const char *__restrict __src
,
166 return __builtin___strncat_chk (__dest
, __src
, __len
, __bos (__dest
));