lkml.org 
[lkml]   [2021]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] LKMM: Add volatile_if()
On Fri, Jun 04, 2021 at 11:51:54AM -0400, Alan Stern wrote:
> On Fri, Jun 04, 2021 at 05:42:28PM +0200, Peter Zijlstra wrote:

> > #define volatile_if(cond) if (({ bool __t = (cond); BUILD_BUG_ON(__builtin_constant_p(__t)); volatile_cond(__t); }))
>
> That won't help with more complicated examples, such as:
>
> volatile_if (READ_ONCE(*x) * 0 + READ_ONCE(*y))

That's effectively:

volatile_if (READ_ONCE(*y))
WRITE_ONCE(*y, 42);

which is a valid, but daft, LOAD->STORE order, no? A compiler might
maybe be able to WARN on that, but that's definitely beyond what we can
do with macros.

\
 
 \ /
  Last update: 2021-06-04 18:18    [W:0.121 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site