https://gcc.gnu.org/g:9e55aa415ea90bcef8033892f6381402cb90b163
commit r17-4162-g9e55aa415ea90bcef8033892f6381402cb90b163 Author: Tobias Burnus <[email protected]> Date: Fri Sep 11 13:35:58 2026 +0200 libgomp.texi: Add note to omp_control_tool routine libgomp/ChangeLog: * libgomp.texi (omp_control_tool): Add example interface for calling the tool with a passed argument from Fortran Diff: --- libgomp/libgomp.texi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 190872f299f6..b3700d7f1428 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -4476,6 +4476,37 @@ specification. In older versions, the type @code{int} was used for the @item @tab @code{integer :: modifier} @end multitable +@item @emph{Note}: +In Fortran code, an argument can passed to the tool by creating a C wrapper +function in the user code; however, as in GCC---and likely in most +implementations---the C/C++ and Fortran use compatible integer kinds/types, +it is simpler to add an INTERFACE block such as the following one. + +@smallexample +interface + ! Or to permit using 'omp_control_tool' for both the two and + ! three argument version, use a generic interface; the two- + ! argument version comes from the 'omp_lib' module. +!interface omp_control_tool + + integer(omp_control_tool_result_kind) & + function omp_control_tool_arg (command, modifier, arg) & + bind(C, name="omp_control_tool") + use omp_lib + use iso_c_binding + integer(kind=omp_control_tool_kind), VALUE :: command + integer(c_int) :: modifier + + ! Either + type(c_ptr), VALUE :: arg + ! or + !type(*), dimension(*) :: arg ! Note: + ! Avoid type(*) for 'type(c_ptr)' actual arguments as this will pass a + ! reference to the C pointer and not the C pointer itself. + end +end interface +@end smallexample + @c @item @emph{See also}: @item @emph{Reference}:
