Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5d9fce4 in mainline


Ignore:
Timestamp:
2013-03-27T17:16:46Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
26c02b22, c6a7b3a
Parents:
5c4356b
Message:

using builtin_memcpy() and builtin_memset() actually emits calls to memcpy() and memset()
if the size argument cannot be determined at compile time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/src/memstr.c

    r5c4356b r5d9fce4  
    3030#include <typedefs.h>
    3131
    32 /** Copy block of memory.
     32/** Move memory block without overlapping.
    3333 *
    34  * Copy cnt bytes from src address to dst address.The source and destination
    35  * memory areas cannot overlap.
     34 * Copy cnt bytes from src address to dst address. The source
     35 * and destination memory areas cannot overlap.
    3636 *
     37 * @param dst Destination address to copy to.
    3738 * @param src Source address to copy from.
    38  * @param dst Destination address to copy to.
    3939 * @param cnt Number of bytes to copy.
    4040 *
     
    4444void *memcpy(void *dst, const void *src, size_t cnt)
    4545{
    46         return __builtin_memcpy(dst, src, cnt);
     46        uint8_t *dp = (uint8_t *) dst;
     47        const uint8_t *sp = (uint8_t *) src;
     48       
     49        while (cnt-- != 0)
     50                *dp++ = *sp++;
     51       
     52        return dst;
    4753}
    4854
     
    6066void *memset(void *dst, int val, size_t cnt)
    6167{
    62         return __builtin_memset(dst, val, cnt);
     68        uint8_t *dp = (uint8_t *) dst;
     69       
     70        while (cnt-- != 0)
     71                *dp++ = val;
     72       
     73        return dst;
    6374}
    6475
Note: See TracChangeset for help on using the changeset viewer.