Xref: utzoo comp.lang.c:22252 comp.unix.questions:16559 comp.unix.wizards:18340 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!mcnc!rti!xyzzy!tiktok!meissner From: meissner@tiktok.dg.com (Michael Meissner) Newsgroups: comp.lang.c,comp.unix.questions,comp.unix.wizards Subject: Re: Bcopy, bzero and bcmp on a not-Berkeley machine Keywords: bcopy bzero bcmp berkely system_v Message-ID: <1350@xyzzy.UUCP> Date: 26 Sep 89 00:48:59 GMT References: <1155@radig.UUCP> Reply-To: meissner@tiktok.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 34 In article <1155@radig.UUCP> peter@radig.UUCP (Peter Radig) writes: | Is is possible to replace calls to `bcopy', `bzero' and `bcmp' by | the following macros: | | #ifdef USG | #define bcmp(s1,s2,cnt) memcpy(s1,s2,cnt) | #define bcopy(fr,to,cnt) memcpy(to,fr,cnt) | #define bzero(addr,cnt) memset(addr,'\0',cnt) | #endif USG | | or are there restrictions? Some programs that use bcopy depend on it 'doing the right thing' when given pointers to overlapping regions. The memcpy routine has no such guarantee. If your system vendor has added the new ANSI C routine `memmove', you can replace bcopy with a call to memmove. I would suspect memmove is not yet in most libraries. You could just hope and pray, you never have overlapping strings (or inspect the code, or write your own). Our database people found an interesting quirk -- they were doing *lots* of block moves of overlapping regions, and found that the hardware character move (which could move in either direction) was *noticably* faster moving left to right rather than right to left. It was so much of a difference, that it was faster to move the bytes into an automatic array, and then move them again than. I've seen some implementations of bcopy, et. al, that do the same thing (ie, optimize the common case, and revert to single byte load/stores for the overlapping case). -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner If compiles were much Internet: meissner@dg-rtp.DG.COM faster, when would we Old Internet: meissner%dg-rtp.DG.COM@relay.cs.net have time for netnews?