escript
Revision_
|
00001 00002 /***************************************************************************** 00003 * 00004 * Copyright (c) 2003-2014 by University of Queensland 00005 * http://www.uq.edu.au 00006 * 00007 * Primary Business: Queensland, Australia 00008 * Licensed under the Open Software License version 3.0 00009 * http://www.opensource.org/licenses/osl-3.0.php 00010 * 00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC) 00012 * Development 2012-2013 by School of Earth Sciences 00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp) 00014 * 00015 *****************************************************************************/ 00016 00017 #ifndef __RIPLEY_SYSTEM_DEP_H__ 00018 #define __RIPLEY_SYSTEM_DEP_H__ 00019 00020 #if defined(_WIN32) && defined(__INTEL_COMPILER) 00021 /* 00022 * The Intel compiler on windows has an "improved" math library compared to 00023 * the usual Visual C++ one. In particular it has acosh and other similar 00024 * functions which aren't implemented in Visual C++ math.h. 00025 * Note you will get a compile time error if any other header (including 00026 * system ones) includes math.h whilst mathimf.h has been included. 00027 * As a result system_dep.h must be included FIRST at all times (this 00028 * prevents math.h from being included). 00029 */ 00030 # include <mathimf.h> 00031 #else 00032 # include <cmath> 00033 #endif 00034 00035 #define RIPLEY_DLL_API 00036 00037 #ifdef _WIN32 00038 # ifndef RIPLEY_STATIC_LIB 00039 # undef RIPLEY_DLL_API 00040 # ifdef RIPLEY_EXPORTS 00041 # define RIPLEY_DLL_API __declspec(dllexport) 00042 # else 00043 # define RIPLEY_DLL_API __declspec(dllimport) 00044 # endif 00045 # endif 00046 #endif 00047 00048 00049 // byte swapping / endianness: 00050 00051 #include <boost/detail/endian.hpp> 00052 00053 namespace ripley { 00054 00055 enum { 00056 BYTEORDER_NATIVE = BOOST_BYTE_ORDER, 00057 BYTEORDER_LITTLE_ENDIAN = 1234, 00058 BYTEORDER_BIG_ENDIAN = 4321 00059 }; 00060 00061 enum { 00062 DATATYPE_INT32 = 1, 00063 DATATYPE_FLOAT32, 00064 DATATYPE_FLOAT64 00065 }; 00066 00067 } // namespace 00068 00069 #ifdef _WIN32 00070 #include <stdlib.h> 00071 namespace ripley { 00072 inline char* byte_swap32(char* val) 00073 { 00074 unsigned long* v = reinterpret_cast<unsigned long*>(val); 00075 *v = _byteswap_ulong(*v); 00076 return val; 00077 } 00078 } // namespace 00079 00080 #else 00081 00082 #if HAVE_BYTESWAP_H 00083 # include <byteswap.h> 00084 #elif HAVE_SYS_ENDIAN_H 00085 # include <sys/endian.h> 00086 # ifdef bswap32 00087 # define bswap_32(D) bswap32((D)) 00088 # endif 00089 #elif HAVE_OSBYTEORDER_H 00090 # include <libkern/OSByteOrder.h> 00091 # define bswap_32 OSSwapInt32 00092 #else // uh oh, we can't swap bytes... 00093 # define bswap_32(D) D 00094 #endif // header selection 00095 00096 namespace ripley { 00097 inline char* byte_swap32(char* val) 00098 { 00099 unsigned int* v = reinterpret_cast<unsigned int*>(val); 00100 *v = bswap_32(*v); 00101 return val; 00102 } 00103 } // namespace ripley 00104 00105 #endif // WIN32 00106 00107 00108 #endif // __RIPLEY_SYSTEM_DEP_H__ 00109