summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2017-02-03 03:08:38 (GMT)
committerTony Theodore <tonyt@logyst.com>2017-02-03 03:08:38 (GMT)
commitb477bae14c12be5f4f8abe8e4d70f3c80e7f5403 (patch)
tree9c2708fa96fe3af1537a836a79f6b9685dd0fea7
parent8268bf6e9ea56fb959db6bb6291c088c0f5aa210 (diff)
downloadmxe-b477bae14c12be5f4f8abe8e4d70f3c80e7f5403.zip
mxe-b477bae14c12be5f4f8abe8e4d70f3c80e7f5403.tar.gz
mxe-b477bae14c12be5f4f8abe8e4d70f3c80e7f5403.tar.bz2
boost: add test for boost.context linking
-rw-r--r--src/boost-test.cmake2
-rw-r--r--src/boost-test.cpp31
-rw-r--r--src/boost.mk3
3 files changed, 34 insertions, 2 deletions
diff --git a/src/boost-test.cmake b/src/boost-test.cmake
index cfde376..12ec9cf 100644
--- a/src/boost-test.cmake
+++ b/src/boost-test.cmake
@@ -7,7 +7,7 @@ set(TGT test-${PKG}-cmake)
enable_language(CXX)
add_executable(${TGT} ${CMAKE_CURRENT_LIST_DIR}/${PKG}-test.cpp)
-find_package(Boost ${PKG_VERSION} EXACT COMPONENTS chrono serialization system thread REQUIRED)
+find_package(Boost ${PKG_VERSION} EXACT COMPONENTS chrono context serialization system thread REQUIRED)
target_link_libraries(${TGT} ${Boost_LIBRARIES})
install(TARGETS ${TGT} DESTINATION bin)
diff --git a/src/boost-test.cpp b/src/boost-test.cpp
index d975894..4dac283 100644
--- a/src/boost-test.cpp
+++ b/src/boost-test.cpp
@@ -9,6 +9,10 @@
boost::thread_specific_ptr<int> ptr;
+// http://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/context/context.html
+#include <boost/context/all.hpp>
+boost::context::fcontext_t fcm,fc1,fc2;
+
void test_thread()
{
if (ptr.get() == 0) {
@@ -17,6 +21,23 @@ void test_thread()
std::cout << "Hello, World! from thread" << std::endl;
}
+void f1(intptr_t)
+{
+ std::cout<<"f1: entered"<<std::endl;
+ std::cout<<"f1: call jump_fcontext( & fc1, fc2, 0)"<< std::endl;
+ boost::context::jump_fcontext(&fc1,fc2,0);
+ std::cout<<"f1: return"<<std::endl;
+ boost::context::jump_fcontext(&fc1,fcm,0);
+}
+
+void f2(intptr_t)
+{
+ std::cout<<"f2: entered"<<std::endl;
+ std::cout<<"f2: call jump_fcontext( & fc2, fc1, 0)"<<std::endl;
+ boost::context::jump_fcontext(&fc2,fc1,0);
+ BOOST_ASSERT(false&&!"f2: never returns");
+}
+
int main(int argc, char *argv[])
{
(void)argc;
@@ -29,5 +50,15 @@ int main(int argc, char *argv[])
boost::thread thrd(test_thread);
thrd.join();
+ std::size_t size(8192);
+ void* sp1(std::malloc(size));
+ void* sp2(std::malloc(size));
+
+ fc1=boost::context::make_fcontext(sp1,size,f1);
+ fc2=boost::context::make_fcontext(sp2,size,f2);
+
+ std::cout<<"main: call jump_fcontext( & fcm, fc1, 0)"<<std::endl;
+ boost::context::jump_fcontext(&fcm,fc1,0);
+
return 0;
}
diff --git a/src/boost.mk b/src/boost.mk
index 2a05987..cc9fdbc 100644
--- a/src/boost.mk
+++ b/src/boost.mk
@@ -73,7 +73,8 @@ define $(PKG)_BUILD
-lboost_serialization-mt \
-lboost_thread_win32-mt \
-lboost_system-mt \
- -lboost_chrono-mt
+ -lboost_chrono-mt \
+ -lboost_context-mt
# test cmake
mkdir '$(1).test-cmake'