220 38129 <dc37b3f7-74b8-b94f-0a1c-59bb99ecbccc@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: memcpy/memset/etc overloads for volatile memory
Date: Sat, 19 May 2018 00:13:15 +0300
Lines: 57
Approved: news@gmane.org
Message-ID: <dc37b3f7-74b8-b94f-0a1c-59bb99ecbccc@gmail.com>
References: <CAFdMc-0NAvWrkwzpgEKq4DQj=0vL_0F2s17XyR9MSUNJk5R0sw@mail.gmail.com>
 <0e5ce74c-3e9e-4cf2-4afd-f7333ed82c5d@gmail.com>
 <CAFdMc-3V0VJ9nOs2fg4OuRr4N8TG-VXsrek1v=CJpr=Bqt98+Q@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1526677871 18067 195.159.176.226 (18 May 2018 21:11:11 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 18 May 2018 21:11:11 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.7.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRB3MD7XLQKGQEEHCBORA@isocpp.org Fri May 18 23:11:07 2018
Return-path: <std-proposals+bncBCXY5TXHWYJRB3MD7XLQKGQEEHCBORA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f72.google.com ([209.85.215.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRB3MD7XLQKGQEEHCBORA@isocpp.org>)
	id 1fJmeY-0004ca-Jo
	for gclcip-std-proposals@m.gmane.org; Fri, 18 May 2018 23:11:06 +0200
Original-Received: by mail-lf0-f72.google.com with SMTP id h129-v6sf3629281lfg.14
        for <gclcip-std-proposals@m.gmane.org>; Fri, 18 May 2018 14:13:18 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1526677998; cv=pass;
        d=google.com; s=arc-20160816;
        b=e0qm8MR0cg+dqdElPwSogC3J2RrfEPTto91EXAMu20e7eq2D5z7zyz0j74iiv6iINH
         RV1y/1qNlsuGNWWHqzqdDGgfYjKF4VWmtA2whUAZYPndfy+MvF8M6UU8jpyl7nUUtsVS
         Hz/j8cMEAeSCyWpuP3U+qSBzwS2xzMVI4NwEOkifK9EZLqVgRZSgwtRENyUdMKu1hK/j
         g3KEk5mjdHadqjWvY99RIJ9MEwP/tOheUtyIJwXJXTVI0BsPY2wq3xttJFKMgKb0b3Kv
         cpCXHboyaD6JgAC2qqvnfBHZDTcowtq/oaNwkFwj+EjHqbJYGeAG5Ag9kbo6/0BXzr/A
         23cQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=oox3D8Sn3XfKdGxkTEhYitElyhbQfhajeSceQxBHegs=;
        b=eRGMMivkQKcUsAtf/SAS95zUdQZYlsWi837Dj317SwE5fLIdTU0J9o0WZhWWgdEkWK
         QRIS/E5+LvWAUK3jsKvV/gzU1RzwdjweVZfGdD6Zs15I5tyBSvJoXoWVy9fAm5KxhOwa
         HOEUbTz6iUccVuf5CWU9Pb3cJS6eLj9/PiABwRqsg+zGGpeImjsCDp73mugBXX6i27ac
         M72QzD8n9TonZT3fhQ6MTh5Df6A0vS1EB7+4kbFOjXUCPyKeoRxFybxOp5vpwb+NvrsD
         YnglONBnXEfGrI7KPvj17zKITMrIgHLSaAoshRhtwurvJM2gpGOaCLDseZXUNQu2wRAS
         uWHg==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=BTo7+eGh;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-language:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=oox3D8Sn3XfKdGxkTEhYitElyhbQfhajeSceQxBHegs=;
        b=gMtLyWDJ9LkHOo9VN8wuhB1LANVYck7neMtanyXZOZxyJ4wKyd62EUARB7zz6VoCzD
         opg7X3nQZelyet0OkorW68TVrxfrdhNpo1jYjGGWn4mQvOQ0aHis2sii0L6ZEg9PTkbH
         1/YyM2E9ENftlsBwgONqjAswDFYN1QgdD5eq3RtxcVZHQdNeI7SctETA+F8HsH5mg7XD
         nWdQoEKxaJ9Ie3HP/qQspeI6xTahb1aMY+MryUU9xP/NmQosuO+HmvJcRIEpnRv3b2ua
         pBmj3+re7QfIpv+bnPSwlGcncoEqlz7rc4GeAtE3s4HwuyNpR7XUStYjKLj+ruBeCWa8
         GSkg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=oox3D8Sn3XfKdGxkTEhYitElyhbQfhajeSceQxBHegs=;
        b=sE91QgTgWK7wPQqzM9Lr18DE+llleh7ub2hmKS5f50u9+TeK1BiMTc2wMI8y2tOUkd
         6TyZQNdo/d9i1xtrAhsxmXwAJHhNx1RcQ3bQT6y2dT3pBsHEWfq1lF4Y8jAgC6FOOIm1
         HYU1LOOSDbySf4UBL7t+spiHB58h0BwnJVuBAtwNicswP1OX+/EQQlgmZZ34R5zvFjoe
         hghTGojLACRxSTBZWxWBM6C2wzoTbr4LRD9aZkQQocgwtPu2VkloF9tLX7yuI/E8N0zt
         HXsdH6PXf023PF3fl2KiMINWafgSYw6li+6MWtmm+X0S9mkKcfY/71Blb7kSnWvhapJe
         N 
X-Gm-Message-State: ALKqPwcfh0Px8NcrBLggl7pFTqlpsdYEjpQbxTCNU8I9cNC+/mrRrbCg
	jikL8bt3uiqApM0TDFr4HO/Eww==
X-Google-Smtp-Source: AB8JxZqPYh6DNZWGAvT98o79hIYWZnSgv2IuBO0aKCQaPKWRaN3IhBE3Hp+6ibkNFN0qY1ZkWeLPug==
X-Received: by 2002:a19:c50a:: with SMTP id w10-v6mr1406423lfe.37.1526677998066;
        Fri, 18 May 2018 14:13:18 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:1666:: with SMTP id m99-v6ls1146721lfi.9.gmail; Fri, 18
 May 2018 14:13:16 -0700 (PDT)
X-Received: by 2002:a19:df55:: with SMTP id q21-v6mr2296046lfj.56.1526677996910;
        Fri, 18 May 2018 14:13:16 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1526677996; cv=none;
        d=google.com; s=arc-20160816;
        b=LV4U1FU1ps2uUAox4TD2EKGJAiGp32PjULbia8v6imPgcmlJXd4h4JD+NVYeUpU3aX
         WLM4VSYWZoyTqh5vnvhNScZ5uhoyy2VB5SjuqSv5nwC+Ii6LbYziLfncAK4ApEfkA5VD
         VvakJVAPtt3rCM7u2IL2703fBvt9UlVkzRl/b1VrxQSa/8vB7i4rH7eSRA68POOouEEf
         ketvRNrK+22xNMsO1+/RBvHgHVEmEx7hzoOhhIwOh9Kd3/esl4K0mHmGVS5VYneaVNav
         cehMkhiAYyl+Vuwc4ijB8vfGTWrc+QBfrFTjCpESU0wn1r1IU4PhnDBA0GwuTkLXC3Bj
         66Kw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :dkim-signature:arc-authentication-results;
        bh=f5G8IKI52tZHj0ANfK5CUIyUI3Pd0CtmlcrODT0lVnk=;
        b=kNtxriHYzhTWvKSx9A46T41xskTQRwKDeXBjUx9pM+gRvEm3ZBm6XbiLDoHvP+tCS7
         AUsKQ+7Agp37UK75Q0BKtzTcJ9uB2wGLTrfKB/m37UitD5MvmXXO7plbRIxF5cwaB+lR
         UbOzRUhP7dyck61xuRKTmpk5MsISPuJa1G2jfWdSfeVJPQEO7sYYJibUycrt/eqKULpI
         jI+9e/vG+YRji/98gcuXRT/HSGEHtTXQY+6uKZBdPljiEw9QX0f1RRJ9pFNu0gnoXQU8
         ZtswGIVfXUet0XJMbTOEU8mHpLcTWQ/qtn5hIA8xHrHvds4+5F/6iMOrOr53tdmI9u6b
         Rq2Q==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=BTo7+eGh;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id d14-v6sor2066663ljf.27.2018.05.18.14.13.16
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 18 May 2018 14:13:16 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 2002:a2e:6e10:: with SMTP id j16-v6mr6964577ljc.61.1526677996470;
        Fri, 18 May 2018 14:13:16 -0700 (PDT)
Original-Received: from [192.168.1.2] (broadband-109-173-28-102.ip.moscow.rt.ru. [109.173.28.102])
        by smtp.googlemail.com with ESMTPSA id v64-v6sm1385403lje.56.2018.05.18.14.13.15
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 18 May 2018 14:13:15 -0700 (PDT)
In-Reply-To: <CAFdMc-3V0VJ9nOs2fg4OuRr4N8TG-VXsrek1v=CJpr=Bqt98+Q@mail.gmail.com>
Content-Language: en-US
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=BTo7+eGh;       spf=pass
 (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:38129
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38129>

On 05/18/18 23:53, dgutson . wrote:
> 
> On Fri, May 18, 2018 at 5:46 PM, Andrey Semashev 
> <andrey.semashev@gmail.com <mailto:andrey.semashev@gmail.com>> wrote:
> 
>     On 05/18/18 23:41, dgutson . wrote:
> 
>         This might be interesting.
> 
>         In some systems, the implementation of memcpy() & friends cannot
>         be used for memory-mapped devices.
>         Usually, mapped memory is marked as volatile.
> 
>         I'm proposing to add volatile pointers overloads for the
>         memcpy() function and friends, without specifying exactly what
>         should be different at the standard-level, but allowing
>         implementations to provide a particular behavior. I'm just
>         proposing to add the declaration to the standard.
> 
>         Particularly, in some x86-based systems, reading things like the
>         SPI should be done on byte-per-byte basis (rather than streamed
>         with any SIMD instruction).
> 
>         I'm not sure what the wording should exactly say, but I'm just
>         initiating the discussion.
> 
>     If it's not specified then the exact behavior wrt. memory accesses
>     is not going to be portable, which means it's not going to be useful.
> 
> It is useful indeed: if I have a pointer to volatile memory, I cannot 
> use memcpy currently.
> By adding the overload, I'm being guaranteed that I will be able to call 
> memcpy (and that the implementation shall DTRT, which is for example, 
> the byte per byte copying).
> Besides the "DTRT" discussion, my point is: I want this overload to be 
> available. At least it should fall back to the non-volatile version.

What is "the right thing"? Does it have to be a byte-granular operation? 
Does it have to be a forward iteration? Is this behavior the same on all 
implementations? You have to answer on all these questions in the 
standard wording so that everyone can rely on the exact memory access 
pattern, which is important in case of volatile memory.

If it is not important in your case then you don't need volatile and 
hence the overload.

Personally, I don't see much use in such an overload. Where memory 
access pattern is important I would rather spell it explicitly or at 
least use std::copy, which, unlike memcpy, does define the order of 
iteration and granularity.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/dc37b3f7-74b8-b94f-0a1c-59bb99ecbccc%40gmail.com.

.
