Commit Graph

121 Commits

Author SHA1 Message Date
George Koehler
7e14ab9e45 Use mmap(2) MAP_STACK to allocate stacks on OpenBSD
Since OpenBSD 6.4 (https://www.openbsd.org/64.html), the stack pointer
must point to MAP_STACK memory, or the kernel may kill the process
with a signal.  All stack allocators must pass MAP_STACK to mmap(2).

Define BOOST_CONTEXT_USE_MAP_STACK on OpenBSD, and don't define it on
other systems.  This doesn't check for old versions of OpenBSD without
MAP_STACK; but OpenBSD has stopped maintaining versions before 6.4.

If BOOST_CONTEXT_USE_MAP_STACK is defined, then cause the stack
allocators to pass MAP_STACK to mmap(2):

 - fixedsize_stack uses mmap/munmap instead of malloc/free.  This
   comes from a patch in OpenBSD Ports.

 - protected_fixedsize_stack adds MAP_STACK to the mmap flags (as it
   does in OpenBSD Ports).  Assume that systems with MAP_STACK also
   have MAP_ANON; this is true on OpenBSD.  Delete POSIX comment,
   because I can't find MAP_ANON nor MAP_ANONYMOUS in POSIX, so these
   mmap calls don't conform to POSIX.

 - pooled_fixedsize_stack can't call munmap, because the pool's free
   doesn't know the allocation's size.  Instead use posix_memalign to
   allocate memory, then mmap to replace the pages with MAP_STACK
   pages, so the pool's free may call std::free.

OpenBSD has no <ucontext.h>, so edit test/Jamfile.v2 to skip ucontext
tests on OpenBSD.

This commit and https://github.com/boostorg/test/pull/231 causes
libs/context/test `b2 full` to pass on OpenBSD 6.5 for 64-bit x86.
`b2 fc` fails because the allocator in test_fcontext.cpp does not use
MAP_STACK.  The tests seem not to cover pooled_fixedsize_stack nor
protected_fixedsize_stack, but they still pass when I temporarily hack
callcc to use those allocators instead of fixedsize_stack.
2019-10-03 20:47:36 -04:00
Oliver Kowalke
0c754f90c5 execution_context removed 2019-08-29 13:42:03 +02:00
Damian Jarek
e547c725a9
Fix bad static_cast in resume_with:
- fix a cast from void* to the wrong dynamic type. The code cast from
  tuple<decay_t<Fn>>* -> void* -> tuple<Fn>, which worked when an rvalue
  was passed to resume_with(), but broke if the function was passed
  by lvalue-reference, because it resulted in a cast from Fn to Fn&.
- remove use of std::tuple - no need to instantiate it for every callable.

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
2018-12-16 04:07:20 +01:00
Daniela Engert
129bf7c9fa
Possibly due to typos, assignments of double values were made to std::string variables.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-07-21 09:26:07 +02:00
Oliver Kowalke
ca7301cc55 build unit-tests as release 2018-05-26 07:18:25 +02:00
Oliver Kowalke
7605c64d95 checked catching of forced_unwind
- based on pull request #61
2018-05-26 07:18:25 +02:00
Oliver Kowalke
40c312b590 uint-tests using segmented stacks 2018-04-05 08:08:45 +02:00
Oliver Kowalke
bd29b48eab unit-tests: remove warning of redundant move in return statement 2018-03-12 09:00:50 +01:00
Oliver Kowalke
aef5de1aa9 unit-test: rename rule to 'native-impl' 2018-02-19 16:09:23 +01:00
Oliver Kowalke
2b1bf36545 unit-tests: exclude android from using ucontext 2018-02-19 15:09:49 +01:00
Oliver Kowalke
388a255ee8 rvalue-ref qualified resume()/resume_with() only 2018-02-09 17:27:35 +01:00
Oliver Kowalke
7c3a6b51c5 mark execution_context (v1) as deprecated 2018-02-08 09:56:22 +01:00
Oliver Kowalke
109543e23d fix buffer size use by snprintf() in unit-tests 2018-02-08 09:50:40 +01:00
Oliver Kowalke
b6582f13c5 fix unit-test for fiber on Windows 2018-02-08 05:56:35 +01:00
Oliver Kowalke
0249289ff5 register unit-test stacked only one 2018-02-08 06:39:26 +01:00
Oliver Kowalke
c6736e478c set test suite name 2018-02-07 20:56:35 +01:00
Oliver Kowalke
c7d01f1854 disable buildng unit-test with ucontext for MacOS X 2018-02-06 19:42:57 +01:00
Oliver Kowalke
a0433d1c72 execution_context without depended compilation
- execution_context v1 in namecpase v1
- execution_context v2 in inlined namespace v2
2018-02-05 19:34:35 +01:00
Oliver Kowalke
51ea6b583d re-introduce continuation - fix conflicts 2018-02-05 13:31:35 +01:00
Oliver Kowalke
f5327520d6 return fiber from resume()/resume_with() 2018-02-05 13:31:35 +01:00
Oliver Kowalke
10d3264f7b implementation of fibers without scheduler according to P0876R0 2018-02-05 13:31:32 +01:00
Oliver Kowalke
420554fe9a function executed by resume_with() has to return a continuation 2017-08-10 18:20:29 +02:00
Oliver Kowalke
8346fbfa89 no data transfer with call/cc 2017-08-01 09:43:29 +02:00
Oliver Kowalke
05646ee266 build unit-tests with variant release 2017-06-11 19:12:01 +02:00
Oliver Kowalke
01365a56c1 keep debug symbols in unit-tests 2017-06-04 20:27:03 +02:00
Oliver Kowalke
fbb225121d disable warning C4702 (MSVC) in unit-test 2017-06-04 20:27:03 +02:00
Oliver Kowalke
82e307a5ad add unit-test for call/cc for native APIs 2017-06-04 20:27:03 +02:00
Oliver Kowalke
cf53ef95e2 disable warning C4996 (MSVC) in unit-test 2017-06-04 20:27:03 +02:00
Oliver Kowalke
d61ee3c66c unit-tests: build parameters speed/release 2017-06-04 20:27:03 +02:00
Oliver Kowalke
fa890b1c4d adapt Jamfiles for new properties 2017-06-04 20:27:03 +02:00
Oliver Kowalke
4b8a730919 support ucontext_t in callcc() 2017-06-01 18:20:02 +02:00
Oliver Kowalke
da4a903634 unit-test: buffer length for snprintf 2017-04-22 22:12:22 +02:00
Oliver Kowalke
1abb5c4d32 enhance unit-test 2017-04-06 17:32:54 +02:00
Oliver Kowalke
d767a2371b replace BOOST_ASSERT by BOOST_CHECK in unit-test 2017-04-05 12:15:06 -07:00
Oliver Kowalke
7dfdede718 fix typo in unit-test 2017-04-05 17:21:29 +00:00
Oliver Kowalke
da597edbbe add missing header in unit-tests 2017-04-05 17:33:07 +02:00
oliver Kowalke
8c6047adf5 add unit-tests related to snprintf() 2017-04-05 08:19:56 +02:00
Nick Vrvilo
7fb76426bc Include missing header in test_fcontext.cpp 2017-04-04 14:48:58 -05:00
Oliver Kowalke
a1cc765318 unit-test for var-args added 2017-03-20 17:18:29 +00:00
Oliver Kowalke
705e6a0640 fix unit-test for callcc() (Windows) 2017-03-09 20:18:02 +01:00
Oliver Kowalke
82293a2c03 rename of continuation member functions 2017-03-05 10:22:48 +01:00
Aaron Gorenstein
7046102c2a Deliberate-failure tests shouldn't be optimized
A few tests designed to deliberately fail appeal to UB (undefined
behavior), but as the MSVC optimizer improves we will take advantage of
that to remove UB statements. In order for deliberate failures to occur,
the tests must have the optimizer turned off.
2017-02-14 12:24:00 -08:00
Oliver Kowalke
25ed545efb ontop-fn accept rvalue reference to continuation 2017-02-04 06:58:17 +01:00
oliver Kowalke
3a822359ec resume() -> continuation::operator() 2017-02-02 09:19:10 +01:00
oliver Kowalke
98291526a7 rename transfer_data() -> get_data() 2017-02-01 09:30:35 +01:00
Oliver Kowalke
dbd95e8421 callcc() -> resume() 2017-01-05 18:59:02 +01:00
Oliver Kowalke
ac38815b6d refactor all.hpp 2017-01-02 10:07:18 +01:00
Oliver Kowalke
6aafda324d decouple passed types 2017-01-02 10:07:17 +01:00
Oliver Kowalke
d32842cb50 context-fn signature continuation(*)(continuation &&) 2016-12-28 14:28:44 +01:00
Oliver Kowalke
ba37cd3968 remove template arg from callcc() 2016-12-28 12:36:25 +01:00