Rick Chen | 6020faf | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Andes Technology Corporation |
| 3 | * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com) |
| 4 | * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com) |
| 5 | * Copyright (C) 2017 Rick Chen (rick@andestech.com) |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
| 10 | */ |
| 11 | |
| 12 | #ifndef __ASM_RISCV_STRING_H |
| 13 | #define __ASM_RISCV_STRING_H |
| 14 | |
| 15 | /* |
| 16 | * We don't do inline string functions, since the |
| 17 | * optimised inline asm versions are not small. |
| 18 | */ |
| 19 | |
| 20 | #undef __HAVE_ARCH_STRRCHR |
| 21 | #undef __HAVE_ARCH_STRCHR |
| 22 | #undef __HAVE_ARCH_MEMCPY |
| 23 | #undef __HAVE_ARCH_MEMMOVE |
| 24 | #undef __HAVE_ARCH_MEMCHR |
| 25 | #undef __HAVE_ARCH_MEMZERO |
| 26 | #undef __HAVE_ARCH_MEMSET |
| 27 | |
| 28 | #ifdef CONFIG_MARCO_MEMSET |
Rick Chen | bc0818a | 2018-02-12 11:07:58 +0800 | [diff] [blame] | 29 | #define memset(_p, _v, _n) \ |
| 30 | (typeof(_p) (p) = (_p); \ |
| 31 | typeof(_v) (v) = (_v); \ |
| 32 | typeof(_n) (n) = (_n); \ |
| 33 | { \ |
Rick Chen | 6020faf | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 34 | if ((n) != 0) { \ |
| 35 | if (__builtin_constant_p((v)) && (v) == 0) \ |
| 36 | __memzero((p), (n)); \ |
| 37 | else \ |
| 38 | memset((p), (v), (n)); \ |
| 39 | } \ |
| 40 | (p); \ |
| 41 | }) |
| 42 | |
Rick Chen | bc0818a | 2018-02-12 11:07:58 +0800 | [diff] [blame] | 43 | #define memzero(_p, _n) \ |
| 44 | (typeof(_p) (p) = (_p); \ |
| 45 | typeof(_n) (n) = (_n); \ |
| 46 | { if ((n) != 0) __memzero((p), (n)); (p); }) |
Rick Chen | 6020faf | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 47 | #endif |
| 48 | |
| 49 | #endif /* __ASM_RISCV_STRING_H */ |