1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (fastcpy.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 /* in the future ASM and new c++ features can be added to speed up copying */
26 #include <retro_inline.h>
28 static INLINE void* memcpy16(void* dst,void* src,size_t size)
30 return memcpy(dst,src,size * 2);
33 static INLINE void* memcpy32(void* dst,void* src,size_t size)
35 return memcpy(dst,src,size * 4);
38 static INLINE void* memcpy64(void* dst,void* src,size_t size)
40 return memcpy(dst,src,size * 8);
46 static INLINE void* memset16(void* dst,uint16_t val,size_t size)
48 uint16_t *typedptr = (uint16_t*)dst;
49 std::fill(typedptr, typedptr + size, val);
53 static INLINE void* memset32(void* dst,uint32_t val,size_t size)
55 uint32_t *typedptr = (uint32_t*)dst;
56 std::fill(typedptr, typedptr + size, val);
60 static INLINE void* memset64(void* dst,uint64_t val,size_t size)
62 uint64_t *typedptr = (uint64_t*)dst;
63 std::fill(typedptr, typedptr + size, val);
67 static INLINE void *memset16(void* dst,uint16_t val,size_t size)
70 uint16_t *typedptr = (uint16_t*)dst;
71 for (i = 0;i < size;i++)
76 static INLINE void *memset32(void* dst,uint32_t val,size_t size)
79 uint32_t *typedptr = (uint32_t*)dst;
80 for (i = 0; i < size; i++)
85 static INLINE void *memset64(void* dst,uint64_t val,size_t size)
88 uint64_t *typedptr = (uint64_t*)dst;
89 for (i = 0; i < size;i++)