BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kva_arg - gets an argument off the variable argument list

LIBRARY CALL

type kva_arg(
   kva_list vararg_list,
   type)

INPUT

OUTPUT

none

RETURN VALUE

The next paramter on the variable argument list cast to the type specified by the type parameter

DESCRIPTION

This routine gets an argument off the variable argument list.

Example variable argument routine definition:

var_arg_routine(int p1, int p2, double pN, kva_alist) { short var; // the next parameter after pN // is expected to be short kva_list *vararg_list; // the variable argument list

kva_start(vararg_list, pN); // pN is the last parameter // before variable args begin : var = kva_arg(vararg_list, short); : kva_end(vararg_list); }

The execution stack when procedure var_arg_routine is executed; before kva_arg is called, the "vararg_list" pointer is set to the address indicated below. | byte0 int parameter p1 | : | byte4 int parameter p2 | : | byte8 double parameter pN | : args stack address ---->| byte16 short parameter A "vararg_list" | byte17 | byte18 int parameter B | byte19 | byte20 | byte21 | :

Now, a call to kva_arg(vararg_list, short) moves the "vararg_list" pointer to byte18, and returns the pointer to byte16 as a short, so that var_arg_routine() can obtain the value of short parameter A.

the resulting execution stack is now: | byte0 int parameter p1 | : | byte4 int parameter p2 | : | byte8 double parameter pN | : args stack address -+ | byte16 short parameter A "vararg_list" | | byte17 (assigned to "var") +-->| byte18 int parameter B | byte19 | byte20 | byte21 | :

ADDITIONAL INFORMATION

none

EXAMPLES

none

SIDE EFFECTS

none

RESTRICTIONS

none

MODIFICATION

none

FILES

$BOOTSTRAP/include/kutils/kvarargs.h

SEE ALSO

kutils(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.