| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2017 The Android Open Source Project | 
|  | 3 | * All rights reserved. | 
|  | 4 | * | 
|  | 5 | * Redistribution and use in source and binary forms, with or without | 
|  | 6 | * modification, are permitted provided that the following conditions | 
|  | 7 | * are met: | 
|  | 8 | *  * Redistributions of source code must retain the above copyright | 
|  | 9 | *    notice, this list of conditions and the following disclaimer. | 
|  | 10 | *  * Redistributions in binary form must reproduce the above copyright | 
|  | 11 | *    notice, this list of conditions and the following disclaimer in | 
|  | 12 | *    the documentation and/or other materials provided with the | 
|  | 13 | *    distribution. | 
|  | 14 | * | 
|  | 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
|  | 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
|  | 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 
|  | 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 
|  | 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | 
|  | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 
|  | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | 
|  | 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 
|  | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
|  | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | 
|  | 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
|  | 26 | * SUCH DAMAGE. | 
|  | 27 | */ | 
|  | 28 |  | 
|  | 29 | #ifndef _STRING_H | 
|  | 30 | #error "Never include this file directly; instead, include <string.h>" | 
|  | 31 | #endif | 
|  | 32 |  | 
| Elliott Hughes | 3f66e74 | 2017-08-01 13:24:40 -0700 | [diff] [blame] | 33 | void* __memchr_chk(const void*, int, size_t, size_t) __INTRODUCED_IN(23); | 
|  | 34 | void* __memrchr_chk(const void*, int, size_t, size_t) __INTRODUCED_IN(23); | 
|  | 35 | char* __stpncpy_chk2(char*, const char*, size_t, size_t, size_t) __INTRODUCED_IN(21); | 
|  | 36 | char* __strncpy_chk2(char*, const char*, size_t, size_t, size_t) __INTRODUCED_IN(21); | 
|  | 37 | size_t __strlcpy_chk(char*, const char*, size_t, size_t) __INTRODUCED_IN(17); | 
|  | 38 | size_t __strlcat_chk(char*, const char*, size_t, size_t) __INTRODUCED_IN(17); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 39 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 40 | #if defined(__BIONIC_FORTIFY) | 
| Elliott Hughes | df9a489 | 2017-08-23 14:34:03 -0700 | [diff] [blame] | 41 | extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr); | 
|  | 42 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 43 | #if __ANDROID_API__ >= __ANDROID_API_J_MR1__ | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 44 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 45 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 46 | void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount) | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 47 | __overloadable { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 48 | size_t bos_dst = __bos0(dst); | 
|  | 49 | if (__bos_trivially_not_lt(bos_dst, copy_amount)) { | 
|  | 50 | return __builtin_memcpy(dst, src, copy_amount); | 
|  | 51 | } | 
|  | 52 | return __builtin___memcpy_chk(dst, src, copy_amount, bos_dst); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 53 | } | 
|  | 54 |  | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 55 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 56 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 57 | void* memmove(void* const dst __pass_object_size0, const void* src, size_t len) __overloadable { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 58 | size_t bos_dst = __bos0(dst); | 
|  | 59 | if (__bos_trivially_not_lt(bos_dst, len)) { | 
|  | 60 | return __builtin_memmove(dst, src, len); | 
|  | 61 | } | 
|  | 62 | return __builtin___memmove_chk(dst, src, len, bos_dst); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 63 | } | 
|  | 64 | #endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */ | 
|  | 65 |  | 
| George Burgess IV | 849c0b9 | 2019-06-10 16:22:09 -0700 | [diff] [blame] | 66 | #if defined(__USE_GNU) | 
|  | 67 | #if __ANDROID_API__ >= __ANDROID_API_R__ | 
|  | 68 | __BIONIC_FORTIFY_INLINE | 
|  | 69 | void* mempcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount) | 
|  | 70 | __overloadable | 
|  | 71 | __clang_error_if(__bos_unevaluated_lt(__bos0(dst), copy_amount), | 
|  | 72 | "'mempcpy' called with size bigger than buffer") { | 
|  | 73 | size_t bos_dst = __bos0(dst); | 
|  | 74 | if (__bos_trivially_not_lt(bos_dst, copy_amount)) { | 
|  | 75 | return __builtin_mempcpy(dst, src, copy_amount); | 
|  | 76 | } | 
|  | 77 | return __builtin___mempcpy_chk(dst, src, copy_amount, bos_dst); | 
|  | 78 | } | 
|  | 79 | #endif /* __ANDROID_API__ >= __ANDROID_API_R__ */ | 
|  | 80 | #endif | 
|  | 81 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 82 | #if __ANDROID_API__ >= __ANDROID_API_L__ | 
|  | 83 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 84 | char* stpcpy(char* const dst __pass_object_size, const char* src) | 
|  | 85 | __overloadable | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 86 | __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 87 | "'stpcpy' called with string bigger than buffer") { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 88 | size_t bos_dst = __bos(dst); | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 89 | if (__bos_trivially_not_le(bos_dst, __builtin_strlen(src))) { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 90 | return __builtin_stpcpy(dst, src); | 
|  | 91 | } | 
|  | 92 | return __builtin___stpcpy_chk(dst, src, bos_dst); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 93 | } | 
|  | 94 | #endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ | 
|  | 95 |  | 
|  | 96 | #if __ANDROID_API__ >= __ANDROID_API_J_MR1__ | 
|  | 97 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 98 | char* strcpy(char* const dst __pass_object_size, const char* src) | 
|  | 99 | __overloadable | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 100 | __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 101 | "'strcpy' called with string bigger than buffer") { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 102 | size_t bos_dst = __bos(dst); | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 103 | if (__bos_trivially_not_le(bos_dst, __builtin_strlen(src))) { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 104 | return __builtin_strcpy(dst, src); | 
|  | 105 | } | 
|  | 106 | return __builtin___strcpy_chk(dst, src, bos_dst); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 107 | } | 
|  | 108 |  | 
|  | 109 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 77f99aa | 2019-06-06 14:14:52 -0700 | [diff] [blame] | 110 | char* strcat(char* const dst __pass_object_size, const char* src) | 
|  | 111 | __overloadable | 
|  | 112 | __clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)), | 
|  | 113 | "'strcat' called with string bigger than buffer") { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 114 | return __builtin___strcat_chk(dst, src, __bos(dst)); | 
|  | 115 | } | 
|  | 116 |  | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 117 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 118 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 119 | char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 120 | return __builtin___strncat_chk(dst, src, n, __bos(dst)); | 
|  | 121 | } | 
|  | 122 |  | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 123 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 124 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 125 | void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 126 | /* If you're a user who wants this warning to go away: use `(&memset)(foo, bar, baz)`. */ | 
|  | 127 | __clang_warning_if(c && !n, "'memset' will set 0 bytes; maybe the arguments got flipped?") { | 
| George Burgess IV | 5da5dd5 | 2019-05-09 14:32:43 -0700 | [diff] [blame] | 128 | size_t bos = __bos0(s); | 
|  | 129 | if (__bos_trivially_not_lt(bos, n)) { | 
|  | 130 | return __builtin_memset(s, c, n); | 
|  | 131 | } | 
|  | 132 | return __builtin___memset_chk(s, c, n, bos); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 133 | } | 
|  | 134 | #endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */ | 
|  | 135 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 136 | #if __ANDROID_API__ >= __ANDROID_API_M__ | 
|  | 137 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 138 | void* memchr(const void* const s __pass_object_size, int c, size_t n) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 139 | size_t bos = __bos(s); | 
|  | 140 |  | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 141 | if (__bos_trivially_ge(bos, n)) { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 142 | return __builtin_memchr(s, c, n); | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | return __memchr_chk(s, c, n, bos); | 
|  | 146 | } | 
|  | 147 |  | 
|  | 148 | __BIONIC_FORTIFY_INLINE | 
| Elliott Hughes | df9a489 | 2017-08-23 14:34:03 -0700 | [diff] [blame] | 149 | void* __memrchr_fortify(const void* const __pass_object_size s, int c, size_t n) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 150 | size_t bos = __bos(s); | 
|  | 151 |  | 
| George Burgess IV | c03d596 | 2019-05-23 15:22:01 -0700 | [diff] [blame] | 152 | if (__bos_trivially_ge(bos, n)) { | 
| Elliott Hughes | df9a489 | 2017-08-23 14:34:03 -0700 | [diff] [blame] | 153 | return __memrchr_real(s, c, n); | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 154 | } | 
|  | 155 |  | 
|  | 156 | return __memrchr_chk(s, c, n, bos); | 
|  | 157 | } | 
|  | 158 | #endif /* __ANDROID_API__ >= __ANDROID_API_M__ */ | 
|  | 159 |  | 
|  | 160 | #if __ANDROID_API__ >= __ANDROID_API_L__ | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 161 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 162 | __BIONIC_FORTIFY_INLINE | 
| Elliott Hughes | 3f66e74 | 2017-08-01 13:24:40 -0700 | [diff] [blame] | 163 | char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n) | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 164 | __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 165 | size_t bos_dst = __bos(dst); | 
|  | 166 | size_t bos_src = __bos(src); | 
|  | 167 |  | 
|  | 168 | /* Ignore dst size checks; they're handled in strncpy_chk */ | 
|  | 169 | if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 170 | return __builtin___stpncpy_chk(dst, src, n, bos_dst); | 
|  | 171 | } | 
|  | 172 |  | 
|  | 173 | return __stpncpy_chk2(dst, src, n, bos_dst, bos_src); | 
|  | 174 | } | 
|  | 175 |  | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 176 | /* No diag -- clang diagnoses misuses of this on its own.  */ | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 177 | __BIONIC_FORTIFY_INLINE | 
| Elliott Hughes | 3f66e74 | 2017-08-01 13:24:40 -0700 | [diff] [blame] | 178 | char* strncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n) | 
| George Burgess IV | 36926f4 | 2019-09-15 16:57:00 -0700 | [diff] [blame] | 179 | __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 180 | size_t bos_dst = __bos(dst); | 
|  | 181 | size_t bos_src = __bos(src); | 
|  | 182 |  | 
|  | 183 | /* Ignore dst size checks; they're handled in strncpy_chk */ | 
|  | 184 | if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 185 | return __builtin___strncpy_chk(dst, src, n, bos_dst); | 
|  | 186 | } | 
|  | 187 |  | 
|  | 188 | return __strncpy_chk2(dst, src, n, bos_dst, bos_src); | 
|  | 189 | } | 
|  | 190 | #endif /* __ANDROID_API__ >= __ANDROID_API_L__ */ | 
|  | 191 |  | 
|  | 192 | #if __ANDROID_API__ >= __ANDROID_API_J_MR1__ | 
|  | 193 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 77f99aa | 2019-06-06 14:14:52 -0700 | [diff] [blame] | 194 | size_t strlcpy(char* const dst __pass_object_size, const char* src, size_t size) | 
|  | 195 | __overloadable | 
|  | 196 | __clang_error_if(__bos_unevaluated_lt(__bos(dst), size), | 
|  | 197 | "'strlcpy' called with size bigger than buffer") { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 198 | size_t bos = __bos(dst); | 
|  | 199 |  | 
|  | 200 | if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 201 | return __call_bypassing_fortify(strlcpy)(dst, src, size); | 
|  | 202 | } | 
|  | 203 |  | 
|  | 204 | return __strlcpy_chk(dst, src, size, bos); | 
|  | 205 | } | 
|  | 206 |  | 
|  | 207 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | 77f99aa | 2019-06-06 14:14:52 -0700 | [diff] [blame] | 208 | size_t strlcat(char* const dst __pass_object_size, const char* src, size_t size) | 
|  | 209 | __overloadable | 
|  | 210 | __clang_error_if(__bos_unevaluated_lt(__bos(dst), size), | 
|  | 211 | "'strlcat' called with size bigger than buffer") { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 212 | size_t bos = __bos(dst); | 
|  | 213 |  | 
|  | 214 | if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 215 | return __call_bypassing_fortify(strlcat)(dst, src, size); | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | return __strlcat_chk(dst, src, size, bos); | 
|  | 219 | } | 
|  | 220 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 221 | __BIONIC_FORTIFY_INLINE | 
| George Burgess IV | b630046 | 2017-07-31 21:29:42 -0700 | [diff] [blame] | 222 | size_t strlen(const char* const s __pass_object_size0) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 223 | size_t bos = __bos0(s); | 
|  | 224 |  | 
| George Burgess IV | a1a09b2 | 2019-05-13 17:16:20 -0700 | [diff] [blame] | 225 | if (__bos_trivially_gt(bos, __builtin_strlen(s))) { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 226 | return __builtin_strlen(s); | 
|  | 227 | } | 
|  | 228 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 229 | return __strlen_chk(s, bos); | 
|  | 230 | } | 
|  | 231 | #endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */ | 
|  | 232 |  | 
|  | 233 | #if  __ANDROID_API__ >= __ANDROID_API_J_MR2__ | 
|  | 234 | __BIONIC_FORTIFY_INLINE | 
| Elliott Hughes | 3f66e74 | 2017-08-01 13:24:40 -0700 | [diff] [blame] | 235 | char* strchr(const char* const s __pass_object_size, int c) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 236 | size_t bos = __bos(s); | 
|  | 237 |  | 
|  | 238 | if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 239 | return __builtin_strchr(s, c); | 
|  | 240 | } | 
|  | 241 |  | 
|  | 242 | return __strchr_chk(s, c, bos); | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 | __BIONIC_FORTIFY_INLINE | 
| Elliott Hughes | 3f66e74 | 2017-08-01 13:24:40 -0700 | [diff] [blame] | 246 | char* strrchr(const char* const s __pass_object_size, int c) __overloadable { | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 247 | size_t bos = __bos(s); | 
|  | 248 |  | 
|  | 249 | if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) { | 
|  | 250 | return __builtin_strrchr(s, c); | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | return __strrchr_chk(s, c, bos); | 
|  | 254 | } | 
|  | 255 | #endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */ | 
|  | 256 |  | 
| Elliott Hughes | df9a489 | 2017-08-23 14:34:03 -0700 | [diff] [blame] | 257 | #if __ANDROID_API__ >= __ANDROID_API_M__ | 
|  | 258 | #if defined(__cplusplus) | 
|  | 259 | extern "C++" { | 
|  | 260 | __BIONIC_FORTIFY_INLINE | 
|  | 261 | void* memrchr(void* const __pass_object_size s, int c, size_t n) { | 
|  | 262 | return __memrchr_fortify(s, c, n); | 
|  | 263 | } | 
|  | 264 |  | 
|  | 265 | __BIONIC_FORTIFY_INLINE | 
|  | 266 | const void* memrchr(const void* const __pass_object_size s, int c, size_t n) { | 
|  | 267 | return __memrchr_fortify(s, c, n); | 
|  | 268 | } | 
|  | 269 | } | 
|  | 270 | #else | 
|  | 271 | __BIONIC_FORTIFY_INLINE | 
|  | 272 | void* memrchr(const void* const __pass_object_size s, int c, size_t n) __overloadable { | 
|  | 273 | return __memrchr_fortify(s, c, n); | 
|  | 274 | } | 
|  | 275 | #endif | 
|  | 276 | #endif /* __ANDROID_API__ >= __ANDROID_API_M__ */ | 
|  | 277 |  | 
| George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 278 | #endif /* defined(__BIONIC_FORTIFY) */ |