]> git.donarmstrong.com Git - bamtools.git/blob - src/shared/bamtools_global.h
4165740ef4cc03f3a86389bd2672f5d7ea1f106b
[bamtools.git] / src / shared / bamtools_global.h
1 // ***************************************************************************
2 // bamtools_global.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 7 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides the basic definitions for exporting & importing library symbols.
8 // Also provides some platform-specific rules for definitions.
9 // ***************************************************************************
10
11 #ifndef BAMTOOLS_GLOBAL_H
12 #define BAMTOOLS_GLOBAL_H
13
14 /*! \brief Library export macro
15     \internal
16 */
17 #ifndef BAMTOOLS_LIBRARY_EXPORT
18 #  if defined(WIN32)
19 #    define BAMTOOLS_LIBRARY_EXPORT __declspec(dllexport)
20 #  else
21 #    define BAMTOOLS_LIBRARY_EXPORT __attribute__((visibility("default")))
22 #  endif
23 #endif // BAMTOOLS_LIBRARY_EXPORT
24
25 /*! \brief Library import macro
26     \internal
27 */
28 #ifndef BAMTOOLS_LIBRARY_IMPORT
29 #  if defined(WIN32)
30 #    define BAMTOOLS_LIBRARY_IMPORT __declspec(dllimport)
31 #  else
32 #    define BAMTOOLS_LIBRARY_IMPORT
33 #  endif
34 #endif // BAMTOOLS_LIBRARY_IMPORT
35
36 /*! \brief Platform-specific type definitions
37     \internal
38 */
39 #ifndef BAMTOOLS_LFS
40 #define BAMTOOLS_LFS
41 #  ifdef WIN32
42 #    define ftell64(a)     _ftelli64(a)
43 #    define fseek64(a,b,c) _fseeki64(a,b,c)
44 #  else
45 #    define ftell64(a)     ftello(a)
46 #    define fseek64(a,b,c) fseeko(a,b,c)
47 #  endif
48 #endif // BAMTOOLS_LFS
49
50 /*! \def ftell64(a)
51     \brief Platform-independent tell() operation.
52     \internal
53 */
54 /*! \def fseek64(a,b,c)
55     \brief Platform-independent seek() operation.
56     \internal
57 */
58
59 /*! \brief Platform-specific type definitions
60     \internal
61 */
62 #ifndef BAMTOOLS_TYPES
63 #define BAMTOOLS_TYPES
64 #  ifdef _MSC_VER
65      typedef char                 int8_t;
66      typedef unsigned char       uint8_t;
67      typedef short               int16_t;
68      typedef unsigned short     uint16_t;
69      typedef int                 int32_t;
70      typedef unsigned int       uint32_t;
71      typedef long long           int64_t;
72      typedef unsigned long long uint64_t;
73 #  else
74 #    include <stdint.h>
75 #  endif
76 #endif // BAMTOOLS_TYPES
77
78 inline void bamtools_noop(void) { }
79
80 #ifndef BAMTOOLS_ASSERTS
81 #define BAMTOOLS_ASSERTS
82 #  include <cassert>
83 #  include <stdexcept>
84 #  ifdef NDEBUG
85 #    define BT_ASSERT_UNREACHABLE bamtools_noop()
86 #    define BT_ASSERT_X( condition, message ) bamtools_noop()
87 #  else
88 #    define BT_ASSERT_UNREACHABLE assert( false )
89 #    define BT_ASSERT_X( condition, message ) if (!( condition )) { throw std::runtime_error( message ); }
90 #  endif
91 #endif // BAMTOOLS_ASSERTS
92
93 #endif // BAMTOOLS_GLOBAL_H