• Kir Kolyshkin's avatar
    zdtm/grow_map: fix test failure for clang · 391bdbe4
    Kir Kolyshkin authored
    When this code is compiled by clang, it optimizes two byte writes into
    one word write, like this:
    
    >        fake_grow_down[0] = 'c';
    >        *(fake_grow_down - 1) = 'b';
    > 401b60:       66 41 c7 46 ff 62 63    movw   $0x6362,-0x1(%r14)
    
    This is incorrect, as the stack is supposed to grow page by page,
    so we need to touch one page then another, i.e. the order is important.
    
    To fix, let's use volatile pointer. After this change, the following
    (correct) code is generated:
    
    >        *p-- = 'c';
    >   401b60:       41 c6 06 63             movb   $0x63,(%r14)
    >        *p = 'b';
    >   401b64:       41 c6 46 ff 62          movb   $0x62,-0x1(%r14)
    
    [v2: same fix for another similar place]
    
    Cc: Andrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
    Acked-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    391bdbe4
Name
Last commit
Last update
Documentation Loading commit data...
contrib Loading commit data...
coredump Loading commit data...
crit Loading commit data...
criu Loading commit data...
images Loading commit data...
lib Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
INSTALL.md Loading commit data...
Makefile Loading commit data...
Makefile.install Loading commit data...
Makefile.versions Loading commit data...
README.md Loading commit data...