<commit_before>/* -*- coding: utf-8 -*-
 * ----------------------------------------------------------------------
 * Copyright © 2011, RedJack, LLC.
 * All rights reserved.
 *
 * Please see the LICENSE.txt file in this distribution for license
 * details.
 * ----------------------------------------------------------------------
 */

#ifndef LIBCORK_CORE_ATTRIBUTES_H
#define LIBCORK_CORE_ATTRIBUTES_H

/**
 * @file
 * @brief Implementation of the @ref compiler_attrs submodule
 */

#include <libcork/config.h>

/**
 * @addtogroup compiler_attrs
 *
 * <tt>#%include \<libcork/core/attributes.h\></tt>
 *
 * The macros in this section define compiler-agnostic versions of
 * several compiler attributes.
 *
 * @{
 */


/**
 * @brief Declare a “const” function.
 *
 * A const function is one whose return value depends only on its
 * parameters.  This is slightly more strict than a “pure” function; a
 * const function is not allowed to read from global variables, whereas
 * a pure function is.
 *
 * @code
 * int square(int x) CORK_ATTR_CONST;
 * @endcode
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_CONST
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_CONST  __attribute__((const))
#else
#define CORK_ATTR_CONST
#endif


/**
 * @brief Declare a “pure” function.
 *
 * A pure function is one whose return value depends only on its
 * parameters, and global variables.
 *
 * @code
 * int square(int x) CORK_ATTR_PURE;
 * @endcode
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_PURE
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_PURE  __attribute__((pure))
#else
#define CORK_ATTR_PURE
#endif


/**
 * @brief Declare that a function returns a newly allocated pointer.
 *
 * The compiler can use this information to generate more accurate
 * aliasing information, since it can infer that the result of the
 * function cannot alias any other existing pointer.
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_MALLOC
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_MALLOC  __attribute__((malloc))
#else
#define CORK_ATTR_MALLOC
#endif


/**
 * @brief Declare an entity that isn't used.
 *
 * This lets you keep <tt>-Wall</tt> activated in several cases where
 * you're obligated to define something that you don't intend to use.
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_UNUSED
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_UNUSED  __attribute__((unused))
#else
#define CORK_ATTR_UNUSED
#endif


/**
 * @brief Declare a function that takes in <tt>printf</tt>-like
 * parameters.
 *
 * When the compiler supports this attribute, it will check the format
 * string, and the following arguments, to make sure that they match.
 *
 * @param [in] format_index  The index of the parameter which is the
 * format string
 * @param [in] args_index  The index of the first parameter which
 * contains the data to format
 *
 * @since 0.2
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_PRINTF(format_index, args_index)
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_PRINTF(format_index, args_index) \
    __attribute__((format(printf, format_index, args_index)))
#else
#define CORK_ATTR_PRINTF(format_index, args_index)
#endif


/* end of compiler_attrs group */
/**
 * @}
 */

#endif /* LIBCORK_CORE_ATTRIBUTES_H */<commit_msg>CORK_ATTR_SENTINEL attribute macro<commit_after>/* -*- coding: utf-8 -*-
 * ----------------------------------------------------------------------
 * Copyright © 2011, RedJack, LLC.
 * All rights reserved.
 *
 * Please see the LICENSE.txt file in this distribution for license
 * details.
 * ----------------------------------------------------------------------
 */

#ifndef LIBCORK_CORE_ATTRIBUTES_H
#define LIBCORK_CORE_ATTRIBUTES_H

/**
 * @file
 * @brief Implementation of the @ref compiler_attrs submodule
 */

#include <libcork/config.h>

/**
 * @addtogroup compiler_attrs
 *
 * <tt>#%include \<libcork/core/attributes.h\></tt>
 *
 * The macros in this section define compiler-agnostic versions of
 * several compiler attributes.
 *
 * @{
 */


/**
 * @brief Declare a “const” function.
 *
 * A const function is one whose return value depends only on its
 * parameters.  This is slightly more strict than a “pure” function; a
 * const function is not allowed to read from global variables, whereas
 * a pure function is.
 *
 * @code
 * int square(int x) CORK_ATTR_CONST;
 * @endcode
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_CONST
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_CONST  __attribute__((const))
#else
#define CORK_ATTR_CONST
#endif


/**
 * @brief Declare a “pure” function.
 *
 * A pure function is one whose return value depends only on its
 * parameters, and global variables.
 *
 * @code
 * int square(int x) CORK_ATTR_PURE;
 * @endcode
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_PURE
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_PURE  __attribute__((pure))
#else
#define CORK_ATTR_PURE
#endif


/**
 * @brief Declare that a function returns a newly allocated pointer.
 *
 * The compiler can use this information to generate more accurate
 * aliasing information, since it can infer that the result of the
 * function cannot alias any other existing pointer.
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_MALLOC
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_MALLOC  __attribute__((malloc))
#else
#define CORK_ATTR_MALLOC
#endif


/**
 * @brief Declare an entity that isn't used.
 *
 * This lets you keep <tt>-Wall</tt> activated in several cases where
 * you're obligated to define something that you don't intend to use.
 *
 * @since 0.1
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_UNUSED
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_UNUSED  __attribute__((unused))
#else
#define CORK_ATTR_UNUSED
#endif


/**
 * @brief Declare a function that takes in <tt>printf</tt>-like
 * parameters.
 *
 * When the compiler supports this attribute, it will check the format
 * string, and the following arguments, to make sure that they match.
 *
 * @param [in] format_index  The index of the parameter which is the
 * format string
 * @param [in] args_index  The index of the first parameter which
 * contains the data to format
 *
 * @since 0.2
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_PRINTF(format_index, args_index)
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_PRINTF(format_index, args_index) \
    __attribute__((format(printf, format_index, args_index)))
#else
#define CORK_ATTR_PRINTF(format_index, args_index)
#endif


/**
 * @brief Declare a var-arg function whose last parameter must be a @c
 * NULL sentinel value.
 *
 * When the compiler supports this attribute, it will check the actual
 * parameters whenever this function is called, and ensure that the
 * last parameter is a @c NULL.
 *
 * @since 0.2-dev
 */

#if defined(CORK_DOCUMENTATION)
#define CORK_ATTR_SENTINEL
#elif CORK_CONFIG_HAVE_GCC_ATTRIBUTES
#define CORK_ATTR_SENTINEL  __attribute__((sentinel))
#else
#define CORK_ATTR_SENTINEL
#endif


/* end of compiler_attrs group */
/**
 * @}
 */

#endif /* LIBCORK_CORE_ATTRIBUTES_H */
{'fraction_non_alphanumeric': 0.130770290753755, 'fraction_numerical': 0.004409535620779937, 'mean_word_length': 3.6229299363057326, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2249290', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2273, 'n_words': 739}