Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phByteOrderPrivate.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004     
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008     
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser 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     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 #ifndef _PHBYTEORDERPRIVATE_H
00027 #define _PHBYTEORDERPRIVATE_H
00028 
00043 #ifndef PH_USE_BYTEORDERPRIVATE
00044     #define PH_USE_BYTEORDERPRIVATE 0
00045 #endif
00046 
00047 #if PH_USE_BYTEORDERPRIVATE
00048 
00049 /* Stole/Copied the following from arpa/nameser_compat.h */
00050 #ifndef BYTE_ORDER
00051     /*#warning "#ifndef BYTE_ORDER"*/
00052     #if (BSD >= 199103)
00053         /*#warning "(BSD >= 199103)"*/
00054         # include <machine/endian.h>
00055     #elif defined(linux)
00056         /*#warning "#ifdef linux"*/
00057         # include <endian.h>
00058     #endif
00059 #endif        
00060 
00061 /* Define __BIG_ENDIAN if it's not defined */
00062 #if !defined(__BIG_ENDIAN)
00063     #if defined(BIG_ENDIAN)
00064         #define __BIG_ENDIAN    BIG_ENDIAN
00065     #else
00066         #define __BIG_ENDIAN    4321
00067     #endif
00068 #endif
00069 
00070 /* Define __LITTLE_ENDIAN if it's not defined */
00071 #if !defined(__LITTLE_ENDIAN)
00072     #if defined(LITTLE_ENDIAN)
00073         #define __LITTLE_ENDIAN LITTLE_ENDIAN
00074     #else
00075         #define __LITTLE_ENDIAN   1234
00076     #endif
00077 #endif
00078 
00079 /* Define BYTE_ORDER to be __BYTE_ORDER if it's defined */
00080 #if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
00081     #define BYTE_ORDER __BYTE_ORDER
00082 #endif
00083     
00084 /* least-significant byte first (vax, pc) */
00085 #if !defined(LITTLE_ENDIAN) || !(BIG_ENDIAN > 0)
00086     #define LITTLE_ENDIAN __LITTLE_ENDIAN
00087 #endif
00088     
00089 /* most-significant byte first (IBM, net) */
00090 #if !defined(BIG_ENDIAN) || !(BIG_ENDIAN > 0)
00091     #define BIG_ENDIAN __BIG_ENDIAN
00092 #endif
00093 
00094 /* Define the phission preprocessor definitions for byte order */
00095 #define phBYTE_ORDER    BYTE_ORDER
00096 #define phLITTLE_ENDIAN LITTLE_ENDIAN
00097 #define phBIG_ENDIAN    BIG_ENDIAN
00098 
00099 /* If we're not in the usual Linux development environment,
00100  * Try to guess the byte order from the machine we're on */
00101 #if !defined(linux) && !defined(BYTE_ORDER)
00102     #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
00103         defined(__i386__) || \
00104         defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
00105         defined(__alpha__) || defined(__alpha) || \
00106         (defined(__Lynx__) && defined(__x86__)) || \
00107         /* added for blackfin */ \
00108         defined(bfin) || \
00109         /* added for vdsp++ build */ \
00110         defined(__ADSPBLACKFIN__) || \
00111         /* added for visual studio build */ \
00112         defined(_M_IX86)
00113         
00114         #define BYTE_ORDER LITTLE_ENDIAN
00115     #endif
00116 
00117     #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
00118         defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
00119         defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
00120         defined(apollo) || defined(__convex__) || defined(_CRAY) || \
00121         defined(__hppa) || defined(__hp9000) || \
00122         defined(__hp9000s300) || defined(__hp9000s700) || \
00123         defined(__hp3000s900) || defined(MPE) || \
00124         defined (BIT_ZERO_ON_LEFT) || defined(m68k) || \
00125         (defined(__Lynx__) && \
00126          (defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
00127         
00128         #define BYTE_ORDER BIG_ENDIAN
00129     #endif
00130 #endif /* !defined(linux) && !defined(BYTE_ORDER)*/
00131 
00132 /* If we're not wrapping this header file in SWIG,
00133  * and byte order isn't defined or isn't valid, 
00134  * then print an appropriate warning it the warning directive is 
00135  * allowed by the preprocessor */
00136 #if !defined(SWIG) && \
00137     (!defined(phBYTE_ORDER) || \
00138     (phBYTE_ORDER != phBIG_ENDIAN && phBYTE_ORDER != phLITTLE_ENDIAN))
00139     /* you must determine what the correct bit order is for
00140      * your compiler - the next line is an intentional error
00141      * which will force your compiles to bomb until you fix
00142      * the above macros.
00143      */
00144 
00145     #if !defined(phBYTE_ORDER)
00146         #warning "!defined(phBYTE_ORDER)"
00147     #endif
00148     #if (phBYTE_ORDER != phBIG_ENDIAN)
00149         #warning "(phBYTE_ORDER != phBIG_ENDIAN)"
00150     #endif
00151     #if (phBYTE_ORDER != phLITTLE_ENDIAN)
00152         #warning "(phBYTE_ORDER != phLITTLE_ENDIAN)"
00153     #endif
00154 
00155     #error "Undefined or invalid phBYTE_ORDER";
00156 #endif
00157     
00158 #endif /* if PH_USE_BYTEORDERPRIVATE */
00159  /* end \addtogroup ByteOrder */
00161     
00162 #endif /* _PHBYTEORDER_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:01 2007 for phission by  doxygen 1.4.4