Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:16

0001 /* Common macro definitions for C include files.
0002    Copyright (C) 2008-2023 Free Software Foundation, Inc.
0003 
0004    This program is free software: you can redistribute it and/or
0005    modify it under the terms of either:
0006 
0007      * the GNU Lesser General Public License as published by the Free
0008        Software Foundation; either version 3 of the License, or (at your
0009        option) any later version.
0010 
0011    or
0012 
0013      * the GNU General Public License as published by the Free
0014        Software Foundation; either version 2 of the License, or (at your
0015        option) any later version.
0016 
0017    or both in parallel, as here.
0018    This program is distributed in the hope that it will be useful,
0019    but WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021    GNU Lesser General Public License for more details.
0022 
0023    You should have received a copy of the GNU Lesser General Public License
0024    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
0025 
0026 #ifndef _UNISTRING_CDEFS_H
0027 #define _UNISTRING_CDEFS_H
0028 
0029 /* _GL_UNUSED_PARAMETER is a marker that can be prepended to function parameter
0030    declarations for parameters that are not used.  This helps to reduce
0031    warnings, such as from GCC -Wunused-parameter.  The syntax is as follows:
0032        _GL_UNUSED_PARAMETER type param
0033    or more generally
0034        _GL_UNUSED_PARAMETER param_decl
0035    For example:
0036        _GL_UNUSED_PARAMETER int param
0037        _GL_UNUSED_PARAMETER int *(*param) (void)
0038  */
0039 #ifndef _GL_UNUSED_PARAMETER
0040 # define _GL_UNUSED_PARAMETER _UC_ATTRIBUTE_MAYBE_UNUSED
0041 #endif
0042 /* _GL_ATTRIBUTE_MAYBE_UNUSED likewise.  */
0043 #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
0044 # define _GL_ATTRIBUTE_MAYBE_UNUSED _UC_ATTRIBUTE_MAYBE_UNUSED
0045 #endif
0046 
0047 #ifndef _GL_ATTRIBUTE_MALLOC
0048 # define _GL_ATTRIBUTE_MALLOC _UC_ATTRIBUTE_MALLOC
0049 #endif
0050 
0051 /* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers
0052    that can be freed by passing them as the Ith argument to the
0053    function F.  _UC_ATTRIBUTE_DEALLOC_FREE is for functions that
0054    return pointers that can be freed via 'free'; it can be used
0055    only after including stdlib.h.  These macros cannot be used on
0056    inline functions.  */
0057 #ifndef _GL_ATTRIBUTE_DEALLOC
0058 # define _GL_ATTRIBUTE_DEALLOC _UC_ATTRIBUTE_DEALLOC
0059 #endif
0060 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
0061 # define _GL_ATTRIBUTE_DEALLOC_FREE _UC_ATTRIBUTE_DEALLOC_FREE
0062 #endif
0063 
0064 /* The definitions below are taken from gnulib/m4/gnulib-common.m4,
0065    with prefix _UC instead of prefix _GL.  */
0066 
0067 /* True if the compiler says it groks GNU C version MAJOR.MINOR.  */
0068 #if defined __GNUC__ && defined __GNUC_MINOR__
0069 # define _UC_GNUC_PREREQ(major, minor) \
0070     ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
0071 #else
0072 # define _UC_GNUC_PREREQ(major, minor) 0
0073 #endif
0074 
0075 #if (defined __has_attribute \
0076      && (!defined __clang_minor__ \
0077          || (defined __apple_build_version__ \
0078              ? 6000000 <= __apple_build_version__ \
0079              : 5 <= __clang_major__)))
0080 # define _UC_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
0081 #else
0082 # define _UC_HAS_ATTRIBUTE(attr) _UC_ATTR_##attr
0083 # define _UC_ATTR_malloc _UC_GNUC_PREREQ (3, 0)
0084 # define _UC_ATTR_unused _UC_GNUC_PREREQ (2, 7)
0085 #endif
0086 
0087 #ifdef __cplusplus
0088 # if defined __clang__
0089 #  define _UC_BRACKET_BEFORE_ATTRIBUTE 1
0090 # endif
0091 #else
0092 # if defined __GNUC__ && !defined __clang__
0093 #  define _UC_BRACKET_BEFORE_ATTRIBUTE 1
0094 # endif
0095 #endif
0096 
0097 #if _UC_GNUC_PREREQ (11, 0)
0098 # define _UC_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
0099 #else
0100 # define _UC_ATTRIBUTE_DEALLOC(f, i)
0101 #endif
0102 #if defined __cplusplus && defined __GNUC__ && !defined __clang__
0103 /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
0104 # define _UC_ATTRIBUTE_DEALLOC_FREE \
0105     _UC_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
0106 #else
0107 # define _UC_ATTRIBUTE_DEALLOC_FREE \
0108     _UC_ATTRIBUTE_DEALLOC (free, 1)
0109 #endif
0110 
0111 #if _UC_HAS_ATTRIBUTE (malloc)
0112 # define _UC_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
0113 #else
0114 # define _UC_ATTRIBUTE_MALLOC
0115 #endif
0116 
0117 #ifndef _UC_BRACKET_BEFORE_ATTRIBUTE
0118 # if defined __clang__ && defined __cplusplus
0119 #  if !defined __apple_build_version__ && __clang_major__ >= 10
0120 #   define _UC_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
0121 #  endif
0122 # elif defined __has_c_attribute
0123 #  if __has_c_attribute (__maybe_unused__)
0124 #   define _UC_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
0125 #  endif
0126 # endif
0127 #endif
0128 #ifndef _UC_ATTRIBUTE_MAYBE_UNUSED
0129 # define _UC_ATTRIBUTE_MAYBE_UNUSED _UC_ATTRIBUTE_UNUSED
0130 #endif
0131 
0132 #if _UC_HAS_ATTRIBUTE (unused)
0133 # define _UC_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
0134 #else
0135 # define _UC_ATTRIBUTE_UNUSED
0136 #endif
0137 
0138 #endif /* _UNISTRING_CDEFS_H */