Writing Device Drivers

Utility Functions

Table B-39 Utility Functions

Function Name 

Description 

nulldev 

zero return function 

nodev 

error return function 

nochpoll 

error return function for non-pollable devices 

  

ASSERT 

expression verification 

  

bcopy 

copy data between address locations in the kernel 

bzero 

clear memory for a given number of bytes 

bcmp 

compare two byte arrays 

ddi_ffs 

find first bit set in a long integer 

ddi_fls 

find last bit set in a long integer 

swab 

swap bytes in 16-bit halfwords 

  

strcmp 

compare two null-terminated strings 

strncmp 

compare two null-terminated strings, with length limit 

strlen 

determine the number of non-null bytes in a string 

strcpy 

copy a string from one location to another 

strncpy 

copy a string from one location to another, with length limit 

strchr 

find a character in a string 

  

sprintf 

format characters in memory 

vsprintf 

format characters in memory 

numtos 

convert integer to decimal string 

stoi 

convert decimal string to an integer 

  

max 

return the larger of two integers 

min 

return the lesser of two integers 

  

va_arg 

handle variable argument list 

va_copy 

handle variable argument list 

va_end 

handle variable argument list 

va_start 

handle variable argument list