lkml.org 
[lkml]   [2019]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] tools/memory-model: Remove (dep ; rfi) from ppo
On Tue, Feb 26, 2019 at 06:28:45AM -0800, Paul E. McKenney wrote:

> Yes, this all is a bit on the insane side from a kernel viewpoint.
> But the paper you found does not impose this; it has instead been there
> for about 20 years, back before C and C++ admitted to the existence
> of concurrency. But of course compilers are getting more aggressive,
> and yes, some of the problems show up in single-threaded code.

But that paper is from last year!! It has Peter Sewell on, I'm sure he's
heard of concurrency.

> The usual response is "then cast the pointers to intptr_t!" but of
> course that breaks type checking.

I tried laundering the pointer through intptr_t, but I can't seem to
unbreak it.


root@ivb-ep:~/tmp# gcc-8 -O2 -fno-strict-aliasing -o ptr ptr.c ; ./ptr
p=0x55aacdc80034 q=0x55aacdc80034
x=1 y=2 *p=11 *q=2
root@ivb-ep:~/tmp# cat ptr.c
#include <stdio.h>
#include <string.h>
#include <stdint.h>
int y = 2, x = 1;
int main (int argc, char **argv) {
intptr_t P = (intptr_t)&x;
intptr_t Q = (intptr_t)&y;
P += sizeof(int);
int *q = &y;
printf("p=%p q=%p\n", (int*)P, (int*)Q);
if (P == Q) {
int *p = (int *)P;
*p = 11;
printf("x=%d y=%d *p=%d *q=%d\n", x, y, *p, *q);
}
}

\
 
 \ /
  Last update: 2019-02-26 16:05    [W:0.099 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site