Blame lib/unistring/attribute.h

Packit Service 4684c1
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
Packit Service 4684c1
Packit Service 4684c1
   Copyright 2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or
Packit Service 4684c1
   modify it under the terms of either:
Packit Service 4684c1
Packit Service 4684c1
     * the GNU Lesser General Public License as published by the Free
Packit Service 4684c1
       Software Foundation; either version 3 of the License, or (at your
Packit Service 4684c1
       option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   or
Packit Service 4684c1
Packit Service 4684c1
     * the GNU General Public License as published by the Free
Packit Service 4684c1
       Software Foundation; either version 2 of the License, or (at your
Packit Service 4684c1
       option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   or both in parallel, as here.
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 4684c1
   Lesser General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU Lesser General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Paul Eggert.  */
Packit Service 4684c1
Packit Service 4684c1
/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
Packit Service 4684c1
   macros used within Gnulib.  */
Packit Service 4684c1
Packit Service 4684c1
/* These attributes can be placed in two ways:
Packit Service 4684c1
     - At the start of a declaration (i.e. even before storage-class
Packit Service 4684c1
       specifiers!); then they apply to all entities that are declared
Packit Service 4684c1
       by the declaration.
Packit Service 4684c1
     - Immediately after the name of an entity being declared by the
Packit Service 4684c1
       declaration; then they apply to that entity only.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef _GL_ATTRIBUTE_H
Packit Service 4684c1
#define _GL_ATTRIBUTE_H
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* This file defines two types of attributes:
Packit Service 4684c1
   * C2X standard attributes.  These have macro names that do not begin with
Packit Service 4684c1
     'ATTRIBUTE_'.
Packit Service 4684c1
   * Selected GCC attributes; see:
Packit Service 4684c1
     https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Packit Service 4684c1
     https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
Packit Service 4684c1
     https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
Packit Service 4684c1
     These names begin with 'ATTRIBUTE_' to avoid name clashes.  */
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* =============== Attributes for specific kinds of functions =============== */
Packit Service 4684c1
Packit Service 4684c1
/* Attributes for functions that should not be used.  */
Packit Service 4684c1
Packit Service 4684c1
/* Warn if the entity is used.  */
Packit Service 4684c1
/* Applies to:
Packit Service 4684c1
     - function, variable,
Packit Service 4684c1
     - struct, union, struct/union member,
Packit Service 4684c1
     - enumeration, enumeration item,
Packit Service 4684c1
     - typedef,
Packit Service 4684c1
   in C++ also: namespace, class, template specialization.  */
Packit Service 4684c1
#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
Packit Service 4684c1
Packit Service 4684c1
/* If a function call is not optimized way, warn with MSG.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
Packit Service 4684c1
Packit Service 4684c1
/* If a function call is not optimized way, report an error with MSG.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Attributes for memory-allocating functions.  */
Packit Service 4684c1
Packit Service 4684c1
/* The function returns a pointer to freshly allocated memory.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
Packit Service 4684c1
Packit Service 4684c1
/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
Packit Service 4684c1
   is the size of the returned memory block.
Packit Service 4684c1
   ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
Packit Service 4684c1
   to determine the size of the returned memory block.  */
Packit Service 4684c1
/* Applies to: function, pointer to function, function types.  */
Packit Service 4684c1
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Attributes for variadic functions.  */
Packit Service 4684c1
Packit Service 4684c1
/* The variadic function expects a trailing NULL argument.
Packit Service 4684c1
   ATTRIBUTE_SENTINEL () - The last argument is NULL.
Packit Service 4684c1
   ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* ================== Attributes for compiler diagnostics ================== */
Packit Service 4684c1
Packit Service 4684c1
/* Attributes that help the compiler diagnose programmer mistakes.
Packit Service 4684c1
   Some of them may also help for some compiler optimizations.  */
Packit Service 4684c1
Packit Service 4684c1
/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
Packit Service 4684c1
   The STRING-INDEXth function argument is a format string of style
Packit Service 4684c1
   ARCHETYPE, which is one of:
Packit Service 4684c1
     printf, gnu_printf
Packit Service 4684c1
     scanf, gnu_scanf,
Packit Service 4684c1
     strftime, gnu_strftime,
Packit Service 4684c1
     strfmon,
Packit Service 4684c1
   or the same thing prefixed and suffixed with '__'.
Packit Service 4684c1
   If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
Packit Service 4684c1
   are suitable for the format string.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
Packit Service 4684c1
Packit Service 4684c1
/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
Packit Service 4684c1
   ATTRIBUTE_NONNULL () - All pointer arguments must not be null.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
Packit Service 4684c1
Packit Service 4684c1
/* The function's return value is a non-NULL pointer.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
Packit Service 4684c1
Packit Service 4684c1
/* Warn if the caller does not use the return value,
Packit Service 4684c1
   unless the caller uses something like ignore_value.  */
Packit Service 4684c1
/* Applies to: function, enumeration, class.  */
Packit Service 4684c1
#define NODISCARD _GL_ATTRIBUTE_NODISCARD
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Attributes that disable false alarms when the compiler diagnoses
Packit Service 4684c1
   programmer "mistakes".  */
Packit Service 4684c1
Packit Service 4684c1
/* Do not warn if the entity is not used.  */
Packit Service 4684c1
/* Applies to:
Packit Service 4684c1
     - function, variable,
Packit Service 4684c1
     - struct, union, struct/union member,
Packit Service 4684c1
     - enumeration, enumeration item,
Packit Service 4684c1
     - typedef,
Packit Service 4684c1
   in C++ also: class.  */
Packit Service 4684c1
#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
Packit Service 4684c1
Packit Service 4684c1
/* The contents of a character array is not meant to be NUL-terminated.  */
Packit Service 4684c1
/* Applies to: struct/union members and variables that are arrays of element
Packit Service 4684c1
   type '[[un]signed] char'.  */
Packit Service 4684c1
#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
Packit Service 4684c1
Packit Service 4684c1
/* Do not warn if control flow falls through to the immediately
Packit Service 4684c1
   following 'case' or 'default' label.  */
Packit Service 4684c1
/* Applies to: Empty statement (;), inside a 'switch' statement.  */
Packit Service 4684c1
#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* ================== Attributes for debugging information ================== */
Packit Service 4684c1
Packit Service 4684c1
/* Attributes regarding debugging information emitted by the compiler.  */
Packit Service 4684c1
Packit Service 4684c1
/* Omit the function from stack traces when debugging.  */
Packit Service 4684c1
/* Applies to: function.  */
Packit Service 4684c1
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
Packit Service 4684c1
Packit Service 4684c1
/* Make the entity visible to debuggers etc., even with '-fwhole-program'.  */
Packit Service 4684c1
/* Applies to: functions, variables.  */
Packit Service 4684c1
#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* ========== Attributes that mainly direct compiler optimizations ========== */
Packit Service 4684c1
Packit Service 4684c1
/* The function does not throw exceptions.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
Packit Service 4684c1
Packit Service 4684c1
/* Do not inline the function.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
Packit Service 4684c1
Packit Service 4684c1
/* Always inline the function, and report an error if the compiler
Packit Service 4684c1
   cannot inline.  */
Packit Service 4684c1
/* Applies to: function.  */
Packit Service 4684c1
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
Packit Service 4684c1
Packit Service 4684c1
/* The function does not affect observable state, and always returns a value.
Packit Service 4684c1
   Compilers can omit duplicate calls with the same arguments if
Packit Service 4684c1
   observable state is not changed between calls.  (This attribute is
Packit Service 4684c1
   looser than ATTRIBUTE_CONST.)  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
Packit Service 4684c1
Packit Service 4684c1
/* The function neither depends on nor affects observable state,
Packit Service 4684c1
   and always returns a value.  Compilers can omit duplicate calls with
Packit Service 4684c1
   the same arguments.  (This attribute is stricter than ATTRIBUTE_PURE.)  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
Packit Service 4684c1
Packit Service 4684c1
/* The function is rarely executed.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
Packit Service 4684c1
Packit Service 4684c1
/* If called from some other compilation unit, the function executes
Packit Service 4684c1
   code from that unit only by return or by exception handling,
Packit Service 4684c1
   letting the compiler optimize that unit more aggressively.  */
Packit Service 4684c1
/* Applies to: functions.  */
Packit Service 4684c1
#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
Packit Service 4684c1
Packit Service 4684c1
/* For struct members: The member has the smallest possible alignment.
Packit Service 4684c1
   For struct, union, class: All members have the smallest possible alignment,
Packit Service 4684c1
   minimizing the memory required.  */
Packit Service 4684c1
/* Applies to: struct members, struct, union,
Packit Service 4684c1
   in C++ also: class.  */
Packit Service 4684c1
#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* ================ Attributes that make invalid code valid ================ */
Packit Service 4684c1
Packit Service 4684c1
/* Attributes that prevent fatal compiler optimizations for code that is not
Packit Service 4684c1
   fully ISO C compliant.  */
Packit Service 4684c1
Packit Service 4684c1
/* Pointers to the type may point to the same storage as pointers to
Packit Service 4684c1
   other types, thus disabling strict aliasing optimization.  */
Packit Service 4684c1
/* Applies to: types.  */
Packit Service 4684c1
#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
#endif /* _GL_ATTRIBUTE_H */