Rev 1702 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1702 | Rev 1780 | ||
|---|---|---|---|
| Line 47... | Line 47... | ||
| 47 | * @param cnt Number of bytes |
47 | * @param cnt Number of bytes |
| 48 | * @return Destination |
48 | * @return Destination |
| 49 | */ |
49 | */ |
| 50 | static inline void * memcpy(void * dst, const void * src, size_t cnt) |
50 | static inline void * memcpy(void * dst, const void * src, size_t cnt) |
| 51 | { |
51 | { |
| 52 | __native d0, d1, d2; |
52 | unative_t d0, d1, d2; |
| 53 | 53 | ||
| 54 | __asm__ __volatile__( |
54 | __asm__ __volatile__( |
| 55 | /* copy all full dwords */ |
55 | /* copy all full dwords */ |
| 56 | "rep movsl\n\t" |
56 | "rep movsl\n\t" |
| 57 | /* load count again */ |
57 | /* load count again */ |
| Line 63... | Line 63... | ||
| 63 | /* copy last <=3 bytes */ |
63 | /* copy last <=3 bytes */ |
| 64 | "rep movsb\n\t" |
64 | "rep movsb\n\t" |
| 65 | /* exit from asm block */ |
65 | /* exit from asm block */ |
| 66 | "1:\n" |
66 | "1:\n" |
| 67 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) |
67 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) |
| 68 | : "0" ((__native) (cnt / 4)), "g" ((__native) cnt), "1" ((__native) dst), "2" ((__native) src) |
68 | : "0" ((unative_t) (cnt / 4)), "g" ((unative_t) cnt), "1" ((unative_t) dst), "2" ((unative_t) src) |
| 69 | : "memory"); |
69 | : "memory"); |
| 70 | 70 | ||
| 71 | return dst; |
71 | return dst; |
| 72 | } |
72 | } |
| 73 | 73 | ||
| Line 83... | Line 83... | ||
| 83 | * @param cnt Number of bytes |
83 | * @param cnt Number of bytes |
| 84 | * @return Zero if bytes are equal, non-zero otherwise |
84 | * @return Zero if bytes are equal, non-zero otherwise |
| 85 | */ |
85 | */ |
| 86 | static inline int memcmp(const void * src, const void * dst, size_t cnt) |
86 | static inline int memcmp(const void * src, const void * dst, size_t cnt) |
| 87 | { |
87 | { |
| 88 | __u32 d0, d1, d2; |
88 | uint32_t d0, d1, d2; |
| 89 | int ret; |
89 | int ret; |
| 90 | 90 | ||
| 91 | __asm__ ( |
91 | __asm__ ( |
| 92 | "repe cmpsb\n\t" |
92 | "repe cmpsb\n\t" |
| 93 | "je 1f\n\t" |
93 | "je 1f\n\t" |
| 94 | "movl %3, %0\n\t" |
94 | "movl %3, %0\n\t" |
| 95 | "addl $1, %0\n\t" |
95 | "addl $1, %0\n\t" |
| 96 | "1:\n" |
96 | "1:\n" |
| 97 | : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2) |
97 | : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2) |
| 98 | : "0" (0), "1" ((__native) src), "2" ((__native) dst), "3" ((__native) cnt) |
98 | : "0" (0), "1" ((unative_t) src), "2" ((unative_t) dst), "3" ((unative_t) cnt) |
| 99 | ); |
99 | ); |
| 100 | 100 | ||
| 101 | return ret; |
101 | return ret; |
| 102 | } |
102 | } |
| 103 | 103 | ||
| Line 108... | Line 108... | ||
| 108 | * |
108 | * |
| 109 | * @param dst Destination |
109 | * @param dst Destination |
| 110 | * @param cnt Number of words |
110 | * @param cnt Number of words |
| 111 | * @param x Value to fill |
111 | * @param x Value to fill |
| 112 | */ |
112 | */ |
| 113 | static inline void memsetw(__address dst, size_t cnt, __u16 x) |
113 | static inline void memsetw(uintptr_t dst, size_t cnt, uint16_t x) |
| 114 | { |
114 | { |
| 115 | __u32 d0, d1; |
115 | uint32_t d0, d1; |
| 116 | 116 | ||
| 117 | __asm__ __volatile__ ( |
117 | __asm__ __volatile__ ( |
| 118 | "rep stosw\n\t" |
118 | "rep stosw\n\t" |
| 119 | : "=&D" (d0), "=&c" (d1), "=a" (x) |
119 | : "=&D" (d0), "=&c" (d1), "=a" (x) |
| 120 | : "0" (dst), "1" (cnt), "2" (x) |
120 | : "0" (dst), "1" (cnt), "2" (x) |
| Line 130... | Line 130... | ||
| 130 | * |
130 | * |
| 131 | * @param dst Destination |
131 | * @param dst Destination |
| 132 | * @param cnt Number of bytes |
132 | * @param cnt Number of bytes |
| 133 | * @param x Value to fill |
133 | * @param x Value to fill |
| 134 | */ |
134 | */ |
| 135 | static inline void memsetb(__address dst, size_t cnt, __u8 x) |
135 | static inline void memsetb(uintptr_t dst, size_t cnt, uint8_t x) |
| 136 | { |
136 | { |
| 137 | __u32 d0, d1; |
137 | uint32_t d0, d1; |
| 138 | 138 | ||
| 139 | __asm__ __volatile__ ( |
139 | __asm__ __volatile__ ( |
| 140 | "rep stosb\n\t" |
140 | "rep stosb\n\t" |
| 141 | : "=&D" (d0), "=&c" (d1), "=a" (x) |
141 | : "=&D" (d0), "=&c" (d1), "=a" (x) |
| 142 | : "0" (dst), "1" (cnt), "2" (x) |
142 | : "0" (dst), "1" (cnt), "2" (x) |