/[escript]/trunk/ripley/src/system_dep.h
ViewVC logotype

Contents of /trunk/ripley/src/system_dep.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4357 - (show annotations)
Thu Apr 11 06:07:14 2013 UTC (6 years, 4 months ago) by caltinay
File MIME type: text/plain
File size: 2411 byte(s)
templated writeBinaryGrid and a bit of cleanup.

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,
56 BYTEORDER_LITTLE_ENDIAN = 1234,
57 BYTEORDER_BIG_ENDIAN = 4321
58 };
59
60 enum {
61 DATATYPE_INT32 = 1,
62 DATATYPE_FLOAT32,
63 DATATYPE_FLOAT64
64 };
65
66 #ifdef _WIN32
67 #include <stdlib.h>
68 inline char* byte_swap32(char* val)
69 {
70 unsigned long* v = reinterpret_cast<unsigned long*>(val);
71 *v = _byteswap_ulong(*v);
72 return val;
73 }
74
75 #else
76
77 #if HAVE_BYTESWAP_H
78 # include <byteswap.h>
79 #elif HAVE_SYS_ENDIAN_H
80 # include <sys/endian.h>
81 #elif HAVE_OSBYTEORDER_H
82 # include <libkern/OSByteOrder.h>
83 # define bswap_32 OSSwapInt32
84 #else // uh oh, we can't swap bytes...
85 # define bswap_32(D) D
86 #endif // header selection
87
88 inline char* byte_swap32(char* val)
89 {
90 unsigned int* v = reinterpret_cast<unsigned int*>(val);
91 *v = bswap_32(*v);
92 return val;
93 }
94 #endif // WIN32
95
96 } // namespace ripley
97
98
99 #endif // __RIPLEY_SYSTEM_DEP_H__
100

  ViewVC Help
Powered by ViewVC 1.1.26