Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:28:39

0001 /* Common macro definitions for C include files.
0002    Copyright (C) 2008-2025 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 /* _GL_UNNAMED serves the same purpose.  */
0047 #ifndef _GL_UNNAMED
0048 # define _GL_UNNAMED _UC_UNNAMED
0049 #endif
0050 
0051 #ifndef _GL_ATTRIBUTE_MALLOC
0052 # define _GL_ATTRIBUTE_MALLOC _UC_ATTRIBUTE_MALLOC
0053 #endif
0054 
0055 /* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers
0056    that can be freed by passing them as the Ith argument to the
0057    function F.  _UC_ATTRIBUTE_DEALLOC_FREE is for functions that
0058    return pointers that can be freed via 'free'; it can be used
0059    only after including stdlib.h.  These macros cannot be used on
0060    inline functions.  */
0061 #ifndef _GL_ATTRIBUTE_DEALLOC
0062 # define _GL_ATTRIBUTE_DEALLOC _UC_ATTRIBUTE_DEALLOC
0063 #endif
0064 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
0065 # define _GL_ATTRIBUTE_DEALLOC_FREE _UC_ATTRIBUTE_DEALLOC_FREE
0066 #endif
0067 
0068 /* The definitions below are taken from gnulib/m4/gnulib-common.m4,
0069    with prefix _UC instead of prefix _GL.  */
0070 
0071 /* True if the compiler says it groks GNU C version MAJOR.MINOR.  */
0072 #if defined __GNUC__ && defined __GNUC_MINOR__
0073 # define _UC_GNUC_PREREQ(major, minor) \
0074     ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
0075 #else
0076 # define _UC_GNUC_PREREQ(major, minor) 0
0077 #endif
0078 
0079 #if (defined __has_attribute \
0080      && (!defined __clang_minor__ \
0081          || (defined __apple_build_version__ \
0082              ? 6000000 <= __apple_build_version__ \
0083              : 5 <= __clang_major__)))
0084 # define _UC_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
0085 #else
0086 # define _UC_HAS_ATTRIBUTE(attr) _UC_ATTR_##attr
0087 # define _UC_ATTR_malloc _UC_GNUC_PREREQ (3, 0)
0088 # define _UC_ATTR_unused _UC_GNUC_PREREQ (2, 7)
0089 #endif
0090 
0091 #ifdef __cplusplus
0092 # if defined __clang__
0093 #  define _UC_BRACKET_BEFORE_ATTRIBUTE 1
0094 # endif
0095 #else
0096 # if defined __GNUC__ && !defined __clang__
0097 #  define _UC_BRACKET_BEFORE_ATTRIBUTE 1
0098 # endif
0099 #endif
0100 
0101 #if _UC_GNUC_PREREQ (11, 0)
0102 # define _UC_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
0103 #else
0104 # define _UC_ATTRIBUTE_DEALLOC(f, i)
0105 #endif
0106 #if defined __cplusplus && defined __GNUC__ && !defined __clang__
0107 /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
0108 # define _UC_ATTRIBUTE_DEALLOC_FREE \
0109     _UC_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
0110 #else
0111 # define _UC_ATTRIBUTE_DEALLOC_FREE \
0112     _UC_ATTRIBUTE_DEALLOC (free, 1)
0113 #endif
0114 
0115 #if _UC_HAS_ATTRIBUTE (malloc)
0116 # define _UC_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
0117 #else
0118 # define _UC_ATTRIBUTE_MALLOC
0119 #endif
0120 
0121 #ifndef _UC_BRACKET_BEFORE_ATTRIBUTE
0122 # if defined __clang__ && defined __cplusplus
0123 #  if !defined __apple_build_version__ && __clang_major__ >= 10
0124 #   define _UC_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
0125 #  endif
0126 # elif defined __has_c_attribute
0127 #  if __has_c_attribute (__maybe_unused__)
0128 #   define _UC_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
0129 #  endif
0130 # endif
0131 #endif
0132 #ifndef _UC_ATTRIBUTE_MAYBE_UNUSED
0133 # define _UC_ATTRIBUTE_MAYBE_UNUSED _UC_ATTRIBUTE_UNUSED
0134 #endif
0135 
0136 #if _UC_HAS_ATTRIBUTE (unused)
0137 # define _UC_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
0138 #else
0139 # define _UC_ATTRIBUTE_UNUSED
0140 #endif
0141 
0142 #if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \
0143      && !defined __cplusplus)
0144 # define _UC_UNNAMED(id) unnamed_##id _UC_ATTRIBUTE_UNUSED
0145 #else
0146 # define _UC_UNNAMED(id)
0147 #endif
0148 
0149 #endif /* _UNISTRING_CDEFS_H */