Subversion Repositories HelenOS-historic

Rev

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
                "rep movsq\n\t"
55
                "rep movsq\n\t"
56
                "movq %4, %%rcx\n\t"
56
                "movq %4, %%rcx\n\t"
57
                "andq $7, %%rcx\n\t"
57
                "andq $7, %%rcx\n\t"
58
                "jz 1f\n\t"
58
                "jz 1f\n\t"
59
                "rep movsb\n\t"
59
                "rep movsb\n\t"
60
                "1:\n"
60
                "1:\n"
61
                : "=&c" (d0), "=&D" (d1), "=&S" (d2)
61
                : "=&c" (d0), "=&D" (d1), "=&S" (d2)
62
                : "0" ((__native)(cnt / 8)), "g" ((__native)cnt), "1" ((__native) dst), "2" ((__native) src)
62
                : "0" ((unative_t)(cnt / 8)), "g" ((unative_t)cnt), "1" ((unative_t) dst), "2" ((unative_t) src)
63
                : "memory");
63
                : "memory");
64
 
64
 
65
        return dst;
65
        return dst;
66
}
66
}
67
 
67
 
Line 77... Line 77...
77
 * @param cnt Number of bytes
77
 * @param cnt Number of bytes
78
 * @return Zero if bytes are equal, non-zero otherwise
78
 * @return Zero if bytes are equal, non-zero otherwise
79
 */
79
 */
80
static inline int memcmp(const void * src, const void * dst, size_t cnt)
80
static inline int memcmp(const void * src, const void * dst, size_t cnt)
81
{
81
{
82
    __native d0, d1, d2;
82
    unative_t d0, d1, d2;
83
    __native ret;
83
    unative_t ret;
84
   
84
   
85
    __asm__ (
85
    __asm__ (
86
        "repe cmpsb\n\t"
86
        "repe cmpsb\n\t"
87
        "je 1f\n\t"
87
        "je 1f\n\t"
88
        "movq %3, %0\n\t"
88
        "movq %3, %0\n\t"
89
        "addq $1, %0\n\t"
89
        "addq $1, %0\n\t"
90
        "1:\n"
90
        "1:\n"
91
        : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2)
91
        : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2)
92
        : "0" (0), "1" (src), "2" (dst), "3" ((__native)cnt)
92
        : "0" (0), "1" (src), "2" (dst), "3" ((unative_t)cnt)
93
    );
93
    );
94
   
94
   
95
    return ret;
95
    return ret;
96
}
96
}
97
 
97
 
Line 102... Line 102...
102
 *
102
 *
103
 * @param dst Destination
103
 * @param dst Destination
104
 * @param cnt Number of words
104
 * @param cnt Number of words
105
 * @param x Value to fill
105
 * @param x Value to fill
106
 */
106
 */
107
static inline void memsetw(__address dst, size_t cnt, __u16 x)
107
static inline void memsetw(uintptr_t dst, size_t cnt, uint16_t x)
108
{
108
{
109
    __native d0, d1;
109
    unative_t d0, d1;
110
   
110
   
111
    __asm__ __volatile__ (
111
    __asm__ __volatile__ (
112
        "rep stosw\n\t"
112
        "rep stosw\n\t"
113
        : "=&D" (d0), "=&c" (d1), "=a" (x)
113
        : "=&D" (d0), "=&c" (d1), "=a" (x)
114
        : "0" (dst), "1" ((__native)cnt), "2" (x)
114
        : "0" (dst), "1" ((unative_t)cnt), "2" (x)
115
        : "memory"
115
        : "memory"
116
    );
116
    );
117
 
117
 
118
}
118
}
119
 
119
 
Line 124... Line 124...
124
 *
124
 *
125
 * @param dst Destination
125
 * @param dst Destination
126
 * @param cnt Number of bytes
126
 * @param cnt Number of bytes
127
 * @param x Value to fill
127
 * @param x Value to fill
128
 */
128
 */
129
static inline void memsetb(__address dst, size_t cnt, __u8 x)
129
static inline void memsetb(uintptr_t dst, size_t cnt, uint8_t x)
130
{
130
{
131
    __native d0, d1;
131
    unative_t d0, d1;
132
   
132
   
133
    __asm__ __volatile__ (
133
    __asm__ __volatile__ (
134
        "rep stosb\n\t"
134
        "rep stosb\n\t"
135
        : "=&D" (d0), "=&c" (d1), "=a" (x)
135
        : "=&D" (d0), "=&c" (d1), "=a" (x)
136
        : "0" (dst), "1" ((__native)cnt), "2" (x)
136
        : "0" (dst), "1" ((unative_t)cnt), "2" (x)
137
        : "memory"
137
        : "memory"
138
    );
138
    );
139
 
139
 
140
}
140
}
141
 
141