123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)letdkey=Wp_parameters.register_category"rte"typet={name:string;cint:bool;kernel:(unit->bool);option:string;status:unit->RteGen.Generator.status_accessor;}letoptionname=tryname=""||Dynamic.Parameter.Bool.getname()with_->falseletstatusdbkf=trylet(_,_,get)=db()ingetkfwithFailure_->Wp_parameters.warning~once:true"Missing RTE plug-in: can not generate conditions";falseletalways_=trueletconfigure~update~generatekfcintrte=ifnotrte.cint||rte.kernel()thenbegin(* need RTE guard, but kernel option is set *)ifnot(statusrte.statuskf)thenbeginifoptionrte.optionthenletmsg=ifgeneratethen"generate"else"missing"inWp_parameters.debug~dkey"function %a: %s rte for %s"Kernel_function.prettykfmsgrte.name;elseWp_parameters.warning~once:true~current:false"-wp-rte can annotate %s because %s is not set"rte.namerte.option;update:=true;endendelseifgeneratethenmatchcintwith|Cint.Machine->()(* RTE has been set *)|Cint.Natural->Wp_parameters.warning~once:true~current:false"-wp-rte and model nat require kernel to warn against %s"rte.nameletgenerator=[{name="memory access";kernel=always;option="-rte-mem";cint=false;status=(fun()->RteGen.Generator.Mem_access.accessor)};{name="division by zero";kernel=always;option="-rte-div";cint=false;status=(fun()->RteGen.Generator.Div_mod.accessor)};{name="signed overflow";cint=true;kernel=Kernel.SignedOverflow.get;option="";status=(fun()->RteGen.Generator.Signed_overflow.accessor)};{name="unsigned overflow";cint=true;kernel=Kernel.UnsignedOverflow.get;option="";status=(fun()->RteGen.Generator.Unsigned_overflow.accessor)};{name="signed downcast";cint=true;option="";kernel=Kernel.SignedDowncast.get;status=(fun()->RteGen.Generator.Signed_downcast.accessor)};{name="unsigned downcast";cint=true;option="";kernel=Kernel.UnsignedDowncast.get;status=(fun()->RteGen.Generator.Unsigned_downcast.accessor)};{name="invalid bool value";cint=false;option="-warn-invalid-bool";kernel=Kernel.InvalidBool.get;status=(fun()->RteGen.Generator.Bool_value.accessor)};]letgeneratemodelkf=letupdate=reffalseinletcint=WpContext.on_context(model,WpContext.Kfkf)Cint.current()inList.iter(configure~update~generate:truekfcint)generator;if!updatethenletflags={(RteGen.Flags.default())withpointer_alignment=false}inRteGen.Visit.annotate~flagskfletgenerate_allmodel=Wp_parameters.iter_kf(generatemodel)letmissing_guardsmodelkf=letupdate=reffalseinletcint=WpContext.on_context(model,WpContext.Kfkf)Cint.current()inList.iter(configure~update~generate:falsekfcint)generator;!update(* -------------------------------------------------------------------------- *)