Added BOOST_NO_CXX11_ALIGNAS, BOOST_ALIGNMENT and BOOST_NO_ALIGNMENT macros.

[SVN r84794]
This commit is contained in:
Andrey Semashev
2013-06-15 13:48:07 +00:00
parent c4960dfdb8
commit 1c3d02c469
24 changed files with 331 additions and 153 deletions

View File

@ -576,6 +576,7 @@ that are not yet supported by a particular compiler or library.
[table
[[Macro ][Description ]]
[[`BOOST_NO_CXX11_ALIGNAS`][The compiler does not support the `alignas` keyword.]]
[[`BOOST_NO_CXX11_ALLOCATOR`][The standard library does not provide a C++11 version of `std::allocator` in <memory>.]]
[[`BOOST_NO_CXX11_ATOMIC_SP`][The standard library <memory> does not support atomic smart pointer operations.]]
[[`BOOST_NO_CXX11_HDR_ARRAY`][The standard library does not provide header <array>.]]
@ -697,6 +698,21 @@ provide compliant C++11 support.
[table
[[Macro ][ Description ]]
[[`BOOST_ALIGNMENT(X)`, `BOOST_NO_ALIGNMENT`][
Some compilers don't support the `alignas` keyword but provide other means to specify alignment
(usually, through compiler-specific attributes). The macro `BOOST_ALIGNMENT(X)` will expand to the `alignas(X)`
keyword if the compiler supports it or to some compiler-specific attribute to achieve the specified alignment.
If no such compiler-specific attribute is known then `BOOST_ALIGNMENT(X)` will expand to nothing and
`BOOST_NO_ALIGNMENT` will be defined. Unlike native `alignas`, `X` must always be a compile-time integer constant.
The macro can be used to specify alignment of types and data:
``
struct BOOST_ALIGNMENT(16) my_data
{
char c[16];
};
BOOST_ALIGNMENT(8) int arr[32];
``
]]
[[`BOOST_CONSTEXPR`][
Some compilers don't support the use of `constexpr`. This macro expands to nothing on those compilers, and `constexpr`
elsewhere. For example, when defining a constexpr function or constructor replace:

View File

@ -191,6 +191,7 @@
#define BOOST_NO_CXX11_NOEXCEPT
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
#if __BORLANDC__ >= 0x590
# define BOOST_HAS_TR1_HASH

View File

@ -154,6 +154,10 @@
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#endif
#if !(__has_feature(cxx_alignas) || __has_extension(cxx_alignas))
# define BOOST_NO_CXX11_ALIGNAS
#endif
// Clang always supports variadic macros
// Clang always supports extern templates

View File

@ -111,6 +111,7 @@
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
//
// TR1 macros:

View File

@ -96,6 +96,7 @@
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
#ifdef c_plusplus
// EDG has "long long" in non-strict mode

View File

@ -55,6 +55,7 @@
#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION
#define BOOST_NO_CXX11_CHAR32_T
#define BOOST_NO_CXX11_CHAR16_T
#define BOOST_NO_CXX11_ALIGNAS
//#define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG
#define BOOST_MATH_DISABLE_STD_FPCLASSIFY
//#define BOOST_HAS_FPCLASSIFY

View File

@ -87,6 +87,7 @@
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
#if (__DMC__ < 0x812)
#define BOOST_NO_CXX11_VARIADIC_MACROS

View File

@ -247,6 +247,12 @@
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#endif
// C++0x features in 4.8.n and later
//
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_NO_CXX11_ALIGNAS
#endif
// C++0x features in 4.8.1 and later
//
#if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40801) || !defined(__GXX_EXPERIMENTAL_CXX0X__)

View File

@ -55,6 +55,7 @@
# define BOOST_NO_CXX11_NOEXCEPT
# define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS
# define BOOST_NO_CXX11_ALIGNAS
#define BOOST_COMPILER "GCC-XML C++ version " __GCCXML__

View File

@ -119,6 +119,7 @@
#define BOOST_NO_CXX11_UNICODE_LITERALS
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
/*
See https://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1443331 and

View File

@ -120,6 +120,7 @@
#define BOOST_NO_CXX11_VARIADIC_MACROS
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
#define BOOST_COMPILER "Metrowerks CodeWarrior C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION)

View File

@ -69,6 +69,7 @@
#define BOOST_NO_CXX11_VARIADIC_MACROS
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
//
// versions check:

View File

@ -77,5 +77,6 @@
# define BOOST_NO_CXX11_HDR_CODECVT
# define BOOST_NO_CXX11_HDR_CHRONO
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS
# define BOOST_NO_CXX11_ALIGNAS
#endif

View File

@ -112,6 +112,7 @@
#define BOOST_NO_CXX11_HDR_CHRONO
#define BOOST_NO_CXX11_HDR_ARRAY
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
//
// version check:

View File

@ -128,6 +128,7 @@
#define BOOST_NO_CXX11_VARIADIC_MACROS
#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
//
// Version

View File

@ -126,6 +126,7 @@
#if ! __C99_MACRO_WITH_VA_ARGS
# define BOOST_NO_CXX11_VARIADIC_MACROS
#endif
#define BOOST_NO_CXX11_ALIGNAS

View File

@ -242,6 +242,7 @@
#define BOOST_NO_SFINAE_EXPR
#define BOOST_NO_TWO_PHASE_NAME_LOOKUP
#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
#define BOOST_NO_CXX11_ALIGNAS
//
// prefix and suffix headers:

View File

@ -676,6 +676,20 @@ namespace std{ using ::type_info; }
# define BOOST_UNLIKELY(x) x
#endif
// Type and data alignment specification
//
#if !defined(BOOST_NO_CXX11_ALIGNAS)
# define BOOST_ALIGNMENT(x) alignas(x)
#elif defined(_MSC_VER)
# define BOOST_ALIGNMENT(x) __declspec(align(x))
#elif defined(__GNUC__)
# define BOOST_ALIGNMENT(x) __attribute__ ((__aligned__(x)))
#else
# define BOOST_NO_ALIGNMENT
# define BOOST_ALIGNMENT(x)
#endif
//
// Set BOOST_NO_DECLTYPE_N3276 when BOOST_NO_DECLTYPE is defined
//

View File

@ -226,6 +226,12 @@ test-suite "BOOST_NO_CWCHAR" :
test-suite "BOOST_NO_CWCTYPE" :
[ run ../no_cwctype_pass.cpp ]
[ compile-fail ../no_cwctype_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_RAW_LITERALS" :
[ run ../no_raw_literals_pass.cpp ]
[ compile-fail ../no_raw_literals_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_ALIGNAS" :
[ run ../no_cxx11_alignas_pass.cpp ]
[ compile-fail ../no_cxx11_alignas_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_ALLOCATOR" :
[ run ../no_cxx11_allocator_pass.cpp ]
[ compile-fail ../no_cxx11_allocator_fail.cpp ] ;
@ -424,9 +430,6 @@ test-suite "BOOST_NO_POINTER_TO_MEMBER_CONST" :
test-suite "BOOST_NO_CXX11_RANGE_BASED_FOR" :
[ run ../no_range_based_for_pass.cpp ]
[ compile-fail ../no_range_based_for_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_RAW_LITERALS" :
[ run ../no_raw_literals_pass.cpp ]
[ compile-fail ../no_raw_literals_fail.cpp ] ;
test-suite "BOOST_NO_UNREACHABLE_RETURN_DETECTION" :
[ run ../no_ret_det_pass.cpp ]
[ compile-fail ../no_ret_det_fail.cpp ] ;

View File

@ -0,0 +1,36 @@
// (C) Copyright Andrey Semashev 2013
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for more information.
// MACRO: BOOST_NO_CXX11_ALIGNAS
// TITLE: C++11 alignas keyword.
// DESCRIPTION: The compiler does not support the C++11 alignment specification with alignas keyword.
namespace boost_no_cxx11_alignas {
struct alignas(16) my_data1
{
char data[10];
};
struct alignas(double) my_data2
{
char data[16];
};
my_data1 dummy1[2];
my_data2 dummy2;
alignas(16) char dummy3[10];
alignas(double) char dummy4[32];
int test()
{
// TODO: Test that the data is actually aligned on platforms with uintptr_t
return 0;
}
}

View File

@ -992,6 +992,7 @@ void print_boost_macros()
PRINT_MACRO(BOOST_NO_CV_VOID_SPECIALIZATIONS);
PRINT_MACRO(BOOST_NO_CWCHAR);
PRINT_MACRO(BOOST_NO_CWCTYPE);
PRINT_MACRO(BOOST_NO_CXX11_ALIGNAS);
PRINT_MACRO(BOOST_NO_CXX11_ALLOCATOR);
PRINT_MACRO(BOOST_NO_CXX11_ATOMIC_SMART_PTR);
PRINT_MACRO(BOOST_NO_CXX11_AUTO_DECLARATIONS);

View File

@ -102,6 +102,11 @@ namespace boost_no_cwchar = empty_boost;
#else
namespace boost_no_cwctype = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_ALIGNAS
#include "boost_no_cxx11_alignas.ipp"
#else
namespace boost_no_cxx11_alignas = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_ALLOCATOR
#include "boost_no_cxx11_allocator.ipp"
#else
@ -1231,6 +1236,11 @@ int main( int, char *[] )
std::cerr << "Failed test for BOOST_NO_CWCTYPE at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_alignas::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_ALIGNAS at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_allocator::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_ALLOCATOR at: " << __FILE__ << ":" << __LINE__ << std::endl;

View File

@ -0,0 +1,37 @@
// This file was automatically generated on Sun Apr 28 18:36:48 2013
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for the most recent version.//
// Revision $Id$
//
// Test file for macro BOOST_NO_CXX11_ALIGNAS
// This file should not compile, if it does then
// BOOST_NO_CXX11_ALIGNAS should not be defined.
// See file boost_no_cxx11_alignas.ipp for details
// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif
#include <boost/config.hpp>
#include "test.hpp"
#ifdef BOOST_NO_CXX11_ALIGNAS
#include "boost_no_cxx11_alignas.ipp"
#else
#error "this file should not compile"
#endif
int main( int, char *[] )
{
return boost_no_cxx11_alignas::test();
}

View File

@ -0,0 +1,37 @@
// This file was automatically generated on Sun Apr 28 18:36:48 2013
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for the most recent version.//
// Revision $Id$
//
// Test file for macro BOOST_NO_CXX11_ALIGNAS
// This file should compile, if it does not then
// BOOST_NO_CXX11_ALIGNAS should be defined.
// See file boost_no_cxx11_alignas.ipp for details
// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif
#include <boost/config.hpp>
#include "test.hpp"
#ifndef BOOST_NO_CXX11_ALIGNAS
#include "boost_no_cxx11_alignas.ipp"
#else
namespace boost_no_cxx11_alignas = empty_boost;
#endif
int main( int, char *[] )
{
return boost_no_cxx11_alignas::test();
}