Skip Navigation Links | |
Exit Print View | |
man pages section 9: DDI and DKI Kernel Functions Oracle Solaris 11 Information Library |
csx_AccessConfigurationRegister(9F)
csx_Parse_CISTPL_BYTEORDER(9F)
csx_Parse_CISTPL_CFTABLE_ENTRY(9F)
csx_Parse_CISTPL_DEVICEGEO(9F)
csx_Parse_CISTPL_DEVICEGEO_A(9F)
csx_Parse_CISTPL_DEVICE_OA(9F)
csx_Parse_CISTPL_DEVICE_OC(9F)
csx_Parse_CISTPL_LINKTARGET(9F)
csx_Parse_CISTPL_LONGLINK_A(9F)
csx_Parse_CISTPL_LONGLINK_C(9F)
csx_Parse_CISTPL_LONGLINK_MFC(9F)
ddi_get_soft_iblock_cookie(9F)
ddi_intr_get_supported_types(9F)
ddi_prop_lookup_byte_array(9F)
ddi_prop_lookup_int64_array(9F)
ddi_prop_lookup_string_array(9F)
ddi_prop_update_byte_array(9F)
ddi_prop_update_int64_array(9F)
ddi_prop_update_string_array(9F)
ldi_prop_lookup_byte_array(9F)
ldi_prop_lookup_int64_array(9F)
ldi_prop_lookup_string_array(9F)
mac_prop_info_set_default_link_flowctrl(9F)
mac_prop_info_set_default_str(9F)
mac_prop_info_set_default_uint8(9F)
mac_prop_info_set_range_uint32(9F)
net_event_notify_unregister(9F)
net_instance_notify_register(9F)
net_instance_notify_unregister(9F)
net_instance_protocol_unregister(9F)
net_protocol_notify_register(9F)
nvlist_lookup_boolean_array(9F)
nvlist_lookup_boolean_value(9F)
nvlist_lookup_nvlist_array(9F)
nvlist_lookup_string_array(9F)
nvlist_lookup_uint16_array(9F)
nvlist_lookup_uint32_array(9F)
nvlist_lookup_uint64_array(9F)
nvpair_value_boolean_array(9F)
pci_plist_lookup_int16_array(9F)
pci_plist_lookup_int32_array(9F)
pci_plist_lookup_int64_array(9F)
pci_plist_lookup_int8_array(9F)
pci_plist_lookup_string_array(9F)
pci_plist_lookup_uint16_array(9F)
pci_plist_lookup_uint32_array(9F)
pci_plist_lookup_uint64_array(9F)
pci_plist_lookup_uint8_array(9F)
scsi_get_device_type_scsi_options(9F)
scsi_get_device_type_string(9F)
scsi_sense_cmdspecific_uint64(9F)
usb_get_current_frame_number(9F)
usb_get_max_pkts_per_isoc_request(9F)
usb_pipe_get_max_bulk_transfer_size(9F)
usb_pipe_stop_intr_polling(9F)
usb_pipe_stop_isoc_polling(9F)
- handle variable argument list
#include <sys/varargs.h> void va_start(va_list pvar, name);
(type *) va_arg(va_list pvar, type);
void va_copy(va_list dest, va_list src);
void va_end(va_list pvar);
Solaris DDI specific (Solaris DDI).
Pointer to variable argument list.
Identifier of rightmost parameter in the function definition.
Pointer to variable argument list.
Type name of the next argument to be returned.
Destination variable argument list.
Source variable argument list.
Pointer to variable argument list.
This set of macros allows portable procedures that accept variable argument lists to be written. Routines that have variable argument lists but do not use the varargs macros are inherently non-portable, as different machines use different argument-passing conventions. Routines that accept a variable argument list can use these macros to traverse the list.
va_list is the type defined for the variable used to traverse the list of arguments.
va_start() is called to initialize pvar to the beginning of the variable argument list. va_start() must be invoked before any access to the unnamed arguments. The parameter name is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the “, . . . ”). If this parameter is declared with the register storage class or with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined.
va_arg() expands to an expression that has the type and value of the next argument in the call. The parameter pvar must be initialized by va_start(). Each invocation of va_arg() modifies pvar so that the values of successive arguments are returned in turn. The parameter type is the type name of the next argument to be returned. The type name must be specified in such a way that the type of pointer to an object that has the specified type can be obtained by postfixing a * to type. If there is no actual next argument, or iftype is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined.
The va_copy() macro saves the state represented by the va_listsrc in the va_list dest. The va_list passed as dest should not be initialized by a previous call to va_start() It then must be passed to va_end() before being reused as a parameter to va_start() or as the dest parameter of a subsequent call to va_copy(). The behavior is undefined if any of these restrictions are not met.
The va_end() macro is used to clean up. It invalidates pvar for use (unless va_start() is invoked again).
Multiple traversals, each bracketed by a call to va_start() and va_end(), are possible.
Example 1 Creating a Variable Length Command
The following example uses these routines to create a variable length command. This might be useful for a device that provides for a variable-length command set. ncmdbytes is the number of bytes in the command. The new command is written to cmdp.
static void xx_write_cmd(uchar_t *cmdp, int ncmdbytes, ...) { va_list ap; int i; /* * Write variable-length command to destination */ va_start(ap, ncmdbytes); for (i = 0; i < ncmdbytes; i++) { *cmdp++ = va_arg(ap, uchar_t); } va_end(ap); }
It is up to the calling routine to specify in some manner how many arguments there are, since it is not always possible to determine the number of arguments from the stack frame.
Specifying a second argument of char or short to va_arg makes your code non-portable, because arguments seen by the called function are not char or short. C converts char and short arguments to int before passing them to a function.