ESScript  Revision_
ripley/src/system_dep.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 #ifndef __RIPLEY_SYSTEM_DEP_H__
17 #define __RIPLEY_SYSTEM_DEP_H__
18 
19 #if defined(_WIN32) && defined(__INTEL_COMPILER)
20 /*
21  * The Intel compiler on windows has an "improved" math library compared to
22  * the usual Visual C++ one. In particular it has acosh and other similar
23  * functions which aren't implemented in Visual C++ math.h.
24  * Note you will get a compile time error if any other header (including
25  * system ones) includes math.h whilst mathimf.h has been included.
26  * As a result system_dep.h must be included FIRST at all times (this
27  * prevents math.h from being included).
28  */
29 # include <mathimf.h>
30 #else
31 # include <cmath>
32 #endif
33 
34 #define RIPLEY_DLL_API
35 
36 #ifdef _WIN32
37 # ifndef RIPLEY_STATIC_LIB
38 # undef RIPLEY_DLL_API
39 # ifdef RIPLEY_EXPORTS
40 # define RIPLEY_DLL_API __declspec(dllexport)
41 # else
42 # define RIPLEY_DLL_API __declspec(dllimport)
43 # endif
44 # endif
45 #endif
46 
47 
48 // byte swapping / endianness:
49 
50 #include <boost/detail/endian.hpp>
51 
52 namespace ripley {
53 
54 enum {
55  BYTEORDER_NATIVE = BOOST_BYTE_ORDER,
58 };
59 
60 enum {
64 };
65 
66 } // namespace
67 
68 #ifdef _WIN32
69 #include <stdlib.h>
70 namespace ripley {
71 inline char* byte_swap32(char* val)
72 {
73  unsigned long* v = reinterpret_cast<unsigned long*>(val);
74  *v = _byteswap_ulong(*v);
75  return val;
76 }
77 } // namespace
78 
79 #else
80 
81 #if HAVE_BYTESWAP_H
82 # include <byteswap.h>
83 #elif HAVE_SYS_ENDIAN_H
84 # include <sys/endian.h>
85 # ifdef bswap32
86 # define bswap_32(D) bswap32((D))
87 # endif
88 #elif HAVE_OSBYTEORDER_H
89 # include <libkern/OSByteOrder.h>
90 # define bswap_32 OSSwapInt32
91 #else // uh oh, we can't swap bytes...
92 # define bswap_32(D) D
93 #endif // header selection
94 
95 namespace ripley {
96 inline char* byte_swap32(char* val)
97 {
98  unsigned int* v = reinterpret_cast<unsigned int*>(val);
99  *v = bswap_32(*v);
100  return val;
101 }
102 } // namespace ripley
103 
104 #endif // WIN32
105 
106 
107 #endif // __RIPLEY_SYSTEM_DEP_H__
108