inline.h (2695B)
1 /* Decision whether to use 'inline' or not. 2 Copyright (C) 2006-2023 Free Software Foundation, Inc. 3 4 This program is free software: you can redistribute it and/or 5 modify it under the terms of either: 6 7 * the GNU Lesser General Public License as published by the Free 8 Software Foundation; either version 3 of the License, or (at your 9 option) any later version. 10 11 or 12 13 * the GNU General Public License as published by the Free 14 Software Foundation; either version 2 of the License, or (at your 15 option) any later version. 16 17 or both in parallel, as here. 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public License 24 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 25 26 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */ 27 28 #ifndef _UNISTRING_INLINE_H 29 #define _UNISTRING_INLINE_H 30 31 /* This is like the gl_INLINE macro in gnulib/m4/inline.m4, but makes its 32 decision based on defined preprocessor symbols rather than through 33 autoconf tests. 34 See <https://lists.gnu.org/archive/html/bug-gnulib/2006-11/msg00055.html> */ 35 36 /* Test for the 'inline' keyword or equivalent. ISO C 99 semantics is not 37 required, only that 'static inline' works. 38 Define 'inline' to a supported equivalent, or to nothing if not supported, 39 like AC_C_INLINE does. Also, define UNISTRING_HAVE_INLINE if 'inline' or an 40 equivalent is effectively supported, i.e. if the compiler is likely to 41 drop unused 'static inline' functions. */ 42 43 #if defined __GNUC__ || defined __clang__ 44 /* GNU C/C++ or clang C/C++. */ 45 # if defined __NO_INLINE__ 46 /* GCC and clang define __NO_INLINE__ if not optimizing or if -fno-inline is 47 specified. */ 48 # define UNISTRING_HAVE_INLINE 0 49 # else 50 /* Whether 'inline' has the old GCC semantics or the ISO C 99 semantics, 51 does not matter. */ 52 # define UNISTRING_HAVE_INLINE 1 53 # ifndef inline 54 # define inline __inline__ 55 # endif 56 # endif 57 #elif defined __cplusplus 58 /* Any other C++ compiler. */ 59 # define UNISTRING_HAVE_INLINE 1 60 #else 61 /* Any other C compiler. */ 62 # if defined __osf__ 63 /* OSF/1 cc has inline. */ 64 # define UNISTRING_HAVE_INLINE 1 65 # elif defined _AIX || defined __sgi 66 /* AIX 4 xlc, IRIX 6.5 cc have __inline. */ 67 # define UNISTRING_HAVE_INLINE 1 68 # ifndef inline 69 # define inline __inline 70 # endif 71 # else 72 /* Some older C compiler. */ 73 # define UNISTRING_HAVE_INLINE 0 74 # endif 75 #endif 76 77 #endif /* _UNISTRING_INLINE_H */