Este conteúdo não está disponível no idioma selecionado.
3.4. Auxiliary functions
General syntax:
function <name>[:<type>] ( <arg1>[:<type>], ... ) { <stmts> }
SystemTap scripts may define subroutines to factor out common work. Functions may take any number of scalar arguments, and must return a single scalar value. Scalars in this context are integers or strings. For more information on scalars, see Section Section 3.3, “Variables” and Section Section 5.2, “Data types”
.
The following is an example function declaration.
function thisfn (arg1, arg2) { return arg1 + arg2 }
Note the general absence of type declarations, which are inferred by the translator. If desired, a function definition may include explicit type declarations for its return value, its arguments, or both. This is helpful for embedded-C functions. In the following example, the type inference engine need only infer the type of arg2, a string.
function thatfn:string(arg1:long, arg2) { return sprintf("%d%s", arg1, arg2) }
Functions may call others or themselves recursively, up to a fixed nesting limit. See Section Section 1.6, “Safety and security”.