diff --git a/.travis.yml b/.travis.yml index 44ad0d3..4efa9b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,20 +19,13 @@ os: matrix: include: - - compiler: clang - env: TOOLSET=clang-3.4 - - compiler: clang - env: TOOLSET=clang-3.5 - - compiler: clang - env: TOOLSET=clang-3.6 - - compiler: gcc - env: TOOLSET=gcc-4.7 - - compiler: gcc - env: TOOLSET=gcc-4.8 - - compiler: gcc - env: TOOLSET=gcc-4.9 - - compiler: gcc - env: TOOLSET=gcc-5.1 + - env: TOOLSET=clang-3.4 + - env: TOOLSET=clang-3.5 + - env: TOOLSET=clang-3.6 + - env: TOOLSET=gcc-4.7 + - env: TOOLSET=gcc-4.8 + - env: TOOLSET=gcc-4.9 + - env: TOOLSET=gcc-5.1 before_install: wget "https://raw.githubusercontent.com/boostorg/regression/develop/ci/src/script.py" install: python script.py install diff --git a/appveyor.yml b/appveyor.yml index 3c702e4..0d02119 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,12 +12,14 @@ environment: platform: 32 - TOOLSET: vs-2012 platform: 32 - - TOOLSET: vs-2012 - platform: 64 - TOOLSET: vs-2013 platform: 32 - TOOLSET: vs-2013 platform: 64 + - TOOLSET: vs-2015 + platform: 32 + - TOOLSET: vs-2015 + platform: 64 configuration: - debug diff --git a/check/predef.jam b/check/predef.jam index 795c333..6fec1f0 100644 --- a/check/predef.jam +++ b/check/predef.jam @@ -14,6 +14,7 @@ import toolset ; import modules ; import path ; import "class" : new ; +import regex ; # Create a project for our targets. project.extension predef check ; @@ -21,30 +22,6 @@ project.extension predef check ; # Feature to pass check expressions to check programs. feature.feature predef-expression : : free ; -# Check programs. Each needs to be compiled for different languages -# even though they are all the same source code. -local rule check_target ( language : ext ) -{ - # Need to use absolute paths because we don't know the - # context of the invocation which affects where the paths - # originate from. - local predef_jam - = [ modules.binding $(__name__) ] ; - local source_path - = $(predef_jam:D)/predef_check_as_$(language).$(ext) ; - local include_path - = $(predef_jam:D)/../include ; - _check_exe_($(language)) = [ - exe predef_check_as_$(language) - : $(source_path) - : $(include_path) ] ; - explicit predef_check_as_$(language) ; -} -check_target c : c ; -check_target cpp : cpp ; -check_target objc : m ; -check_target objcpp : mm ; - # Checks the expressions and when used evaluates to the true-properties # if the expressions are all true. Otherwise evaluates to the # false-properties. @@ -65,26 +42,16 @@ rule check ( expressions + : language ? : true-properties * : false-properties * } else { - # The check program to use. - local exe_target = [ $(_check_exe_($(language))).name ] ; - exe_target = /check/predef//$(exe_target) ; - # Create the check run if we don't have one yet. local key = [ MD5 $(language)::$(expression) ] ; if ! ( $(key) in $(_checks_) ) { _checks_ += $(key) ; - _message_(/check/predef//$(key).txt) = $(expression) ; - make - $(key).txt : - $(exe_target) : - @$(__name__).predef_check_action : - $(expression) ; - explicit - $(key).txt ; + _message_(/check/predef//predef_check_cc_$(key)) = $(expression) ; + check_target $(language) $(key) : [ change_term_to_def $(expression) ] ; } - terms += /check/predef//$(key).txt ; + terms += /check/predef//predef_check_cc_$(key) ; } } local instance = [ new check-expression-evaluator @@ -102,15 +69,44 @@ rule require ( expressions + : language ? ) return [ check $(expressions) : $(language) : : no ] ; } -rule predef_check_action ( targets + : sources + : props * ) +############################################################################# + +.c.ext = c ; +.cpp.ext = cpp ; +.objc.ext = m ; +.objcpp.ext = mm ; + +# Check targets. Each needs to be compiled for different languages +# even though they are all the same source code. +local rule check_target ( language key : requirements * ) { - PREDEF_CHECK_EXPRESSION on $(targets) - = [ feature.get-values : $(props) ] ; + # Need to use absolute paths because we don't know the + # context of the invocation which affects where the paths + # originate from. + local predef_jam + = [ modules.binding $(__name__) ] ; + local source_path + = $(predef_jam:D)/predef_check_cc_as_$(language).$(.$(language).ext) ; + local include_path + = $(predef_jam:D)/../include ; + obj predef_check_cc_$(key) + : $(source_path) + : $(include_path) $(requirements) ; + explicit predef_check_cc_$(key) ; + return predef_check_cc_$(key) ; } -actions predef_check_action bind PREDEF_CHECK_EXPRESSION +local rule change_term_to_def ( term ) { - $(>) "$(PREDEF_CHECK_EXPRESSION)" > $(<) + local parts = [ regex.split $(term) " " ] ; + if $(parts[3]) + { + local version_number = [ regex.split $(parts[3]) "[.]" ] ; + if ! $(version_number[3]) { version_number += "0" ; } + if ! $(version_number[3]) { version_number += "0" ; } + parts = $(parts[1-2]) BOOST_VERSION_NUMBER($(version_number:J=",")) ; + } + return CHECK=\"$(parts:J=" ")\" ; } class check-expression-evaluator diff --git a/check/predef_check_cc.h b/check/predef_check_cc.h new file mode 100644 index 0000000..da7609e --- /dev/null +++ b/check/predef_check_cc.h @@ -0,0 +1,19 @@ +/* +Copyright Rene Rivera 2015 +Distributed under 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) +*/ +#include + +#ifdef CHECK +# if ((CHECK) == 0) +# error "FAILED" +# endif +#endif + +int dummy() +{ + static int d = 0; + return d++; +} diff --git a/check/predef_check_cc_as_c.c b/check/predef_check_cc_as_c.c new file mode 100644 index 0000000..24fab13 --- /dev/null +++ b/check/predef_check_cc_as_c.c @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +Distributed under 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) +*/ +#include "predef_check_cc.h" diff --git a/check/predef_check_cc_as_cpp.cpp b/check/predef_check_cc_as_cpp.cpp new file mode 100644 index 0000000..24fab13 --- /dev/null +++ b/check/predef_check_cc_as_cpp.cpp @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +Distributed under 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) +*/ +#include "predef_check_cc.h" diff --git a/check/predef_check_cc_as_objc.m b/check/predef_check_cc_as_objc.m new file mode 100644 index 0000000..24fab13 --- /dev/null +++ b/check/predef_check_cc_as_objc.m @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +Distributed under 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) +*/ +#include "predef_check_cc.h" diff --git a/check/predef_check_cc_as_objcpp.mm b/check/predef_check_cc_as_objcpp.mm new file mode 100644 index 0000000..24fab13 --- /dev/null +++ b/check/predef_check_cc_as_objcpp.mm @@ -0,0 +1,7 @@ +/* +Copyright Rene Rivera 2015 +Distributed under 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) +*/ +#include "predef_check_cc.h" diff --git a/doc/hardware_simd.qbk b/doc/hardware_simd.qbk new file mode 100644 index 0000000..c613310 --- /dev/null +++ b/doc/hardware_simd.qbk @@ -0,0 +1,89 @@ +SIMD predefs depend on compiler options. For example, you will have to add the +option `-msse3` to clang or gcc to enable SSE3. SIMD predefs are also inclusive. +This means that if SSE3 is enabled, then every other extensions with a lower +version number will implicitly be enabled and detected. However, some extensions +are CPU specific, they may not be detected nor enabled when an upper version is +enabled. + +[note SSE(1) and SSE2 are automatically enabled by default when using x86-64 +architecture.] + +To check if any SIMD extension has been enabled, you can use: + +`` +#include +#include + +int main() +{ +#if defined(BOOST_HW_SIMD_AVAILABLE) + std::cout << "SIMD detected!" << std::endl; +#endif + return 0; +} +`` + +When writing SIMD specific code, you may want to check if a particular extension +has been detected. To do so you have to use the right architecture predef and +compare it. Those predef are of the form `BOOST_HW_SIMD_"ARCH"` (where `"ARCH"` +is either `ARM`, `PPC`, or `X86`). For example, if you compile code for x86 +architecture, you will have to use `BOOST_HW_SIMD_X86`. Its value will be the +version number of the most recent SIMD extension detected for the architecture. + +To check if an extension has been enabled: + +`` +#include +#include + +int main() +{ +#if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE3_VERSION + std::cout << "This is SSE3!" << std::endl; +#endif + return 0; +} +`` + +[note The *_VERSION* defines that map version number to actual real +identifiers. This way it is easier to write comparisons without messing up with +version numbers.] + +To *"stricly"* check the most recent detected extension: + +`` +#include +#include + +int main() +{ +#if BOOST_HW_SIMD_X86 == BOOST_HW_SIMD_X86_SSE3_VERSION + std::cout << "This is SSE3 and this is the most recent enabled extension!" + << std::endl; +#endif + return 0; +} +`` + +Because of the version systems of predefs and of the inclusive property of SIMD +extensions macros, you can easily check for ranges of supported extensions: + +`` +#include +#include + +int main() +{ +#if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE2_VERSION &&\ + BOOST_HW_SIMD_X86 <= BOOST_HW_SIMD_X86_SSSE3_VERSION + std::cout << "This is SSE2, SSE3 and SSSE3!" << std::endl; +#endif + return 0; +} +`` + +[note Unlike gcc and clang, Visual Studio does not allow you to specify precisely +the SSE variants you want to use, the only detections that will take place are +SSE, SSE2, AVX and AVX2. For more informations, + see [@https://msdn.microsoft.com/en-us/library/b0084kay.aspx here].] + diff --git a/doc/history.qbk b/doc/history.qbk index 4c8833f..6358e1d 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -7,6 +7,15 @@ http://www.boost.org/LICENSE_1_0.txt) [section History] +[heading 1.4] + +* Add detection of SIMD hardware. With the addition of the `BOOST_HW_*` + category (from Charly Chevalier). +* Add compile only version of check utilities to address cross-compile + use cases. And changed the BBv2 check support to use compile only checks. +* Fix test warnings. +* Fix typos on `AVAILABLE` macros for Windows Platform. (from Vemund Handeland) + [heading 1.3] * Fix many problems with `predef_check` functionality. diff --git a/doc/html/index.html b/doc/html/index.html index 4e9d22c..70c1348 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -1,10 +1,10 @@ -Predef 1.3 +Predef 1.4 - + @@ -13,12 +13,14 @@

-Predef 1.3

+Predef 1.4

Rene Rivera

+
+

Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -42,6 +44,7 @@

BOOST_LIB library macros
BOOST_OS operating system macros
BOOST_PLAT platform macros
+
BOOST_HW hardware macros
Other macros
Version definition macros
@@ -54,7 +57,7 @@
- +

Last revised: July 01, 2015 at 22:17:15 GMT

Last revised: October 15, 2015 at 04:09:31 GMT


diff --git a/doc/html/predef/acknoledgements.html b/doc/html/predef/acknoledgements.html index 1a97b32..ccf5767 100644 --- a/doc/html/predef/acknoledgements.html +++ b/doc/html/predef/acknoledgements.html @@ -4,8 +4,8 @@ Acknoledgements - - + + @@ -36,7 +36,7 @@