Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / utility / current_function.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2015,2019, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \file
36  * \brief
37  * Declares GMX_CURRENT_FUNCTION for getting the current function name.
38  *
39  * The implementation is essentially copied from Boost 1.55 (see reference below).
40  *
41  * \ingroup module_utility
42  */
43 #ifndef GMX_UTILITY_CURRENT_FUNCTION_H
44 #define GMX_UTILITY_CURRENT_FUNCTION_H
45
46 /*! \def GMX_CURRENT_FUNCTION
47  * \brief
48  * Expands to a string that provides the name of the current function.
49  *
50  * \ingroup module_utility
51  */
52
53 //
54 //  boost/current_function.hpp - BOOST_CURRENT_FUNCTION
55 //
56 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
57 //
58 // Distributed under the Boost Software License, Version 1.0. (See
59 // accompanying file LICENSE_1_0.txt or copy at
60 // http://www.boost.org/LICENSE_1_0.txt)
61 //
62 //  http://www.boost.org/libs/utility/current_function.html
63 //
64
65 namespace gmx
66 {
67
68 namespace internal
69 {
70
71 //! Helper for defining GMX_CURRENT_FUNCTION.
72 inline void current_function_helper()
73 {
74
75 #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
76         || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
77
78 #    define GMX_CURRENT_FUNCTION __PRETTY_FUNCTION__
79
80 #elif defined(__DMC__) && (__DMC__ >= 0x810)
81
82 #    define GMX_CURRENT_FUNCTION __PRETTY_FUNCTION__
83
84 #elif defined(__FUNCSIG__)
85
86 #    define GMX_CURRENT_FUNCTION __FUNCSIG__
87
88 #elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \
89         || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
90
91 #    define GMX_CURRENT_FUNCTION __FUNCTION__
92
93 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
94
95 #    define GMX_CURRENT_FUNCTION __FUNC__
96
97 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
98
99 #    define GMX_CURRENT_FUNCTION __func__
100
101 #else
102
103 #    define GMX_CURRENT_FUNCTION "(unknown)"
104
105 #endif
106 }
107
108 } // namespace internal
109
110 } // namespace gmx
111
112 #endif