- Fix and extend the attribute checking macros for the
most common attributes. Useful attributes may be: - optimization (pure, const, malloc--restrictness) - data layout (packed) - interface definition, API (deprecated, visibility, weak alias) - compiler hint for code analysis and debugging (nonnull, format) This commit was SVN r13369.
Этот коммит содержится в:
родитель
2f3eefee01
Коммит
2bda2f5d8c
@ -61,6 +61,7 @@ m4_include(config/ompi_check_broken_qsort.m4)
|
||||
m4_include(config/ompi_check_compiler_works.m4)
|
||||
m4_include(config/ompi_check_func_lib.m4)
|
||||
m4_include(config/ompi_check_optflags.m4)
|
||||
m4_include(config/ompi_check_attributes.m4)
|
||||
m4_include(config/ompi_check_icc.m4)
|
||||
m4_include(config/ompi_check_gm.m4)
|
||||
m4_include(config/ompi_check_mx.m4)
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
# of Tennessee Research Foundation. All rights
|
||||
# reserved.
|
||||
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
# Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
@ -22,8 +22,12 @@ AC_DEFUN([OMPI_CHECK____ATTRIBUTE__], [
|
||||
AC_CACHE_VAL(ac_cv___attribute__, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
static void foo(void) __attribute__ ((unused));
|
||||
static void foo(void) { exit(1); }],
|
||||
/* Check for the longest available __attribute__ (since gcc-2.3) */
|
||||
struct foo {
|
||||
char a;
|
||||
int x[2] __attribute__ ((packed));
|
||||
};
|
||||
],
|
||||
[],
|
||||
[ac_cv___attribute__=1 ac_cv___attribute__msg=yes],
|
||||
[ac_cv___attribute__=0 ac_cv___attribute__msg=no],
|
||||
@ -37,80 +41,234 @@ AC_DEFUN([OMPI_CHECK____ATTRIBUTE__], [
|
||||
# attributed are supported.
|
||||
#
|
||||
if test "$ac_cv___attribute__msg" = "no"; then
|
||||
ac_cv___attribute__alias=0
|
||||
ac_cv___attribute__aligned=0
|
||||
ac_cv___attribute__const=0
|
||||
ac_cv___attribute__deprecated=0
|
||||
ac_cv___attribute__format=0
|
||||
ac_cv___attribute__malloc=0
|
||||
ac_cv___attribute__nonnull=0
|
||||
ac_cv___attribute__noreturn=0
|
||||
ac_cv___attribute__pure=0
|
||||
ac_cv___attribute__packed=0
|
||||
ac_cv___attribute__unused=0
|
||||
ac_cv___attribute__visibility=0
|
||||
ac_cv___attribute__warn_unused_result=0
|
||||
ac_cv___attribute__weak_alias=0
|
||||
else
|
||||
AC_MSG_CHECKING("for __attribute__ ((alias))" )
|
||||
AC_CACHE_VAL(ac_cv___attribute__alias, [
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((aligned))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__aligned, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg) { return arg + 3; }
|
||||
int foo2(int) __attribute__ ((weak, alias ("foo")));],
|
||||
struct foo { char text[4] } __attribute__ ((aligned(8))); ],
|
||||
[],
|
||||
[ac_cv___attribute__alias=1 ac_cv___attribute__alias_msg=yes],
|
||||
[ac_cv___attribute__alias=0 ac_cv___attribute__alias_msg=no]
|
||||
[ac_cv___attribute__aligned=1 ac_cv___attribute__aligned_msg=yes],
|
||||
[ac_cv___attribute__aligned=0 ac_cv___attribute__aligned_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__alias_msg)
|
||||
AC_MSG_RESULT($ac_cv___attribute__aligned_msg)
|
||||
|
||||
AC_MSG_CHECKING("for __attribute__ ((const))" )
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((const))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__const, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg1, int arg2) __attribute__ ((const)) { return arg1 * arg2 + arg1; }],
|
||||
int foo(int arg1, int arg2) __attribute__ ((const));
|
||||
int foo(int arg1, int arg2) { return arg1 * arg2 + arg1; }],
|
||||
[],
|
||||
[ac_cv___attribute__const=1 ac_cv___attribute__const_msg=yes],
|
||||
[ac_cv___attribute__const=0 ac_cv___attribute__const_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__const_msg)
|
||||
|
||||
AC_MSG_CHECKING("for __attribute__ ((malloc))" )
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((deprecated))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__deprecated, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg1, int arg2) __attribute__ ((deprecated));
|
||||
int foo(int arg1, int arg2) { return arg1 * arg2 + arg1; }],
|
||||
[],
|
||||
[ac_cv___attribute__deprecated=1 ac_cv___attribute__deprecated_msg=yes],
|
||||
[ac_cv___attribute__deprecated=0 ac_cv___attribute__deprecated_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__deprecated_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((format))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__format, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int this_printf (void *my_object, const char *my_format, ...) __attribute__ ((format (printf, 2, 3)));],
|
||||
[],
|
||||
[ac_cv___attribute__format=1 ac_cv___attribute__format_msg=yes],
|
||||
[ac_cv___attribute__format=0 ac_cv___attribute__format_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__format_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((malloc))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__malloc, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg1) __attribute__ ((malloc)) { return malloc(arg1); }],
|
||||
int * foo(int arg1) __attribute__ ((malloc));
|
||||
int * foo(int arg1) { return malloc(arg1); }],
|
||||
[],
|
||||
[ac_cv___attribute__malloc=1 ac_cv___attribute__malloc_msg=yes],
|
||||
[ac_cv___attribute__malloc=0 ac_cv___attribute__malloc_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__malloc_msg)
|
||||
|
||||
AC_MSG_CHECKING("for __attribute__ ((noreturn))" )
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((may_alias))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__may_alias, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int * arg __attribute__ ((may_alias));],
|
||||
[],
|
||||
[ac_cv___attribute__may_alias=1 ac_cv___attribute__may_alias_msg=yes],
|
||||
[ac_cv___attribute__may_alias=0 ac_cv___attribute__may_alias_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__may_alias_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((nonnull))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__nonnull, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int square(int *arg) __attribute__ ((nonnull));
|
||||
int square(int *arg) { return *arg; }],
|
||||
[
|
||||
int value=1;
|
||||
value = square (&value);
|
||||
],
|
||||
[ac_cv___attribute__nonnull=1 ac_cv___attribute__nonnull_msg=yes],
|
||||
[ac_cv___attribute__nonnull=0 ac_cv___attribute__nonnull_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__nonnull_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((noreturn))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__noreturn, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int fatal(int arg1) __attribute__ ((noreturn)) { exit(arg1); }],
|
||||
int fatal(int arg1) __attribute__ ((noreturn));
|
||||
int fatal(int arg1) { exit(arg1); }],
|
||||
[],
|
||||
[ac_cv___attribute__noreturn=1 ac_cv___attribute__noreturn_msg=yes],
|
||||
[ac_cv___attribute__noreturn=0 ac_cv___attribute__noreturn_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__noreturn_msg)
|
||||
|
||||
AC_MSG_CHECKING("for __attribute__ ((pure))" )
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((packed))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__packed, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
struct foo {
|
||||
char a;
|
||||
int x[2] __attribute__ ((packed));
|
||||
};],
|
||||
[],
|
||||
[ac_cv___attribute__packed=1 ac_cv___attribute__packed_msg=yes],
|
||||
[ac_cv___attribute__packed=0 ac_cv___attribute__packed_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__packed_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((pure))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__pure, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int square(int arg) __attribute__ ((pure)) { return arg * arg; }],
|
||||
int square(int arg) __attribute__ ((pure));
|
||||
int square(int arg) { return arg * arg; }],
|
||||
[],
|
||||
[ac_cv___attribute__pure=1 ac_cv___attribute__pure_msg=yes],
|
||||
[ac_cv___attribute__pure=0 ac_cv___attribute__pure_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__pure_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((unused))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__unused, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int square(int arg1 __attribute__ ((unused)), int arg2);
|
||||
int square(int arg1, int arg2) { return arg2; }],
|
||||
[],
|
||||
[ac_cv___attribute__unused=1 ac_cv___attribute__unused_msg=yes],
|
||||
[ac_cv___attribute__unused=0 ac_cv___attribute__unused_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__unused_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((visibility))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__visibility, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int square(int arg1) __attribute__ ((visibility("hidden")));],
|
||||
[],
|
||||
[ac_cv___attribute__visibility=1 ac_cv___attribute__visibility_msg=yes],
|
||||
[ac_cv___attribute__visibility=0 ac_cv___attribute__visibility_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__visibility_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((warn_unused_result))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__warn_unused_result, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg) __attribute__ ((warn_unused_result));
|
||||
int foo(int arg) { return arg + 3; }
|
||||
int foo2(int arg) { return foo (arg); } ],
|
||||
[],
|
||||
[ac_cv___attribute__warn_unused_result=1 ac_cv___attribute__warn_unused_result_msg=yes],
|
||||
[ac_cv___attribute__warn_unused_result=0 ac_cv___attribute__warn_unused_result_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__warn_unused_result_msg)
|
||||
|
||||
|
||||
AC_MSG_CHECKING([for __attribute__ ((weak, alias..))])
|
||||
AC_CACHE_VAL(ac_cv___attribute__weak_alias, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
int foo(int arg) { return arg + 3; }
|
||||
int foo2(int) __attribute__ ((weak, alias("foo")));],
|
||||
[],
|
||||
[ac_cv___attribute__weak_alias=1 ac_cv___attribute__weak_alias_msg=yes],
|
||||
[ac_cv___attribute__weak_alias=0 ac_cv___attribute__weak_alias_msg=no]
|
||||
)])
|
||||
AC_MSG_RESULT($ac_cv___attribute__weak_alias_msg)
|
||||
|
||||
fi
|
||||
|
||||
# Now that all the values are set, define them
|
||||
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_WEAK_ALIAS, [$ac_cv___attribute__alias],
|
||||
[Whether your compiler has __attribute__ alias weak or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_ALIGNED, [$ac_cv___attribute__aligned],
|
||||
[Whether your compiler has __attribute__ aligned or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_CONST, [$ac_cv___attribute__const],
|
||||
[Whether your compiler has __attribute__ const or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_DEPRECATED, [$ac_cv___attribute__deprecated],
|
||||
[Whether your compiler has __attribute__ deprecated or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_FORMAT, [$ac_cv___attribute__format],
|
||||
[Whether your compiler has __attribute__ format or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_MALLOC, [$ac_cv___attribute__malloc],
|
||||
[Whether your compiler has __attribute__ malloc or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_MAY_ALIAS, [$ac_cv___attribute__may_alias],
|
||||
[Whether your compiler has __attribute__ may_alias or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_NONNULL, [$ac_cv___attribute__nonnull],
|
||||
[Whether your compiler has __attribute__ nonnull or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_NORETURN, [$ac_cv___attribute__noreturn],
|
||||
[Whether your compiler has __attribute__ noreturn or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_PACKED, [$ac_cv___attribute__packed],
|
||||
[Whether your compiler has __attribute__ packed or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_PURE, [$ac_cv___attribute__pure],
|
||||
[Whether your compiler has __attribute__ pure or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_UNUSED, [$ac_cv___attribute__unused],
|
||||
[Whether your compiler has __attribute__ unused or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_VISIBILITY, [$ac_cv___attribute__visibility],
|
||||
[Whether your compiler has __attribute__ visibility or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_WARN_UNUSED_RESULT, [$ac_cv___attribute__warn_unused_result],
|
||||
[Whether your compiler has __attribute__ warn unused result or not])
|
||||
AC_DEFINE_UNQUOTED(OMPI_HAVE_ATTRIBUTE_WEAK_ALIAS, [$ac_cv___attribute__weak_alias],
|
||||
[Whether your compiler has __attribute__ weak alias or not])
|
||||
])
|
||||
|
@ -283,6 +283,11 @@ AC_DEFUN([OMPI_SETUP_CC],[
|
||||
unset co_found co_word
|
||||
|
||||
AC_SUBST([CFLAGS_WITHOUT_OPTFLAGS])
|
||||
|
||||
#
|
||||
# Finally get the supported attributes of the selected compiler
|
||||
#
|
||||
OMPI_CHECK____ATTRIBUTE__
|
||||
])
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@ -356,4 +356,81 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
|
||||
#define OPAL_WANT_IPV6 0
|
||||
#endif
|
||||
|
||||
#if OMPI_HAVE_ATTRIBUTE
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_ALIGNED
|
||||
# define __opal_attribute_aligned__(a) __attribute__((__aligned__(a)))
|
||||
# define __opal_attribute_aligned_max__ __attribute__((__aligned__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_CONST
|
||||
# define __opal_attribute_const__ __attribute__((__const__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_DEPRECATED
|
||||
# define __opal_attribute_deprecated__ __attribute__((__deprecated__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_FORMAT
|
||||
# define __opal_attribute_format__(a,b,c) __attribute__((__format__(a, b, c)))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_MALLOC
|
||||
# define __opal_attribute_malloc__ __attribute__((__malloc__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_MAY_ALIAS
|
||||
# define __opal_attribute_may_alias__ __attribute__((__may_alias__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_NONNULL
|
||||
# define __opal_attribute_nonnull__ __attribute__((__nonnull__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_NORETURN
|
||||
# define __opal_attribute_noreturn__ __attribute__((__noreturn__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_PACKED
|
||||
# define __opal_attribute_packed__ __attribute__((__packed__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_PURE
|
||||
# define __opal_attribute_pure__ __attribute__((__pure__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_UNUSED
|
||||
# define __opal_attribute_unused__ __attribute__((__unused__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_VISIBILITY
|
||||
# define __opal_attribute_visibility__(a) __attribute__((__visibility__(a)))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
# define __opal_attribute_warn_unused_result__ __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
|
||||
# if OMPI_HAVE_ATTRIBUTE_WEAK_ALIAS
|
||||
# define __opal_attribute_weak_alias__(a) __attribute__((__weak__, __alias__(a)))
|
||||
# endif
|
||||
|
||||
#else
|
||||
#define __opal_attribute_aligned__(a)
|
||||
#define __opal_attribute_aligned_max__
|
||||
#define __opal_attribute_const__
|
||||
#define __opal_attribute_deprecated__
|
||||
#define __opal_attribute_format__(a,b,c)
|
||||
#define __opal_attribute_malloc__
|
||||
#define __opal_attribute_may_alias__
|
||||
#define __opal_attribute_nonnull__
|
||||
#define __opal_attribute_noreturn__
|
||||
#define __opal_attribute_packed__
|
||||
#define __opal_attribute_pure__
|
||||
#define __opal_attribute_unused__
|
||||
#define __opal_attribute_visibility__(a)
|
||||
#define __opal_attribute_warn_unused_result__
|
||||
#define __opal_attribute_weak_alias__(a)
|
||||
#endif
|
||||
|
||||
#endif /* OMPI_BUILDING */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user