Ignore:
Timestamp:
Apr 26, 2017, 2:29:23 PM (4 years ago)
Author:
alain
Message:

Merge all FS related files in one single vfs directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/memcpy.c

    r1 r11  
    2323
    2424#include <hal_types.h>
     25#include <printk.h>
    2526
    2627/////////////////////////////////
     
    3233    const uint32_t * wsrc = src;
    3334
     35    // word per word copy if both addresses aligned
    3436    if (!((uint32_t) wdst & 3) && !((uint32_t) wsrc & 3) )
    3537    {
     
    4446    unsigned char *csrc = (unsigned char*)wsrc;
    4547
     48    // byte per byte for last bytes (or not aligned)
    4649    while (size--)
    4750    {
     
    5154}
    5255
    53 ///////////////////////////
    54 void * memset( void   * dst,
    55                int      s,
    56                uint32_t size)
     56//////////////////////////////
     57void * memset( void     * dst,
     58               uint32_t   val,
     59               uint32_t   size)
    5760{
    58     char * a = (char *) dst;
    59     while (size--)
     61    // build 8 bits and 32 bits values
     62    uint8_t    byte = (uint8_t)(val & 0xFF);
     63    uint32_t   word = (val<<24) | (val<<16) | (val<<8) | val;
     64
     65    // word per word if address aligned
     66    uint32_t * wdst = (uint32_t *)dst;
     67
     68    if( (((uint32_t)dst) & 0x3) == 0 )
    6069    {
    61         *a++ = (char)s;
     70        while( size > 3 )
     71        {
     72            *wdst++ = word;
     73            size -= 4;
     74        }
    6275    }
     76
     77    // byte per byte for last bytes (or not aligned)
     78    char * cdst = (char *)wdst;
     79
     80    while( size-- )
     81    {
     82        *cdst++ = byte;
     83    }
     84
    6385    return dst;
    6486}
Note: See TracChangeset for help on using the changeset viewer.