shared/libc/string0: Don't include string.h, and provide __memcpy_chk.
Some toolchains will have string.h defining various macros which can lead to compile errors for string function implementations. Not including string.h fixes this. An implementation of __memcpy_chk is provided for toolchains that enable _FORTIFY_SOURCE. Fixes issue #6046. Signed-off-by: Alexey 'alexxy' Shvetsov <alexxyum@gmail.com>
This commit is contained in:
parent
d11ff0499f
commit
5cf71b5596
|
@ -25,7 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define likely(x) __builtin_expect((x), 1)
|
#define likely(x) __builtin_expect((x), 1)
|
||||||
|
|
||||||
|
@ -64,6 +64,13 @@ void *memcpy(void *dst, const void *src, size_t n) {
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) {
|
||||||
|
if (len > slen) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return memcpy(dest, src, len);
|
||||||
|
}
|
||||||
|
|
||||||
void *memmove(void *dest, const void *src, size_t n) {
|
void *memmove(void *dest, const void *src, size_t n) {
|
||||||
if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) {
|
if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) {
|
||||||
// need to copy backwards
|
// need to copy backwards
|
||||||
|
|
Loading…
Reference in New Issue