bcopy

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Dec 10 08:52:42 AEST 1988


In article <1356 at astroatc.UUCP> johnw at astroatc.UUCP (John F. Wardale) writes:
>What does the following mean?  [What should it do?]
>			bcopy (&a[0], &a[1], 19);
>			bcopy (&a[1], &a[0], 19);
>The vax-BSD 4.3 "man bcopy" doesn't mention this.
> the SUN "man bcopy" says:
>"Overlapping strings are handled correctly."

One has no way to guess whether or not overlapping arrays are
handled "correctly" unless, as Sun did, the vendor ensures this
attribute.

>Emacs (a highly ported program) *ASSUMES* (needs/uses) this
>overlaping semantic.

It sounds like it relies on an undocumented and therefore
unreliable feature of some implementations.  Since bcopy()
normally would be implemented as highly-tuned assembly code,
rather than in portable C, one is entirely at the mercy of
the BSD-flavor C library implementer.

ANSI C recognizes the need for a faster, non-checking function
and an overlap-supporting function, and doesn't have bcopy()
at all (neither does UNIX System V).  So, unless EMACS source
comes with its own implementation anyway, it is far from
portable in this respect.

By the way, I have a portable overlap-supporting block-move
implementation in C in case anyone needs it.  Perhaps if the
GNU project doesn't already have such a beast they could pick
up mine.



More information about the Comp.std.c mailing list