1 /*
2  * Copyright (c) 1994 William F. Jolitz.
3  * 386BSD Copyright Restrictions Apply. All Other Rights Reserved.
4  *
5  * $Id: memcmp.h,v 1.1 94/06/09 18:19:57 bill Exp Locker: bill $
6  * POSIX block memory compare.
7  */
8 
9 __INLINE int
memcmp(const void * s1,const void * s2,size_t len)10 memcmp(const void *s1, const void *s2, size_t len) {
11 	extern const int zero;		/* compiler bug workaround */
12 	const void *s2p = s2 + zero;	/* compiler bug workaround */
13 
14 	/* compare by words, then by bytes */
15 	asm volatile ("cld ; repe ; cmpsl ; jne 1f" :
16 	    "=D" (s1), "=S" (s2p) :
17 	    "0" (s1), "1" (s2p), "c" (len / 4));
18 	asm volatile ("repe ; cmpsb ; jne 1f" :
19 	    "=D" (s1), "=S" (s2p) :
20 	    "0" (s1), "1" (s2p), "c" (len & 3));
21 
22 	return (0);	/* exact match */
23 
24 	asm volatile ("1:");
25 	return (1);	/* failed match */
26 }
27