Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77196 - in trunk/libs/context: build config
From: steven_at_[hidden]
Date: 2012-03-03 22:35:31


Author: steven_watanabe
Date: 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
New Revision: 77196
URL: http://svn.boost.org/trac/boost/changeset/77196

Log:
Auto detect the architecture for Boost.Context.
Added:
   trunk/libs/context/build/architecture.jam (contents, props changed)
   trunk/libs/context/config/
   trunk/libs/context/config/32.cpp (contents, props changed)
   trunk/libs/context/config/64.cpp (contents, props changed)
   trunk/libs/context/config/Jamfile.jam (contents, props changed)
   trunk/libs/context/config/arm.cpp (contents, props changed)
   trunk/libs/context/config/mips1.cpp (contents, props changed)
   trunk/libs/context/config/power.cpp (contents, props changed)
   trunk/libs/context/config/x86.cpp (contents, props changed)
Text files modified:
   trunk/libs/context/build/Jamfile.v2 | 7 +++----
   1 files changed, 3 insertions(+), 4 deletions(-)

Modified: trunk/libs/context/build/Jamfile.v2
==============================================================================
--- trunk/libs/context/build/Jamfile.v2 (original)
+++ trunk/libs/context/build/Jamfile.v2 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -12,6 +12,7 @@
 import modules ;
 import os ;
 import toolset ;
+import architecture ;
 
 project boost/context
     : source-location ../src
@@ -197,10 +198,6 @@
      <target-os>windows
    ;
 
-message asm_context_sources
- : "warning: Boost.Context requires architecture=[x86|power|mips1|arm]"
- : "note: and (for x86 and power) address-model=[32|64]" ;
-
 explicit asm_context_sources ;
 
 
@@ -224,6 +221,8 @@
      context_sources
      fcontext.cpp
    : <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1
+ [ architecture.architecture ]
+ [ architecture.address-model ]
    ;
 
 boost-install boost_context ;

Added: trunk/libs/context/build/architecture.jam
==============================================================================
--- (empty file)
+++ trunk/libs/context/build/architecture.jam 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,76 @@
+# architecture.jam
+#
+# Copyright 2012 Steven Watanabe
+#
+# 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)
+
+import configure ;
+import project ;
+import path ;
+import property ;
+
+local here = [ modules.binding $(__name__) ] ;
+
+project.push-current [ project.current ] ;
+project.load [ path.join [ path.make $(here:D) ] ../config ] ;
+project.pop-current ;
+
+rule deduce-address-model ( properties * )
+{
+ local result = [ property.select <address-model> : $(properties) ] ;
+ if $(result)
+ {
+ return $(result) ;
+ }
+ else
+ {
+ if [ configure.builds /boost/architecture//32 : $(properties) : 32-bit ]
+ {
+ return <address-model>32 ;
+ }
+ else if [ configure.builds /boost/architecture//64 : $(properties) : 64-bit ]
+ {
+ return <address-model>64 ;
+ }
+ }
+}
+
+rule address-model ( )
+{
+ return <conditional>@architecture.deduce-address-model ;
+}
+
+rule deduce-architecture ( properties * )
+{
+ local result = [ property.select <architecture> : $(properties) ] ;
+ if $(result)
+ {
+ return $(result) ;
+ }
+ else
+ {
+ if [ configure.builds /boost/architecture//x86 : $(properties) : x86 ]
+ {
+ return <architecture>x86 ;
+ }
+ else if [ configure.builds /boost/architecture//power : $(properties) : power ]
+ {
+ return <architecture>power ;
+ }
+ else if [ configure.builds /boost/architecture//arm : $(properties) : arm ]
+ {
+ return <architecture>arm ;
+ }
+ else if [ configure.builds /boost/architecture//mips1 : $(properties) : mips1 ]
+ {
+ return <architecture>mips1 ;
+ }
+ }
+}
+
+rule architecture ( )
+{
+ return <conditional>@architecture.deduce-architecture ;
+}

Added: trunk/libs/context/config/32.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/32.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,9 @@
+// 32.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+int test[sizeof(void*) == 4? 1 : -1];

Added: trunk/libs/context/config/64.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/64.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,9 @@
+// 64.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+int test[sizeof(void*) == 8? 1 : -1];

Added: trunk/libs/context/config/Jamfile.jam
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/Jamfile.jam 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,17 @@
+# Jamfile.jam
+#
+# Copyright 2012 Steven Watanabe
+#
+# 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)
+
+project /boost/architecture ;
+
+obj 32 : 32.cpp ;
+obj 64 : 64.cpp ;
+
+obj power : power.cpp ;
+obj x86 : x86.cpp ;
+obj mips1 : mips1.cpp ;
+obj arm : arm.cpp ;

Added: trunk/libs/context/config/arm.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/arm.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,13 @@
+// arm.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(__arm__) && !defined(__thumb__) && \
+ !defined(__TARGET_ARCH_ARM) && !defined(__TARGET_ARCH_THUMB) && \
+ !defined(_ARM)
+#error "Not ARM"
+#endif

Added: trunk/libs/context/config/mips1.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/mips1.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,11 @@
+// mips1.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !((defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) || defined(_R3000))
+#error "Not MIPS1"
+#endif

Added: trunk/libs/context/config/power.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/power.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,14 @@
+// power.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(__powerpc) && !defined(__powerpc__) && !defined(__ppc) \
+ && !defined(__ppc__) && !defined(_M_PPC) && !defined(_ARCH_PPC) \
+ && !defined(__POWERPC__) && !defined(__PPCGECKO__) \
+ && !defined(__PPCBROADWAY) && !defined(_XENON)
+#error "Not PPC"
+#endif

Added: trunk/libs/context/config/x86.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/x86.cpp 2012-03-03 22:35:30 EST (Sat, 03 Mar 2012)
@@ -0,0 +1,16 @@
+// x86.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(i386) && !defined(__i386__) && !defined(__i386) \
+ && !defined(__i486__) && !defined(__i586__) && !defined(__i686__) \
+ && !defined(_M_IX86) && !defined(__X86__) && !defined(_X86_) \
+ && !defined(__THW_INTEL__) && !defined(__I86__) && !defined(__INTEL__) \
+ && !defined(__amd64__) && !defined(__x86_64__) && !defined(__amd64) \
+ && !defined(__x86_64) && !defined(_M_X64)
+#error "Not x86"
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk