From owner-freebsd-arch Sun Mar 16 13: 0:12 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8558037B401 for ; Sun, 16 Mar 2003 13:00:11 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9475643F93 for ; Sun, 16 Mar 2003 13:00:10 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.8/8.12.8) with ESMTP id h2GL05Ds009532; Sun, 16 Mar 2003 22:00:06 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: Bakul Shah Cc: arch@FreeBSD.ORG Subject: Re: memcpy() with specified direction of copying ? From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sun, 16 Mar 2003 12:52:10 PST." <200303162052.PAA05328@goliath.cnchost.com> Date: Sun, 16 Mar 2003 22:00:05 +0100 Message-ID: <9531.1047848405@critter.freebsd.dk> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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