From: Ian Jackson Date: Tue, 10 Sep 2019 11:12:44 +0000 (+0100) Subject: tools/ocaml: abi-check: Add comments X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~1619 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e95e2acffefa1f20109055840b29efd4505c9840;p=xen.git tools/ocaml: abi-check: Add comments Provide interface documentation for this script. Explain why we check .ml not .mli. Signed-off-by: Andrew Cooper Reviewed-by: Ian Jackson Signed-off-by: Ian Jackson Acked-by: Christian Lindig --- diff --git a/tools/ocaml/libs/xc/abi-check b/tools/ocaml/libs/xc/abi-check index c987cd8454..ccc35e79e9 100755 --- a/tools/ocaml/libs/xc/abi-check +++ b/tools/ocaml/libs/xc/abi-check @@ -5,6 +5,13 @@ use Data::Dumper; our %enums; +# Usage: abi-check C-file Ocaml-file +# Writes out a BUILD_BUG_ON() list to be included back into C. +# +# Ocaml-file should be the .ml file. The ocaml compiler will check +# that any declarations in a .mli correspond. We check the .ml +# rather than the .mli in case there are private types in future. + @ARGV == 2 or die; our ($c, $o) = @ARGV; @@ -13,6 +20,14 @@ open STDIN, "<", $c or die $!; our $cline = -1; our $ei; +# Parse the C file looking for calls to: +# c_bitmap_to_ocaml_list() +# +# followed by anotations of the following form: +# /* ! OType OPrefix Mangle */ +# /* ! CPrefix CFinal CFinalHow */ +# +# The function definitions use /* ! */ which simply skips that instance. while (<>) { if ($cline == -1) { if (m/c_bitmap_to_ocaml_list/) {