Skip to content
Snippets Groups Projects
macros.h 637 B
Newer Older
/*
 * SPDX-FileCopyrightText: 2020 Bruce Cowan <bruce@bcowan.me.uk>
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#pragma once

#include "config.h"

#ifdef HAVE_ATTR_ALLOC_SIZE
  #define ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
  #define ATTR_ALLOC_SIZE2(x,y) __attribute__((alloc_size(x,y)))
#else
  #define ATTR_ALLOC_SIZE(x)
  #define ATTR_ALLOC_SIZE2(x,y)
#endif

#ifdef HAVE_ATTR_MALLOC
  #define ATTR_MALLOC __attribute__((malloc))
#else
  #define ATTR_MALLOC
#endif

#ifdef HAVE_ATTR_WARN_UNUSED_RESULT
  #define ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
  #define ATTR_WARN_UNUSED_RESULT
#endif