NCEPLIBS-bacio
2.5.0
|
This file contains various implementations of fast byteswapping routines. More...
#include <byteswap.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include "clib.h"
#include "fast-byteswap.h"
Go to the source code of this file.
Functions | |
void | byteswap_ (char *data, int *nbyte, int *nnum) |
Byteswap. More... | |
int | fast_byteswap (void *data, int bytes, size_t count) |
Fast byteswap. More... | |
void | fast_byteswap_errors (int flag) |
Set a flag to turn warnings off for non-aligned pointers. More... | |
static int | macro_swap_64 (void *data, size_t len) |
Use the GNU macros, which are specialized byteswap ASM instructions. More... | |
static int | simple_swap_16 (void *data, size_t len) |
Simple single-value loops. More... | |
static int | simple_swap_32 (void *data, size_t len) |
Simple single-value loops. More... | |
Variables | |
static int | send_errors = 1 |
If non-zero, warn about non-aligned pointers. More... | |
This file contains various implementations of fast byteswapping routines.
The main entry point, fast_byteswap(), is the only one you should need, and it should be modified to use whatever method is fastest on your architecture.
In all cases, the routines return 1 on success and 0 on failure. They only fail if your data is non-aligned. All routines require that arrays of N-bit data be N-bit aligned. If they are not, an error will be sent to stderr and the routine will return non-zero. To silence the error message, call fast_byteswap_errors(0).
Definition in file byteswap.c.
void byteswap_ | ( | char * | data, |
int * | nbyte, | ||
int * | nnum | ||
) |
Byteswap.
data | Data |
nbyte | Number of bytes. |
nnum | NNUM |
Definition at line 161 of file byteswap.c.
References fast_byteswap().
int fast_byteswap | ( | void * | data, |
int | bytes, | ||
size_t | count | ||
) |
Fast byteswap.
data | data |
bytes | Number of bytes |
count | Count. |
Definition at line 136 of file byteswap.c.
References macro_swap_64(), simple_swap_16(), and simple_swap_32().
Referenced by byteswap_().
void fast_byteswap_errors | ( | int | flag | ) |
Set a flag to turn warnings off for non-aligned pointers.
flag | Set to 0 to turn off warnings, non-zero to turn them on (the default). |
Definition at line 39 of file byteswap.c.
References send_errors.
|
static |
Use the GNU macros, which are specialized byteswap ASM instructions.
data | data |
len | Length |
Definition at line 110 of file byteswap.c.
References send_errors.
Referenced by fast_byteswap().
|
static |
Simple single-value loops.
data | data |
len | Length |
Definition at line 82 of file byteswap.c.
References send_errors.
Referenced by fast_byteswap().
|
static |
Simple single-value loops.
data | data |
len | Length |
Definition at line 53 of file byteswap.c.
References send_errors.
Referenced by fast_byteswap().
|
static |
If non-zero, warn about non-aligned pointers.
Definition at line 30 of file byteswap.c.
Referenced by fast_byteswap_errors(), macro_swap_64(), simple_swap_16(), and simple_swap_32().