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

Changeset 1715b7fe in mainline


Ignore:
Timestamp:
2013-03-25T19:42:07Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
5c4356b
Parents:
2a08005
Message:

implement memcpy() and memset() using builtin functions

Location:
boot/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/include/memstr.h

    r2a08005 r1715b7fe  
    3636
    3737extern void *memcpy(void *, const void *, size_t);
     38extern void *memset(void *, int, size_t);
    3839extern void *memmove(void *, const void *, size_t);
    3940
  • boot/generic/src/memstr.c

    r2a08005 r1715b7fe  
    3535 * memory areas cannot overlap.
    3636 *
    37  * @param src           Source address to copy from.
    38  * @param dst           Destination address to copy to.
    39  * @param cnt           Number of bytes to copy.
     37 * @param src Source address to copy from.
     38 * @param dst Destination address to copy to.
     39 * @param cnt Number of bytes to copy.
    4040 *
    41  * @return              Destination address.
     41 * @return Destination address.
     42 *
    4243 */
    4344void *memcpy(void *dst, const void *src, size_t cnt)
    4445{
    45         size_t i;
     46        return __builtin_memcpy(dst, src, cnt);
     47}
    4648
    47         for (i = 0; i < cnt; i++)
    48                 ((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
    49 
    50         return dst;
     49/** Fill block of memory.
     50 *
     51 * Fill cnt bytes at dst address with the value val.
     52 *
     53 * @param dst Destination address to fill.
     54 * @param val Value to fill.
     55 * @param cnt Number of bytes to fill.
     56 *
     57 * @return Destination address.
     58 *
     59 */
     60void *memset(void *dst, int val, size_t cnt)
     61{
     62        return __builtin_memset(dst, val, cnt);
    5163}
    5264
Note: See TracChangeset for help on using the changeset viewer.