1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/*
Audio File Library
Copyright (C) 1998-1999, Michael Pruett <michael@68k.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307 USA.
*/
/*
byteorder.h
This file declares functions useful for dealing with byte
swapping.
*/
#ifndef BYTEORDER_H
#define BYTEORDER_H
#include <config.h>
#if WORDS_BIGENDIAN
#define __BIGENDIAN__
#define _AF_BYTEORDER_NATIVE (AF_BYTEORDER_BIGENDIAN)
#else
#define __LITTLEENDIAN__
#define _AF_BYTEORDER_NATIVE (AF_BYTEORDER_LITTLEENDIAN)
#endif
#ifndef uint16
typedef u_int16_t uint16;
#endif
#ifndef uint32
typedef u_int32_t uint32;
#endif
#ifdef __LITTLEENDIAN__
#define HOST_TO_LENDIAN_INT16(x) ((uint16) (x))
#define HOST_TO_LENDIAN_INT32(x) ((uint32) (x))
#define HOST_TO_LENDIAN_FLOAT32(x) ((float) (x))
#define HOST_TO_LENDIAN_DOUBLE64(x) ((double) (x))
#define LENDIAN_TO_HOST_INT16(x) ((uint16) (x))
#define LENDIAN_TO_HOST_INT32(x) ((uint32) (x))
#define LENDIAN_TO_HOST_FLOAT32(x) ((float) (x))
#define LENDIAN_TO_HOST_DOUBLE64(x) ((double) (x))
#else
#define HOST_TO_LENDIAN_INT16(x) _af_byteswap_int16(x)
#define HOST_TO_LENDIAN_INT32(x) _af_byteswap_int32(x)
#define HOST_TO_LENDIAN_FLOAT32(x) _af_byteswap_float32(x)
#define HOST_TO_LENDIAN_DOUBLE64(x) _af_byteswap_double64(x)
#define LENDIAN_TO_HOST_INT16(x) _af_byteswap_int16(x)
#define LENDIAN_TO_HOST_INT32(x) _af_byteswap_int32(x)
#define LENDIAN_TO_HOST_FLOAT32(x) _af_byteswap_float32(x)
#define LENDIAN_TO_HOST_DOUBLE64(x) _af_byteswap_double64(x)
#endif
#ifdef __BIGENDIAN__
#define HOST_TO_BENDIAN_INT16(x) ((uint16) (x))
#define HOST_TO_BENDIAN_INT32(x) ((uint32) (x))
#define HOST_TO_BENDIAN_FLOAT32(x) ((float) (x))
#define HOST_TO_BENDIAN_DOUBLE64(x) ((double) (x))
#define BENDIAN_TO_HOST_INT16(x) ((uint16) (x))
#define BENDIAN_TO_HOST_INT32(x) ((uint32) (x))
#define BENDIAN_TO_HOST_FLOAT32(x) ((float) (x))
#define BENDIAN_TO_HOST_DOUBLE64(x) ((double) (x))
#else
#define HOST_TO_BENDIAN_INT16(x) _af_byteswap_int16(x)
#define HOST_TO_BENDIAN_INT32(x) _af_byteswap_int32(x)
#define HOST_TO_BENDIAN_FLOAT32(x) _af_byteswap_float32(x)
#define HOST_TO_BENDIAN_DOUBLE64(x) _af_byteswap_double64(x)
#define BENDIAN_TO_HOST_INT16(x) _af_byteswap_int16(x)
#define BENDIAN_TO_HOST_INT32(x) _af_byteswap_int32(x)
#define BENDIAN_TO_HOST_FLOAT32(x) _af_byteswap_float32(x)
#define BENDIAN_TO_HOST_DOUBLE64(x) _af_byteswap_double64(x)
#endif
u_int16_t _af_byteswap_int16 (u_int16_t x);
u_int32_t _af_byteswap_int32 (u_int32_t x);
float _af_byteswap_float32 (float x);
double _af_byteswap_double64 (double x);
#endif
|