xref: /titanic_50/usr/src/lib/libast/common/man/swap.3 (revision 7a286c471efbab8562f7655a82931904703fffe0)
.fp 5 CW .. .nr ;G \\n(.f .Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" \\*(;G .. .aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" .. .aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" .. .aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" ..

0

..

..

SWAP 3
NAME
swap - integral representation conversion routines
SYNOPSIS
.L "#include <swap.h>" .L "int swapop(const void* internal, const void* external, int width); .L "int_max swapget(int op, const void* from, int width);" .L "void* swapput(int op, void* to, int width, int_max value);" .L "void* swapmem(int op, const void* from, void* to, size_t n);"
DESCRIPTION
These routines convert integral constants between internal and external representations. They are used to handle binary data generated by foreign programs. New binary data representations should use the compact canonical form provided by the sfio (3) routines .L sfputu and .LR sgetu .

.L swapop returns the swap operation required to convert the .L width byte integer .L external to the .L width byte integer .LR internal . The swap operation is a bit mask:

.L 0 No swapping necessary.

.L 1 Swap byte .L 0 with byte .LR 1 .

.L 2 Swap bytes .L 0 and .L 1 with bytes .L 2 and .LR 3 .

.L 4 Swap bytes .L 0-3 with bytes .LR 4-7 , and so on. The largest native integral type is defined by the macro .L int_max in the header .L <int.h> described in int (3).

.L swapget returns the .L width byte integer in the buffer .LR from , swapped according to .LR op .

.L swapput copies the .L width byte integer .L value into the buffer .LR to , swapped according to .LR op . .L to is returned.

.L swapmem swaps .L n bytes from the buffer .L from to the buffer .L to according to .LR op . .L to and .L from may be the same.

"SEE ALSO"
int(3)