1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556(**************************************************************************)(* *)(* OCaml *)(* *)(* Stephen Dolan, University of Cambridge *)(* *)(* Copyright 2017-2018 University of Cambridge. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)externalignore:'a->unit="%ignore"moduleLoc=structtype'at='aatomic_locexternalget:'at->'a="%atomic_load_loc"externalexchange:'at->'a->'a="%atomic_exchange_loc"externalcompare_and_set:'at->'a->'a->bool="%atomic_cas_loc"externalfetch_and_add:intt->int->int="%atomic_fetch_add_loc"letsettv=ignore(exchangetv)letincrt=ignore(fetch_and_addt1)letdecrt=ignore(fetch_and_addt(-1))endtype!'at={mutablecontents:'a[@atomic];}letmakev={contents=v}externalmake_contended:'a->'at="caml_atomic_make_contended"letgett=t.contentsletsettv=t.contents<-vletexchangetv=Loc.exchange[%atomic.loct.contents]vletcompare_and_settoldnew_=Loc.compare_and_set[%atomic.loct.contents]oldnew_letfetch_and_addtincr=Loc.fetch_and_add[%atomic.loct.contents]incrletincrt=Loc.incr[%atomic.loct.contents]letdecrt=Loc.decr[%atomic.loct.contents]