Changeset b169619 in mainline for common/stdc/mem.c


Ignore:
Timestamp:
2023-10-27T17:38:32Z (15 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, topic/msim-upgrade, topic/simplify-dev-export
Children:
44e8541
Parents:
c89ae25
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-27 13:19:20)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-27 17:38:32)
Message:

Deduplicate mem functions

There are a number of functions which are copied between
kernel, libc, and potentially boot too. mem*() functions
are first such offenders. All this duplicate code will
be moved to directory 'common'.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • common/stdc/mem.c

    rc89ae25 rb169619  
    3434 */
    3535
    36 #include <mem.h>
     36#include "../include/mem.h"
     37
    3738#include <stdlib.h>
    3839#include <stddef.h>
    3940#include <stdint.h>
    40 #include "private/cc.h"
     41#include "cc.h"
     42
     43#undef memset
     44#undef memcpy
     45#undef memcmp
     46#undef memmove
     47#undef memchr
    4148
    4249/** Fill memory block with a constant value. */
     50DO_NOT_DISCARD
    4351ATTRIBUTE_OPTIMIZE_NO_TLDP
    4452    void *memset(void *dest, int b, size_t n)
     
    99107} __attribute__((packed));
    100108
    101 static void *unaligned_memcpy(void *dst, const void *src, size_t n)
     109ATTRIBUTE_OPTIMIZE_NO_TLDP
     110    static void *unaligned_memcpy(void *dst, const void *src, size_t n)
    102111{
    103112        size_t i, j;
     
    116125
    117126/** Copy memory block. */
     127DO_NOT_DISCARD
    118128ATTRIBUTE_OPTIMIZE_NO_TLDP
    119129    void *memcpy(void *dst, const void *src, size_t n)
     
    194204
    195205/** Move memory block with possible overlapping. */
     206DO_NOT_DISCARD
     207ATTRIBUTE_OPTIMIZE_NO_TLDP
    196208void *memmove(void *dst, const void *src, size_t n)
    197209{
     
    239251 *
    240252 */
    241 int memcmp(const void *s1, const void *s2, size_t len)
     253DO_NOT_DISCARD
     254ATTRIBUTE_OPTIMIZE_NO_TLDP
     255    int memcmp(const void *s1, const void *s2, size_t len)
    242256{
    243257        uint8_t *u1 = (uint8_t *) s1;
     
    264278 *         bytes of @a s or @c NULL if not found.
    265279 */
     280DO_NOT_DISCARD
     281ATTRIBUTE_OPTIMIZE_NO_TLDP
    266282void *memchr(const void *s, int c, size_t n)
    267283{
Note: See TracChangeset for help on using the changeset viewer.