man pages section 9: DDI and DKI Kernel Functions

Exit Print View

Updated: July 2014
 
 

swab(9F)

Name

swab - swap bytes in 16-bit halfwords

Synopsis

#include <sys/sunddi.h>

void swab(const void *src, void *dst, ssize_t nbytes);

Interface Level

Architecture independent level 1 (DDI/DKI).

Parameters

src

A pointer to the buffer containing the bytes to be swapped.

dst

A pointer to the destination buffer where the swapped bytes will be written. If dst is the same as src the buffer will be swapped in place.

nbytes

Number of bytes to be swapped, rounded down to the nearest half-word.

Description

The swab() function copies the bytes in the buffer pointed to by src to the buffer pointer to by dst, swapping the order of adjacent bytes in half-word pairs as the copy proceeds. A total of nbytes bytes are copied, rounded down to the nearest half-word.

Context

The swab() function can be called from user, interrupt, or kernel context.

See Also

Writing Device Drivers for Oracle Solaris 11.2

Notes

Since swab() operates byte-by-byte, it can be used on non-aligned buffers.