Changeset 7f079d9 in mainline for libc/generic/string.c


Ignore:
Timestamp:
2006-06-03T01:24:33Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0861786
Parents:
6c46350
Message:

Tetris now works on mips on gxemul on both console & framebuffer.
It doesn't work in msim, but it seems to be msim bug this time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/string.c

    r6c46350 r7f079d9  
    3131#include <ctype.h>
    3232#include <limits.h>
     33#include <align.h>
    3334
    3435
     
    4344}
    4445
     46struct along {unsigned long n; } __attribute__ ((packed));
     47
     48static 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
    4563void * memcpy(void *dst, const void *src, size_t n)
    4664{
    4765        int i, j;
     66
     67        if (((long)dst & (sizeof(long)-1)) || ((long)src & (sizeof(long)-1)))
     68                return unaligned_memcpy(dst, src, n);
    4869
    4970        for (i = 0; i < n/sizeof(unsigned long); i++)
Note: See TracChangeset for help on using the changeset viewer.