Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Mar 2003 22:00:05 +0100
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Bakul Shah <bakul@bitblocks.com>
Cc:        arch@FreeBSD.ORG
Subject:   Re: memcpy() with specified direction of copying ? 
Message-ID:  <9531.1047848405@critter.freebsd.dk>
In-Reply-To: Your message of "Sun, 16 Mar 2003 12:52:10 PST." <200303162052.PAA05328@goliath.cnchost.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200303162052.PAA05328@goliath.cnchost.com>, Bakul Shah writes:
>> Is there any standard which has provided an api for mandating the
>> direction of copying from a memcpy() like function ?
>> 
>> As I read our man-page, there is no way to know of memcpy() copies
>> from the start and forward or from the end and backward through the
>> two areas.
>
>The direction is not even relevant for memcpy and if the
>source and destination overlap, the behavior is undefined.
>Use memmove() for overlapped src and dst, but if you want the
>direction reversed for some other reason you're on your own.

Well, in my case it is a matter of shared memory where the order in
which I snapshot a data structure is critical for detecting integrity
issues.

I'll roll my own.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9531.1047848405>