Changeset 8ecef91 in mainline


Ignore:
Timestamp:
2011-07-13T16:06:17Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
27eddb52, e4f8c77
Parents:
6817eba
Message:

Implement functions in strings.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/strings.c

    r6817eba r8ecef91  
    4242#include "ctype.h"
    4343
     44#include "libc/mem.h"
     45
    4446/**
    4547 *
     
    4951int posix_ffs(int i)
    5052{
    51         // TODO
    52         not_implemented();
     53        if (i == 0) {
     54                return 0;
     55        }
     56
     57        int result = 0;
     58
     59        // XXX: assumes at most 32-bit int
     60        if (!(i & 0xFFFF)) {
     61                result |= 16;
     62                i >>= 16;
     63        }
     64        if (!(i & 0xFF)) {
     65                result |= 8;
     66                i >>= 8;
     67        }
     68        if (!(i & 0xF)) {
     69                result |= 4;
     70                i >>= 4;
     71        }
     72        if (!(i & 0x3)) {
     73                result |= 2;
     74                i >>= 2;
     75        }
     76        if (!(i & 0x1)) {
     77                result |= 1;
     78        }
     79
     80        return result + 1;
    5381}
    5482
     
    96124int posix_bcmp(const void *mem1, const void *mem2, size_t n)
    97125{
    98         // TODO
    99         not_implemented();
     126        return bcmp(mem1, mem2, n);
    100127}
    101128
     
    108135void posix_bcopy(const void *dest, void *src, size_t n)
    109136{
    110         // TODO
    111         not_implemented();
     137        /* Note that memmove has different order of arguments. */
     138        memmove(src, dest, n);
    112139}
    113140
     
    119146void posix_bzero(void *mem, size_t n)
    120147{
    121         // TODO
    122         not_implemented();
     148        bzero(mem, n);
    123149}
    124150
Note: See TracChangeset for help on using the changeset viewer.