1 // ***************************************************************************
2 // bamtools_global.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 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 #define BAMTOOLS_LIBRARY_EXPORT
19 #endif  // BAMTOOLS_LIBRARY_EXPORT
20 
21 /*! \brief Library import macro
22     \internal
23 */
24 #ifndef BAMTOOLS_LIBRARY_IMPORT
25 #define BAMTOOLS_LIBRARY_IMPORT
26 #endif  // BAMTOOLS_LIBRARY_IMPORT
27 
28 /*! \brief Platform-specific type definitions
29     \internal
30 */
31 #ifndef BAMTOOLS_LFS
32 #define BAMTOOLS_LFS
33 #ifdef _WIN32
34 #define ftell64(a) _ftelli64(a)
35 #define fseek64(a, b, c) _fseeki64(a, b, c)
36 #else
37 #define ftell64(a) ftello(a)
38 #define fseek64(a, b, c) fseeko(a, b, c)
39 #endif
40 #endif  // BAMTOOLS_LFS
41 
42 /*! \def ftell64(a)
43     \brief Platform-independent tell() operation.
44     \internal
45 */
46 /*! \def fseek64(a,b,c)
47     \brief Platform-independent seek() operation.
48     \internal
49 */
50 
51 /*! \brief Platform-specific type definitions
52     \internal
53 */
54 #ifndef BAMTOOLS_TYPES
55 #define BAMTOOLS_TYPES
56 #include <stdint.h>
57 #endif  // BAMTOOLS_TYPES
58 
59 //! \internal
bamtools_noop()60 inline void bamtools_noop() {}
61 
62 /*! \brief Assert definitions
63     \internal
64 */
65 #ifndef BAMTOOLS_ASSERTS
66 #define BAMTOOLS_ASSERTS
67 #ifdef NDEBUG
68 #define BT_ASSERT_UNREACHABLE bamtools_noop()
69 #define BT_ASSERT_X(condition, message) bamtools_noop()
70 #else
71 #include <cassert>
72 #include <stdexcept>
73 #define BT_ASSERT_UNREACHABLE assert(false)
74 #define BT_ASSERT_X(condition, message)    \
75     if (!(condition)) {                    \
76         throw std::runtime_error(message); \
77     }
78 #endif
79 #endif  // BAMTOOLS_ASSERTS
80 
81 #endif  // BAMTOOLS_GLOBAL_H
82