SysV bcopy?

Chris Torek chris at mimsy.UUCP
Mon Mar 20 16:02:25 AEST 1989


>In article <114 at sherpa.UUCP> rac at sherpa.UUCP (Roger A. Cornelius) asks:
>>Is there a routine in the system V library analogous to BSD's bcopy().

In article <604 at pmafire.UUCP> dave at pmafire.UUCP (Dave Remien) replies
(and in other articles, others write):
>Being fundamentally in favor of making life easier, I have a file that I
>include in all BSD source at the top, which contains:
>
>#define bcopy(s,d,n)	memcpy((d),(s),(n))

Beware: bcopy() is more like memmove() than memcpy().  This is not well
documented, and is sometimes even false (e.g., for 4.2BSD with n >
65535 and s < d < s + n; for 4.2BSD-derived systems such as SunOS, I
cannot even guess), but using memmove is safer.

To put it another way:

	#define bcopy(s, d, n) memmove(d, s, n)

will always work, while

	#define memmove(d, s, n) bcopy(s, d, n)

may not.  (The latter does work in 4.3BSD and 4.3BSD-tahoe.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list