Path: csiph.com!news.redatomik.org!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!feeds.phibee-telecom.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Tue, 30 Aug 2016 01:14:30 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Default values in #define References: <1d377167-a33a-402e-89ee-d3efa06d95ab@googlegroups.com> <87twebuwwn.fsf@gmail.com> <36a5bcc3-9e30-468c-a3e1-4b9c9788d395@googlegroups.com> <1Kgvz.279$6d.174@fx26.iad> <8277ffd2-121d-4f3a-9bb0-ad3068696415@googlegroups.com> <502669cd-f0fc-4b99-8c8a-0d806c8b5f20@googlegroups.com> <11e2bb75-ee3c-4904-b7c8-77023426fb45@googlegroups.com> <87vaynj0l9.fsf@bsb.me.uk> <4c14769d-f75d-4c8f-89f6-5290f6b97b32@googlegroups.com> <3f6534af-ec82-4d9e-8f9c-e4805dec99db@googlegroups.com> Date: Tue, 30 Aug 2016 07:14:30 +0100 Message-ID: <87shtmokah.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:7WSH/SgAUYX8JTY5UbfqnQewPz0= MIME-Version: 1.0 Content-Type: text/plain Lines: 9 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-UltwHyMgIIswJyyW0V7qhxLbK2C3hE2WpRiM7t2YMhs30boacEeyeHChkKpzRqFA+S+kfzzT32f5EDx!HSbmyVlZ936iTisQbYe0SmnYFmL9BeMgE0cFI5vk6Cl1AXpDa0EilZsayhJgotEs8wFNfg== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2353 Xref: csiph.com comp.lang.c:92919 Malcolm McLean writes: > I see. So if we implement a semaphore / token /flag system, the > buffer must also be volatile, even though in fact it can't change when > the accessor has the token, to prevent the optimiser moving the buffer > accesses from outside the token guards. Use a memory barrier in the token acquisition/release code. Buffer accesses will not be re-ordered through the memory barrier.