Reference

swap(3)

integral representation conversion routines

NAME

swap - integral representation conversion routines

SYNOPSIS

$1$2#include <swap.h>#include <swap.h>#include <swap.h>#include <swap.h>#include <swap.h>#include <swap.h>#include <swap.h>#include <swap.h>

$1$2int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width);int swapop(const void* internal, const void* external, int width); $1$2int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width);int_max swapget(int op, const void* from, int width); $1$2void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value);void* swapput(int op, void* to, int width, int_max value); $1$2void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);void* swapmem(int op, const void* from, void* to, size_t n);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 $1$2sfputusfputusfputusfputusfputusfputusfputusfputu and $1$2sgetusgetusgetusgetusgetusgetusgetusgetu

$1$2swapopswapopswapopswapopswapopswapopswapopswapop returns the swap operation required to convert the $1$2widthwidthwidthwidthwidthwidthwidthwidth byte integer $1$2externalexternalexternalexternalexternalexternalexternalexternal to the $1$2widthwidthwidthwidthwidthwidthwidthwidth byte integer $1$2internalinternalinternalinternalinternalinternalinternalinternal The swap operation is a bit mask:

$1$200000000

No swapping necessary.

$1$211111111

Swap byte $1$200000000 with byte $1$211111111

$1$222222222

Swap bytes $1$200000000 and $1$211111111 with bytes $1$222222222 and $1$233333333

$1$244444444

Swap bytes $1$20-30-30-30-30-30-30-30-3 with bytes $1$24-74-74-74-74-74-74-74-7 and so on. The largest native integral type is defined by the macro $1$2int_maxint_maxint_maxint_maxint_maxint_maxint_maxint_max in the header $1$2<int.h><int.h><int.h><int.h><int.h><int.h><int.h><int.h> described in int(3).

$1$2swapgetswapgetswapgetswapgetswapgetswapgetswapgetswapget returns the $1$2widthwidthwidthwidthwidthwidthwidthwidth byte integer in the buffer $1$2fromfromfromfromfromfromfromfrom swapped according to $1$2opopopopopopopop

$1$2swapputswapputswapputswapputswapputswapputswapputswapput copies the $1$2widthwidthwidthwidthwidthwidthwidthwidth byte integer $1$2valuevaluevaluevaluevaluevaluevaluevalue into the buffer $1$2totototototototo swapped according to $1$2opopopopopopopop $1$2totototototototo is returned.

$1$2swapmemswapmemswapmemswapmemswapmemswapmemswapmemswapmem swaps $1$2nnnnnnnn bytes from the buffer $1$2fromfromfromfromfromfromfromfrom to the buffer $1$2totototototototo according to $1$2opopopopopopopop $1$2totototototototo and $1$2fromfromfromfromfromfromfromfrom may be the same.

SEE ALSO

int(3)