usrp_bytesex.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2004 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 #ifndef INCLUDED_USRP_BYTESEX_H
00023 #define INCLUDED_USRP_BYTESEX_H
00024 
00033 #ifdef HAVE_BYTESWAP_H
00034 #include <byteswap.h>
00035 #else
00036 static inline unsigned short int
00037 bswap_16 (unsigned short int x)
00038 {
00039   return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
00040 }
00041 #endif
00042 
00043 
00044 #ifdef WORDS_BIGENDIAN
00045 
00046 static inline short int
00047 host_to_usrp_short (short int x)
00048 {
00049   return bswap_16 (x);
00050 }
00051 
00052 static inline short int
00053 usrp_to_host_short (short int x)
00054 {
00055   return bswap_16 (x);
00056 }
00057 
00058 #else
00059 
00060 static inline short int
00061 host_to_usrp_short (short int x)
00062 {
00063   return x;
00064 }
00065 
00066 static inline short int
00067 usrp_to_host_short (unsigned short int x)
00068 {
00069   return x;
00070 }
00071 
00072 #endif
00073 
00074 #endif /* INCLUDED_USRP_BYTESEX_H */

Generated on Wed Jan 17 16:24:51 2007 for Universal Software Radio Peripheral by  doxygen 1.5.1