From: loth AT gec DOT net (Burton Radons) To: djgpp-workers AT delorie DOT com Subject: libc replacement (bcmp) Date: Tue, 17 Mar 1998 12:57:22 GMT Message-ID: <35107243.35844972@mail.gec.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Precedence: bulk See original message (Nearly same subject). bcmp is only a modified memcmp. I haven't benchmarked it -- it shouldn't be significantly different. I have, of course, tested it. - Burton Radons, loth AT gec DOT net Vancouver Island, British Columbia, Canada *** src/new/bcmp.c Tue Mar 17 04:42:48 1998 --- src/libc/compat/bsd/bcmp.c Wed Aug 23 00:56:02 1995 *************** *** 1,4 **** ! /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ #include #undef bcmp --- 1,4 ---- ! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #undef bcmp *************** *** 12,45 **** if (ptr1 == 0 || ptr2 == 0) return -1; ! if (length != 0) { ! const unsigned char *p1 = ptr1; ! const unsigned char *p2 = ptr2; ! ! while (length > 4) { ! if (*((int *) p1) != *((int *) p2)) { ! if (*((short *) p1) != *((short *) p2)) { ! if (*p1 != *p2) ! return length; ! ! return length - 1; ! } ! ! if (p1[2] != p2[2]) ! return length - 2; ! ! return length - 3; ! } ! ! p1 += 4; ! p2 += 4; ! length -= 4; ! } ! ! for (; length; length --) ! if (*p1++ != *p2++) ! return length; } return 0; --- 12,22 ---- if (ptr1 == 0 || ptr2 == 0) return -1; ! while (length) { ! if (*((const char *)ptr1)++ != *((const char *)ptr2)++) ! return length; ! length--; } return 0;