RetroArch
fastcpy.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (fastcpy.h).
5  * ---------------------------------------------------------------------------------------
6  *
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:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
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.
21  */
22 
23 /* in the future ASM and new c++ features can be added to speed up copying */
24 #include <stdint.h>
25 #include <string.h>
26 #include <retro_inline.h>
27 
28 static INLINE void* memcpy16(void* dst,void* src,size_t size)
29 {
30  return memcpy(dst,src,size * 2);
31 }
32 
33 static INLINE void* memcpy32(void* dst,void* src,size_t size)
34 {
35  return memcpy(dst,src,size * 4);
36 }
37 
38 static INLINE void* memcpy64(void* dst,void* src,size_t size)
39 {
40  return memcpy(dst,src,size * 8);
41 }
42 
43 #ifdef USECPPSTDFILL
44 #include <algorithm>
45 
46 static INLINE void* memset16(void* dst,uint16_t val,size_t size)
47 {
48  uint16_t* typedptr = (uint16_t*)dst;
49  std::fill(typedptr, typedptr + size, val);
50  return dst;
51 }
52 
53 static INLINE void* memset32(void* dst,uint32_t val,size_t size)
54 {
55  uint32_t* typedptr = (uint32_t*)dst;
56  std::fill(typedptr, typedptr + size, val);
57  return dst;
58 }
59 
60 static INLINE void* memset64(void* dst,uint64_t val,size_t size)
61 {
62  uint64_t* typedptr = (uint64_t*)dst;
63  std::fill(typedptr, typedptr + size, val);
64  return dst;
65 }
66 #else
67 
68 static INLINE void* memset16(void* dst,uint16_t val,size_t size)
69 {
70  size_t i;
71  uint16_t* typedptr = (uint16_t*)dst;
72  for(i = 0;i < size;i++)
73  typedptr[i] = val;
74  return dst;
75 }
76 
77 static INLINE void* memset32(void* dst,uint32_t val,size_t size)
78 {
79  size_t i;
80  uint32_t* typedptr = (uint32_t*)dst;
81  for(i = 0;i < size;i++)
82  typedptr[i] = val;
83  return dst;
84 }
85 
86 static INLINE void* memset64(void* dst,uint64_t val,size_t size)
87 {
88  size_t i;
89  uint64_t* typedptr = (uint64_t*)dst;
90  for(i = 0;i < size;i++)
91  typedptr[i] = val;
92  return dst;
93 }
94 #endif
GLuint GLfloat * val
Definition: glext.h:7847
#define INLINE
Definition: retro_inline.h:35
static INLINE void * memcpy32(void *dst, void *src, size_t size)
Definition: fastcpy.h:33
GLsizeiptr size
Definition: glext.h:6559
static INLINE void * memset16(void *dst, uint16_t val, size_t size)
Definition: fastcpy.h:68
static INLINE void * memset64(void *dst, uint64_t val, size_t size)
Definition: fastcpy.h:86
GLenum src
Definition: glext.h:6980
static INLINE void * memcpy16(void *dst, void *src, size_t size)
Definition: fastcpy.h:28
static INLINE void * memcpy64(void *dst, void *src, size_t size)
Definition: fastcpy.h:38
GLenum GLenum dst
Definition: glext.h:6980
static INLINE void * memset32(void *dst, uint32_t val, size_t size)
Definition: fastcpy.h:77
unsigned short uint16_t
Definition: stdint.h:125
unsigned __int64 uint64_t
Definition: stdint.h:136
unsigned int uint32_t
Definition: stdint.h:126
void * memcpy(void *dst, const void *src, size_t len)
Definition: string.c:26