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