123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)(** Plug-in states and options. *)letplugin_name="Volatile"includePlugin.Register(structletname=plugin_nameletshortname="volatile"lethelp="support for volatile accesses and calls through function pointers"end)(** {1 Messages and warning categories} *)moduleKeys=structletdkey_binding=register_category~help:"Prints debug messages related to volatile operations""binding"letdkey_binding_table=register_category~help:"Prints debug messages related to volatile operations on internal tables""binding-table"letdkey_volatile_table=register_category~help:"Prints Volatile internal tables""volatile-table"letdkey_transformation_action=register_category~help:"Prints information on generated code""transformation-action"letdkey_transformation_visit=register_category~help:"Prints visitor information during the transformation""transformation-visit"letwkeynamestatus=letwkey=register_warn_categorynameinset_warn_statuswkeystatus;wkeyletwkey_invalid_binding_function=wkey"invalid-binding-function"Log.Werrorletwkey_unsupported_volatile_clause=wkey"unsupported:volatile-clause"Log.Werrorletwkey_duplicated_access_function=wkey"duplicated-access-function"Log.Werrorletwkey_volatile_cast=wkey"cast:volatile"Log.Wfeedbackletwkey_cast_insertion=wkey"cast:insertion"Log.Wfeedbackletwkey_transformed_access_lvalue_volatile=wkey"transformed-access:lvalue-volatile"Log.Wfeedbackletwkey_transformed_access_lvalue_partially_volatile=wkey"transformed-access:lvalue-partially-volatile"Log.Wfeedbackletwkey_untransformed_access_lvalue_volatile=wkey"untransformed-access:lvalue-volatile"Log.Wactiveletwkey_untransformed_access_lvalue_partially_volatile=wkey"untransformed-access:lvalue-partially-volatile"Log.Wactiveletwkey_untransformed_call=wkey"untransformed-call"Log.Wactiveletwkey_untransformed_call_function_not_found=wkey"untransformed-call:function_not_found"Log.Wactiveletwkey_transformed_call=wkey"transformed-call"Log.Wfeedbackletwkey_transformed_call_skipped_parameters=wkey"transformed-call:skipped-parameters"Log.Wactiveletwkey_transformed_call_missing_parameters=wkey"transformed-call:missing-parameters"Log.Wactiveend(** {1 Plug-in options.} *)moduleEnabled=False(structletoption_name="-volatile"lethelp="builds a new project (named \""^plugin_name^"\") where volatile accesses are simulated by function calls"end)moduleProcess=String_set(structletoption_name="-volatile-fct"letarg_name="f,..."lethelp="Only process the given function(s)"end)moduleCallPtr=String_list(structletoption_name="-volatile-call-pointer"letarg_name="f,..."lethelp="stub call to pointer functions to the provided functions \
(indexed by type)"end)moduleBase=False(structletoption_name="-volatile-basetype"lethelp="use base-type for int, float and enums for the instrumentation \
related to -volatile-binding option"end)moduleBinding=String_list(structletoption_name="-volatile-binding"letarg_name="f,..."lethelp="allows binding of volatile accesses to functions <f,...>"end)moduleBindingAuto=False(structletoption_name="-volatile-binding-auto"lethelp="allows automatic binding of volatiles accesses to functions: \
<prefix>Rd_<typename> and <prefix>Wr_<typename>"end)moduleBindingCall=False(structletoption_name="-volatile-binding-call-pointer"lethelp="replaces calls through function pointers by direct calls to \
functions: <prefix>Call_<result-type>_<param-types>"end)moduleBindingPrefix=String(structletoption_name="-volatile-binding-prefix"letarg_name="str"letdefault="c2fc2_"lethelp="adds <str> as prefix to function names for automatic binding"end)let()=BindingPrefix.add_set_hook(fun_t->function|""->error"empty string cannot be used as binding prefix@."|str->letrx=Str.regexp"^[a-zA-Z_][a-zA-Z0-9_$]*$"inif(not(Str.string_matchrxstr0))thenerror"binding prefix %S does not match C identifier regexp@."str;)