/* * Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory */ /* * * swap.c -- swap data between native and IEEE format * * */ #include #include #include /* * * swap.c -- routines to swap parts of data * */ #define _idx(x, n) ((unsigned char *) x)[n] /* from Harbison&Steele by way of GNU cinfigure ... returns 1 for bigendian, 0 for littleendian */ #ifdef ANSI_FUNC int is_bigendian (void) #else int is_bigendian() #endif { union { long l; char c[sizeof (long)]; } u; u.l = 1; return(u.c[sizeof (long) - 1] == 1); } #ifdef ANSI_FUNC void swap_short (short *buf, int n) #else void swap_short(buf, n) short *buf; int n; #endif { int i; register short *ptr; short val; ptr = buf; for(i=0; i