Changeset 8a5a902 in mainline for boot/generic/src/memstr.c


Ignore:
Timestamp:
2013-03-29T16:26:39Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ca441c
Parents:
2d1195c0
Message:

GCC 4.8 recognizes parts of our C implementation of memset() and memcpy() and actually emits a call to memset() and memcpy()
(which is of course futile and only causes an infinite recursion)
switch to a hand-written memset() and memcpy()

File:
1 edited

Legend:

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

    r2d1195c0 r8a5a902  
    2929#include <memstr.h>
    3030#include <typedefs.h>
    31 
    32 /** Move memory block without overlapping.
    33  *
    34  * Copy cnt bytes from src address to dst address. The source
    35  * and destination memory areas cannot overlap.
    36  *
    37  * @param dst Destination address to copy to.
    38  * @param src Source address to copy from.
    39  * @param cnt Number of bytes to copy.
    40  *
    41  * @return Destination address.
    42  *
    43  */
    44 void *memcpy(void *dst, const void *src, size_t cnt)
    45 {
    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;
    53 }
    54 
    55 /** Fill block of memory.
    56  *
    57  * Fill cnt bytes at dst address with the value val.
    58  *
    59  * @param dst Destination address to fill.
    60  * @param val Value to fill.
    61  * @param cnt Number of bytes to fill.
    62  *
    63  * @return Destination address.
    64  *
    65  */
    66 void *memset(void *dst, int val, size_t cnt)
    67 {
    68         uint8_t *dp = (uint8_t *) dst;
    69        
    70         while (cnt-- != 0)
    71                 *dp++ = val;
    72        
    73         return dst;
    74 }
    7531
    7632/** Move memory block with possible overlapping.
Note: See TracChangeset for help on using the changeset viewer.