| 1 | /* gsl_inline.h |
| 2 | * |
| 3 | * Copyright (C) 2008, 2009 Brian Gough |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __GSL_INLINE_H__ |
| 21 | #define __GSL_INLINE_H__ |
| 22 | |
| 23 | /* In recent versiions of GCC, the inline keyword has two different |
| 24 | forms: GNU and C99. |
| 25 | |
| 26 | In GNU mode we can use 'extern inline' to make inline functions |
| 27 | work like macros. The function is only inlined--it is never output |
| 28 | as a definition in an object file. |
| 29 | |
| 30 | In the new C99 mode 'extern inline' has a different meaning--it |
| 31 | causes the definition of the function to be output in each object |
| 32 | file where it is used. This will result in multiple-definition |
| 33 | errors on linking. The 'inline' keyword on its own (without |
| 34 | extern) has the same behavior as the original GNU 'extern inline'. |
| 35 | |
| 36 | The C99 style is the default with -std=c99 in GCC 4.3. |
| 37 | |
| 38 | This header file allows either form of inline to be used by |
| 39 | redefining the macros INLINE_DECL and INLINE_FUN. These are used |
| 40 | in the public header files as |
| 41 | |
| 42 | INLINE_DECL double gsl_foo (double x); |
| 43 | #ifdef HAVE_INLINE |
| 44 | INLINE_FUN double gsl_foo (double x) { return x+1.0; } ; |
| 45 | #endif |
| 46 | |
| 47 | */ |
| 48 | |
| 49 | #ifdef HAVE_INLINE |
| 50 | # if defined(__GNUC_STDC_INLINE__) || defined(GSL_C99_INLINE) || defined(HAVE_C99_INLINE) |
| 51 | # define INLINE_DECL inline /* use C99 inline */ |
| 52 | # define INLINE_FUN inline |
| 53 | # else |
| 54 | # define INLINE_DECL /* use GNU extern inline */ |
| 55 | # define INLINE_FUN extern inline |
| 56 | # endif |
| 57 | #else |
| 58 | # define INLINE_DECL /* */ |
| 59 | #endif |
| 60 | |
| 61 | /* Range checking conditions in headers do not require any run-time |
| 62 | tests of the global variable gsl_check_range. They are enabled or |
| 63 | disabled in user code at compile time with GSL_RANGE_CHECK macro. |
| 64 | See also build.h. */ |
| 65 | #define GSL_RANGE_COND(x) (x) |
| 66 | |
| 67 | #endif /* __GSL_INLINE_H__ */ |
| 68 | |