Functions
swap.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "include/swap.h"
Include dependency graph for swap.c:

Functions

int little_endian ()
void swap (void *from, void *to, int size)
void swabip (void *buf, int size)
void swawbip (void *buf, int size)
void swawip (void *buf, int size)
void printf32bits (void *buf)

Function Documentation

int little_endian ( )
Check whether current platform uses little endian byte order.
See H&S Sec. 6.1.2 pp. 163-4.
Returns:
Returns 1, if current platform is little endian, and 0 if not.
void printf32bits ( void *  buf)

Printfs as bit string the 32-bit variable pointed to by buf. Far from being optimized, thus only for testing and development purposes.

Parameters:
bufPointer to memory
void swabip ( void *  buf,
int  size 
)

In-place swab, replaces the non-ANSI function swab(), which may not work if data is overlapping.

Parameters:
bufPointer to memory
sizeSize of buf in bytes

References Memory_handler::size.

void swap ( void *  from,
void *  to,
int  size 
)

Swaps the specified short int, int, long int, float, or double from little endian to big endian or vice versa. Arguments are allowed to overlap.

Parameters:
fromPointer to a short int, int, long int, float, or double variable
toPointer to a short int, int, long int, float, or double variable
sizeSize of from and to (byte nr) must be 1, 2, 4 or 8.

References swap().

Referenced by intExpand(), and swap().

Here is the call graph for this function:

void swawbip ( void *  buf,
int  size 
)

In-place swab and swaw, switches words and bytes from an array of 4-byte ints or floats.

Parameters:
bufPointer to memory
sizeSize of buf in bytes

References Memory_handler::size.

void swawip ( void *  buf,
int  size 
)

In-place swaw, switches words (but not bytes) from an array of 4-byte ints or floats.

Parameters:
bufPointer to memory
sizeSize of buf in bytes

References Memory_handler::size.