C Standard Library Extensions: Low-level byte-swapping routines

C Standard Library Extensions 6.2.0

- Main Page
- Modules
- Classes
- Files

Functions
Low-level byte-swapping routines

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

## 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:

  p | pointer to void (generic pointer)
  s | size 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:

  w | A 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:

  dw | A 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.