Subversion Repositories HelenOS-historic

Rev

Rev 1530 | Rev 1653 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1530 Rev 1538
Line 28... Line 28...
28
 
28
 
29
#include <string.h>
29
#include <string.h>
30
#include <unistd.h>
30
#include <unistd.h>
31
#include <ctype.h>
31
#include <ctype.h>
32
#include <limits.h>
32
#include <limits.h>
-
 
33
#include <align.h>
33
 
34
 
34
 
35
 
35
/* Dummy implementation of mem/ functions */
36
/* Dummy implementation of mem/ functions */
36
 
37
 
37
void * memset(void *s, int c, size_t n)
38
void * memset(void *s, int c, size_t n)
Line 40... Line 41...
40
    while (n--)
41
    while (n--)
41
        *(os++) = c;
42
        *(os++) = c;
42
    return s;
43
    return s;
43
}
44
}
44
 
45
 
-
 
46
struct along {unsigned long n; } __attribute__ ((packed));
-
 
47
 
-
 
48
static void * unaligned_memcpy(void *dst, const void *src, size_t n)
-
 
49
{
-
 
50
    int i, j;
-
 
51
    struct along *adst = dst;
-
 
52
    const struct along *asrc = src;
-
 
53
 
-
 
54
    for (i = 0; i < n/sizeof(unsigned long); i++)
-
 
55
        adst[i].n = asrc[i].n;
-
 
56
       
-
 
57
    for (j = 0; j < n%sizeof(unsigned long); j++)
-
 
58
        ((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j];
-
 
59
       
-
 
60
    return (char *)src;
-
 
61
}
-
 
62
 
45
void * memcpy(void *dst, const void *src, size_t n)
63
void * memcpy(void *dst, const void *src, size_t n)
46
{
64
{
47
    int i, j;
65
    int i, j;
48
 
66
 
-
 
67
    if (((long)dst & (sizeof(long)-1)) || ((long)src & (sizeof(long)-1)))
-
 
68
        return unaligned_memcpy(dst, src, n);
-
 
69
 
49
    for (i = 0; i < n/sizeof(unsigned long); i++)
70
    for (i = 0; i < n/sizeof(unsigned long); i++)
50
        ((unsigned long *) dst)[i] = ((unsigned long *) src)[i];
71
        ((unsigned long *) dst)[i] = ((unsigned long *) src)[i];
51
       
72
       
52
    for (j = 0; j < n%sizeof(unsigned long); j++)
73
    for (j = 0; j < n%sizeof(unsigned long); j++)
53
        ((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j];
74
        ((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j];