// If DEFINE_FUNC_ATTRIBUTES macro is not defined then all function attributes // are defined as empty values. // // If DO_NOT_DEFINE_EMPTY_ATTRIBUTES then empty macros are not defined. Thus // undefined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES // leaves file with untouched FUNC_ATTR_* macros. This variant is used for // scripts/gendeclarations.lua. // // Empty macros are used for *.c files. (undefined DEFINE_FUNC_ATTRIBUTES and // undefined DO_NOT_DEFINE_EMPTY_ATTRIBUTES) // // Macros defined as __attribute__((*)) are used by generated header files. // (defined DEFINE_FUNC_ATTRIBUTES and undefined // DO_NOT_DEFINE_EMPTY_ATTRIBUTES) // // Defined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES is // not used by anything. // FUNC_ATTR_* macros should be in *.c files for declarations generator. If you // define a function for which declaration is not generated by // gendeclarations.lua (e.g. template hash implementation) then you should use // REAL_FATTR_* macros. // gcc and clang expose their version as follows: // // gcc 4.7.2: // __GNUC__ = 4 // __GNUC_MINOR__ = 7 // __GNUC_PATCHLEVEL = 2 // // clang 3.4 (claims compat with gcc 4.2.1): // __GNUC__ = 4 // __GNUC_MINOR__ = 2 // __GNUC_PATCHLEVEL = 1 // __clang__ = 1 // __clang_major__ = 3 // __clang_minor__ = 4 // // To view the default defines of these compilers, you can perform: // // $ gcc -E -dM - = 40900 # define REAL_FATTR_NONNULL_RET __attribute__((returns_nonnull)) # endif # endif # endif // define function attributes that haven't been defined for this specific // compiler. # ifndef REAL_FATTR_MALLOC # define REAL_FATTR_MALLOC # endif # ifndef REAL_FATTR_ALLOC_SIZE # define REAL_FATTR_ALLOC_SIZE(x) # endif # ifndef REAL_FATTR_ALLOC_SIZE_PROD # define REAL_FATTR_ALLOC_SIZE_PROD(x, y) # endif # ifndef REAL_FATTR_ALLOC_ALIGN # define REAL_FATTR_ALLOC_ALIGN(x) # endif # ifndef REAL_FATTR_PURE # define REAL_FATTR_PURE # endif # ifndef REAL_FATTR_CONST # define REAL_FATTR_CONST # endif # ifndef REAL_FATTR_WARN_UNUSED_RESULT # define REAL_FATTR_WARN_UNUSED_RESULT # endif # ifndef REAL_FATTR_ALWAYS_INLINE # define REAL_FATTR_ALWAYS_INLINE # endif # ifndef REAL_FATTR_UNUSED # define REAL_FATTR_UNUSED # endif # ifndef REAL_FATTR_NONNULL_ALL # define REAL_FATTR_NONNULL_ALL # endif # ifndef REAL_FATTR_NONNULL_ARG # define REAL_FATTR_NONNULL_ARG(...) # endif # ifndef REAL_FATTR_NONNULL_RET # define REAL_FATTR_NONNULL_RET # endif #endif #ifdef DEFINE_FUNC_ATTRIBUTES # define FUNC_API_ASYNC # define FUNC_API_NOEXPORT # define FUNC_API_NOEVAL # define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) REAL_FATTR_ALLOC_SIZE_PROD(x, y) # define FUNC_ATTR_ALLOC_ALIGN(x) REAL_FATTR_ALLOC_ALIGN(x) # define FUNC_ATTR_PURE REAL_FATTR_PURE # define FUNC_ATTR_CONST REAL_FATTR_CONST # define FUNC_ATTR_WARN_UNUSED_RESULT REAL_FATTR_WARN_UNUSED_RESULT # define FUNC_ATTR_ALWAYS_INLINE REAL_FATTR_ALWAYS_INLINE # define FUNC_ATTR_UNUSED REAL_FATTR_UNUSED # define FUNC_ATTR_NONNULL_ALL REAL_FATTR_NONNULL_ALL # define FUNC_ATTR_NONNULL_ARG(...) REAL_FATTR_NONNULL_ARG(__VA_ARGS__) # define FUNC_ATTR_NONNULL_RET REAL_FATTR_NONNULL_RET #elif !defined(DO_NOT_DEFINE_EMPTY_ATTRIBUTES) # define FUNC_ATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) # define FUNC_ATTR_ALLOC_ALIGN(x) # define FUNC_ATTR_PURE # define FUNC_ATTR_CONST # define FUNC_ATTR_WARN_UNUSED_RESULT # define FUNC_ATTR_ALWAYS_INLINE # define FUNC_ATTR_UNUSED # define FUNC_ATTR_NONNULL_ALL # define FUNC_ATTR_NONNULL_ARG(...) # define FUNC_ATTR_NONNULL_RET #endif #endif // NVIM_FUNC_ATTR_H