C Standard Library Extensions  6.2.0
Functions
Low-level byte-swapping routines

Functions

unsigned short qfits_swap_bytes_16 (unsigned short w)
 Swap a 16-bit number. More...
 
unsigned int qfits_swap_bytes_32 (unsigned int dw)
 Swap a 32-bit number. More...
 
void qfits_swap_bytes (void *p, int s)
 Swaps bytes in a variable of given size. More...
 

Detailed Description

This module offers access to byte-swapping routines. Generic routines are offered that should work everywhere. Assembler is also included for x86 architectures, and dedicated assembler calls for processors > 386.

Function Documentation

void qfits_swap_bytes ( void *  p,
int  s 
)

Swaps bytes in a variable of given size.

Parameters
ppointer to void (generic pointer)
ssize of the element to swap, pointed to by p
Returns
void

This byte-swapper is portable and works for any even variable size. It is not truly the most efficient ever, but does its job fine everywhere this file compiles.

Referenced by qfits_query_column(), and qfits_query_column_seq().

unsigned short qfits_swap_bytes_16 ( unsigned short  w)

Swap a 16-bit number.

Parameters
wA 16-bit (short) number to byte-swap.
Returns
The swapped version of w, w is untouched.

This function swaps a 16-bit number, returned the swapped value without modifying the passed argument. Assembler included for x86 architectures.

unsigned int qfits_swap_bytes_32 ( unsigned int  dw)

Swap a 32-bit number.

Parameters
dwA 32-bit (long) number to byte-swap.
Returns
The swapped version of dw, dw is untouched.

This function swaps a 32-bit number, returned the swapped value without modifying the passed argument. Assembler included for x86 architectures and optimized for processors above 386.