X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fstring.h;h=38d3baba9dae20d5765d1539d6dc9069653f207c;hb=4141ded3ec876313a5c7f74a93dec3e18940180a;hp=0b187672816fbec5ddf3409c54d3ae5637d63e51;hpb=137d4ca67bb525f2e2214cc42c2cb3866fc16dc4;p=vpp.git diff --git a/src/vppinfra/string.h b/src/vppinfra/string.h index 0b187672816..38d3baba9da 100644 --- a/src/vppinfra/string.h +++ b/src/vppinfra/string.h @@ -47,7 +47,9 @@ #include /* for CLIB_LINUX_KERNEL */ #include #include +#ifdef __SSE4_2__ #include +#endif #ifdef CLIB_LINUX_KERNEL #include @@ -77,7 +79,7 @@ clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n) "behaviour"); #if defined(__COVERITY__) return memcpy (dst, src, n); -#elif defined(__x86_64__) +#elif defined(__SSE4_2__) clib_memcpy_x86_64 (dst, src, n); return dst; #else @@ -85,6 +87,25 @@ clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n) #endif } +static_always_inline void * +clib_memmove (void *dst, const void *src, size_t n) +{ + u8 *d = (u8 *) dst; + u8 *s = (u8 *) src; + + if (s == d) + return d; + + if (d > s) + for (uword i = n - 1; (i + 1) > 0; i--) + d[i] = s[i]; + else + for (uword i = 0; i < n; i++) + d[i] = s[i]; + + return d; +} + #include /* c-11 string manipulation variants */