Changeset 8e3f47b3 in mainline for arch/ia32/include/memstr.h


Ignore:
Timestamp:
2005-10-04T22:06:07Z (20 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1084a784
Parents:
ce031f0
Message:

ia-32 memcmp inline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/include/memstr.h

    rce031f0 r8e3f47b3  
    3232extern void memsetw(__address dst, size_t cnt, __u16 x);
    3333extern void memsetb(__address dst, size_t cnt, __u8 x);
    34 
    35 extern int memcmp(__address src, __address dst, int cnt);
    3634
    3735/** Copy memory
     
    7270
    7371
     72/** Compare memory
     73 *
     74 * Compare a given number of bytes (3rd argument)
     75 * at memory locations defined by 1st and 2nd argument
     76 * for equality. If memory is equal, returns 0.
     77 *
     78 * @param pointer 1
     79 * @param pointer 2
     80 * @param number of bytes
     81 * @return 0 on match or non-zero if different
     82 */
     83static inline int memcmp(const void * mem1, const void * mem2, size_t cnt)
     84{
     85        __u32 d0, d1, d2;
     86        int ret;
     87       
     88        __asm__ (
     89                "repe cmpsb\n\t"
     90                "je 1f\n\t"
     91                "movl %3, %0\n\t"
     92                "addl $1, %0\n\t"
     93                "1:\n"
     94                : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2)
     95                : "0" (0), "1" (mem1), "2" (mem2), "3" (cnt)
     96        );
     97       
     98        return ret;
     99}
    74100
    75101#endif
Note: See TracChangeset for help on using the changeset viewer.