kstars
byteorder.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 byteorder.h - Define byteswapping macros if required 00003 ------------------- 00004 begin : Mon Aug 10 2009 15:29 IST 00005 copyright : (c) 2009 by Akarsh Simha 00006 email : akarsh.simha@kdemail.net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 /* 00019 NOTE: This file was written from scratch using several headers written 00020 by others as reference. Of particular mention is LICQ's 00021 licq_bytorder.h and Oskar Liljeblad's byteswap.h licensed under the 00022 GPL. 00023 */ 00024 00025 #ifndef BYTEORDER_H_ 00026 #define BYTEORDER_H_ 00027 00028 // Check if we have standard byteswap headers 00029 00030 #ifdef HAVE_BYTESWAP_H 00031 #include <byteswap.h> 00032 00033 #elif defined HAVE_MACHINE_ENDIAN_H 00034 #include <machine/endian.h> 00035 #define bswap_16(x) swap16(x) 00036 #define bswap_32(x) swap32(x) 00037 00038 #elif defined HAVE_SYS_BYTEORDER_H 00039 #include <sys/byteorder.h> 00040 #define bswap_16(x) BSWAP_16(x) 00041 #define bswap_32(x) BSWAP_32(x) 00042 #endif 00043 00044 // If no standard headers are found, we define our own byteswap macros 00045 00046 #ifndef bswap_16 00047 #define bswap_16(x) ((( (x) & 0x00FF ) << 8) | (( (x) & 0xFF00 ) >> 8)) 00048 #endif 00049 00050 #ifndef bswap_32 00051 00052 #define bswap_32(x) ((( (x) & 0x000000FF ) << 24) | (( (x) & 0x0000FF00 ) << 8) \ 00053 | (( (x) & 0x00FF0000 ) >> 8) | (( (x) & 0xFF000000 ) >> 24)) 00054 #endif 00055 00056 #endif
KDE 4.5 API Reference