Changeset e4f8c77 in mainline for uspace/lib/posix/strings.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (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:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

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

    r5974661 re4f8c77  
    3838#include "internal/common.h"
    3939#include "strings.h"
     40
    4041#include "string.h"
    4142#include "ctype.h"
     43
     44#include "libc/mem.h"
    4245
    4346/**
     
    4851int posix_ffs(int i)
    4952{
    50         // TODO
    51         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;
    5281}
    5382
     
    95124int posix_bcmp(const void *mem1, const void *mem2, size_t n)
    96125{
    97         // TODO
    98         not_implemented();
     126        return bcmp(mem1, mem2, n);
    99127}
    100128
     
    107135void posix_bcopy(const void *dest, void *src, size_t n)
    108136{
    109         // TODO
    110         not_implemented();
     137        /* Note that memmove has different order of arguments. */
     138        memmove(src, dest, n);
    111139}
    112140
     
    118146void posix_bzero(void *mem, size_t n)
    119147{
    120         // TODO
    121         not_implemented();
     148        bzero(mem, n);
    122149}
    123150
Note: See TracChangeset for help on using the changeset viewer.