1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950(**************************************************************************)(* *)(* OCaml *)(* *)(* Gabriel Scherer, projet Partout, INRIA Paris-Saclay *)(* *)(* Copyright 2020 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* 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. *)(* *)(**************************************************************************)external(==):'a->'a->bool="%eq"external(+):int->int->int="%addint"externalignore:'a->unit="%ignore"type'at={mutablev:'a}letmakev={v}letgetr=r.vletsetrv=r.v<-vlet[@inlinenever]exchangerv=(* BEGIN ATOMIC *)letcur=r.vinr.v<-v;(* END ATOMIC *)curlet[@inlinenever]compare_and_setrseenv=(* BEGIN ATOMIC *)letcur=r.vinifcur==seenthen(r.v<-v;(* END ATOMIC *)true)elsefalselet[@inlinenever]fetch_and_addrn=(* BEGIN ATOMIC *)letcur=r.vinr.v<-cur+n;(* END ATOMIC *)curletincrr=ignore(fetch_and_addr1)letdecrr=ignore(fetch_and_addr(-1))