]>
git.saurik.com Git - apple/libc.git/blob - include/secure/_string.h
d85d91d0328ce96d7710dedd4fed4acc0242fdea
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 # error "Never use <secure/_string.h> directly; include <string.h> instead."
28 #ifndef _SECURE__STRING_H_
29 #define _SECURE__STRING_H_
31 #include <secure/_common.h>
33 #if _USE_FORTIFY_LEVEL > 0
35 /* memcpy, mempcpy, memmove, memset, strcpy, stpcpy, strncpy, strcat
47 #define memcpy(dest, src, len) \
48 ((__darwin_obsz0 (dest) != (size_t) -1) \
49 ? __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest)) \
50 : __inline_memcpy_chk (dest, src, len))
53 __inline_memcpy_chk (void *__dest
, const void *__src
, size_t __len
)
55 return __builtin___memcpy_chk (__dest
, __src
, __len
, __darwin_obsz0(__dest
));
58 #define memmove(dest, src, len) \
59 ((__darwin_obsz0 (dest) != (size_t) -1) \
60 ? __builtin___memmove_chk (dest, src, len, __darwin_obsz0 (dest)) \
61 : __inline_memmove_chk (dest, src, len))
64 __inline_memmove_chk (void *__dest
, const void *__src
, size_t __len
)
66 return __builtin___memmove_chk (__dest
, __src
, __len
, __darwin_obsz0(__dest
));
69 #define memset(dest, val, len) \
70 ((__darwin_obsz0 (dest) != (size_t) -1) \
71 ? __builtin___memset_chk (dest, val, len, __darwin_obsz0 (dest)) \
72 : __inline_memset_chk (dest, val, len))
75 __inline_memset_chk (void *__dest
, int __val
, size_t __len
)
77 return __builtin___memset_chk (__dest
, __val
, __len
, __darwin_obsz0(__dest
));
80 #define strcpy(dest, src) \
81 ((__darwin_obsz0 (dest) != (size_t) -1) \
82 ? __builtin___strcpy_chk (dest, src, __darwin_obsz (dest)) \
83 : __inline_strcpy_chk (dest, src))
86 __inline_strcpy_chk (char *__restrict __dest
, const char *__restrict __src
)
88 return __builtin___strcpy_chk (__dest
, __src
, __darwin_obsz(__dest
));
91 #define stpcpy(dest, src) \
92 ((__darwin_obsz0 (dest) != (size_t) -1) \
93 ? __builtin___stpcpy_chk (dest, src, __darwin_obsz (dest)) \
94 : __inline_stpcpy_chk (dest, src))
97 __inline_stpcpy_chk (char *__dest
, const char *__src
)
99 return __builtin___stpcpy_chk (__dest
, __src
, __darwin_obsz(__dest
));
102 #define strncpy(dest, src, len) \
103 ((__darwin_obsz0 (dest) != (size_t) -1) \
104 ? __builtin___strncpy_chk (dest, src, len, __darwin_obsz (dest)) \
105 : __inline_strncpy_chk (dest, src, len))
108 __inline_strncpy_chk (char *__restrict __dest
, const char *__restrict __src
,
111 return __builtin___strncpy_chk (__dest
, __src
, __len
, __darwin_obsz(__dest
));
114 #define strcat(dest, src) \
115 ((__darwin_obsz0 (dest) != (size_t) -1) \
116 ? __builtin___strcat_chk (dest, src, __darwin_obsz (dest)) \
117 : __inline_strcat_chk (dest, src))
120 __inline_strcat_chk (char *__restrict __dest
, const char *__restrict __src
)
122 return __builtin___strcat_chk (__dest
, __src
, __darwin_obsz(__dest
));
125 #define strncat(dest, src, len) \
126 ((__darwin_obsz0 (dest) != (size_t) -1) \
127 ? __builtin___strcat_chk (dest, src, __darwin_obsz (dest)) \
128 : __inline_strncat_chk (dest, src, len))
131 __inline_strncat_chk (char *__restrict __dest
, const char *__restrict __src
,
134 return __builtin___strncat_chk (__dest
, __src
, __len
, __darwin_obsz(__dest
));