2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-19 04:02:17 +00:00

155 Commits

Author SHA1 Message Date
Vasanth Karanam
68ea30dfd7 Add Windows ARM64 support
Currently we do not have fcontext related ASM files for Windows ARM64.
So we can use winfib context-impl only for Windows ARM64.

Fixes issue : https://github.com/boostorg/boost/issues/1070
Related to PR: https://github.com/boostorg/boost/pull/1077
2025-09-23 20:44:35 +01:00
Vasanth Karanam
28722d1c8b Add Windows ARM64 support
Fixes issue : https://github.com/boostorg/boost/issues/1070
Related to PR: https://github.com/boostorg/boost/pull/1077
2025-09-23 20:37:38 +01:00
René Ferdinand Rivera Morell
3378976432 Add safeseh to clang-win building.
As an alternative msvc compiler the clang-win toolset needs the same seh flags.
2025-05-15 22:47:13 -05:00
Thomas Dickerson
35ddf2103e Support gcc when building ASM on Darwin
Parallel to #178 but for aarch64 instead of x86_64
2025-04-17 12:00:53 -04:00
Dmitry Arkhipov
12ac945158 move context-impl feature into a module
This is now necessary to allow users to set it from the command line.
2025-01-07 16:11:34 +03:00
Martin Vejbora
2767c8e1f2 Clean up comment headings 2024-11-08 16:30:14 +01:00
Martin Vejbora
566fdee8ad Define assembler files for ARM64+PE+GCC 2024-11-08 16:30:07 +01:00
Martin Vejbora
9068c08ee7 Fix assembler extensions in Jamfile 2024-11-08 16:24:40 +01:00
Chris Ward
77835b78c0 Jamfile 2024-10-31 10:45:46 +00:00
Oliver Kowalke
7c80551e16 Merge pull request #273 from rdoeffinger/develop
Convert make_fcontext etc into true C++ symbols
2024-10-27 17:34:44 +01:00
Reimar Döffinger
245904742b Convert make_fcontext etc into true C++ symbols
Also mark the non-mangled fcontext asm function symbols
as hidden visibility
These functions should not be exported as dynamic
symbols by boost, only the namespaced C++ symbols
introduced by this patch should.
2024-10-14 13:23:16 +02:00
Oliver Kowalke
5d852fc034 Merge pull request #265 from boostorg/master
Master
2024-08-28 12:45:50 +02:00
Rene Rivera
953437695b Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:23 -05:00
Liryna
e878e8edb2 Convert ARM64 armasm to armclang for Windows clang 2024-06-26 18:24:52 +00:00
Rene Rivera
3850a4da99 Add missing NO_LIB usage requirements. 2024-04-28 20:14:38 -05:00
Rene Rivera
877d450537 Remove accidentally added conflict file. 2024-04-26 23:06:09 -05:00
Claudio Jeker
d2109fdc2e Implement the fcontext asm for sparc64
This implements the required asm functions for sparc64_sysv_elf and
was tested on an OpenBSD/sparc64 system.

Jump_fcontext uses an extra C call frame to store the frame-pointer and
return address. Because of this the code is simply a save (to new reg
window), then forcing a window flush and finally switch stack and restore
from there.

Since jump_fcontext() uses a register window and stack frame, make_fcontext()
reserves two call frames on the stack (one for jump_fcontext() and the other
for the callback function).

OpenBSD/sparc64 uses stackghost which prevents userland from overriding the
return-address on the stack. Because of this make_fcontext() uses an extra
trampoline to implement the _exit(0) call if the callback returns.

All tests pass with this on OpenBSD/sparc64 (also the tests for fiber,
coroutine and coroutine2).
2024-03-11 08:51:26 -05:00
Oliver Kowalke
d81d611fa2 support gcc for ARM64 on mac OS X
- #255
2024-03-11 08:51:26 -05:00
Rene Rivera
9170c51c98 Make the library modular usable. 2024-03-11 08:31:17 -05:00
Oliver Kowalke
d9bea79b09 Merge pull request #251 from cjeker/sparc64_asm_support
Implement the fcontext asm for sparc64
2024-03-10 20:18:12 +01:00
Oliver Kowalke
99be0a678d support gcc for ARM64 on mac OS X
- #255
2024-03-10 20:07:00 +01:00
Claudio Jeker
17945a28a2 Implement the fcontext asm for sparc64
This implements the required asm functions for sparc64_sysv_elf and
was tested on an OpenBSD/sparc64 system.

Jump_fcontext uses an extra C call frame to store the frame-pointer and
return address. Because of this the code is simply a save (to new reg
window), then forcing a window flush and finally switch stack and restore
from there.

Since jump_fcontext() uses a register window and stack frame, make_fcontext()
reserves two call frames on the stack (one for jump_fcontext() and the other
for the callback function).

OpenBSD/sparc64 uses stackghost which prevents userland from overriding the
return-address on the stack. Because of this make_fcontext() uses an extra
trampoline to implement the _exit(0) call if the callback returns.

All tests pass with this on OpenBSD/sparc64 (also the tests for fiber,
coroutine and coroutine2).
2024-02-13 11:16:42 +01:00
Ivan A. Melnikov
819c2d6423 Fix ABI detection for empty 'os.platform'
`in` operator in bjam always returns true if its first
argument has no elements[1]. This means that if `os.platform`
is empty (not detected), the construction introduced
in commit d039c8e4da sets
ABI to `aapcs` on all platforms where `os.platform` is
empty, including, e.g. riscv64, and breaks build there.

This commit refactors the condition to use '=' operator,
to make sure that when `os.platform` is empty we get
the default ABI value, and thus fixes build on riscv64.

[1] https://www.boost.org/doc/libs/1_83_0/tools/build/doc/html/index.html#jam.language.flow_of_control

Fixes: d039c8e4da
2023-08-17 14:15:03 +04:00
Sergey Fedorov
d57d28640d Jamfile: sort out macOS ppc asm_sources 2023-05-15 16:51:54 +08:00
Nikita Kniazev
d039c8e4da Fix arm64 detection broken by recent B2 change 2023-03-23 16:23:07 +03:00
Evan Miller
070d03fc7e Fixes for Darwin PPC32
For make_fcontext, use the diff provided here:

https://github.com/boostorg/context/issues/211#issuecomment-1328154669

For ontop_context, adapt the Linux PPC32 fixes from here:

df8fb6b528

Co-authored-by: George Koehler <kernigh@gmail.com>
2022-12-27 10:47:41 -05:00
Oliver Kowalke
5bcc1ab155 architecture flag for Apple's combined ha changed to 'arm+x86' 2022-12-23 11:14:10 +01:00
Oliver Kowalke
ad3fc892b5 support s390x + clang in build/Jamfile.v2
- #208
2022-10-16 07:27:09 +02:00
Oliver Kowalke
5852b49355 change address model to 32bit for x32 ABI
related to issue #200
2022-09-18 15:52:47 +02:00
dixyes
abf8e04e23 Spport Windows arm64 cpp exception
Windows C++ exception unwinding needs TEB(TIB) stack info matching real
stack.
2022-06-26 09:53:11 +08:00
dixyes
697299ea55 Add windows arm64 fcontext support 2022-06-26 09:51:30 +08:00
Zhang Na
e1001c479e Add support for loongarch64 2022-02-15 17:28:33 +08:00
Brad Smith
04ab01d386 Add support for building on riscv64 with Clang 2021-11-12 04:35:18 -05:00
Oliver Kowalke
c55b58bf0a Merge branch 'develop' into mips 2021-08-06 07:41:02 +02:00
Oliver Kowalke
8f69d9d03c Merge pull request #178 from eschnett/eschnett/macho-gcc
Allow building asm_sources with GCC on 64-bit MACH-O
2021-07-15 06:44:59 +02:00
Erik Schnetter
cee39879a3 Allow building asm_sources with GCC on 64-bit MACH-O 2021-07-14 17:24:44 -04:00
Nikita Kniazev
8425e830ea Cease dependence on Thread
On C++11 static local variables are initialized in thread-safe manner, but even on C++03 it should not be a problem because in our case variables are of trivial types, which means double initialization is not an issue, and they are initialized with the same value in every thread.
2021-06-12 22:23:08 +03:00
Ilia K
e97864875b Use /safeseh asmflags for MSVC x86 2021-04-16 07:54:44 +02:00
Oliver Kowalke
575dc2b7be Merge pull request #140 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74
2020-06-28 17:05:44 +02:00
EGuesnet
8d1c3fbe19 Update Jamfile.v2 2020-06-25 08:46:02 +02:00
EGuesnet
5c0adf0b84 split-stack flag for GCC
-fsplit-stack flag  available only on Linux for GCC
2020-06-24 10:45:44 +02:00
Edward Diener
2dbaa73de2 Setup fpr Embarcadero bcc64 64-bit assembler, the Embarcadero 32-bit assembler, and the Bprland 32-bit assembler. The syntactical difference between the Embarcqadero 32-bit assembler and the Borland 32-bit assembler is simply that the embarcadero toolset uses clang-based command lines, while the bporland toolset uses bcc32 based command lines. Otherwise both use tasm32 to assemble assembly files. 2020-05-13 18:58:37 -04:00
YunQiang Su
19f2351124 Use OSPLAT MIPS32/MIPS64 to set different ABI
We should set abi for 64bit as n64, and 32bit for o32.
This patch depends on the patch of boost/build.
2019-12-18 03:33:18 -08:00
George Koehler
df8fb6b528 Fix ppc32 on Linux musl, NetBSD, OpenBSD; fixes #120
This fixes fcontext on my PowerBook G4 running Void Linux
ppc-musl-20190901, NetBSD/macppc 8.1, or OpenBSD/macppc 6.6-current,
all with g++.  These systems use fcontext for *ppc32_sysv_elf*
(PowerPC 32-bit System V ELF).  The assembly code was wrong for BSD
and crashing on Linux musl.

Linux returns a transfer_t in memory (through a hidden pointer in R3),
but other systems (at least NetBSD and OpenBSD) return a transfer_t in
registers R3:R4.  jump_fcontext() and ontop_fcontext() were always
using the hidden pointer.  Add checks for `#ifdef__linux__`; start
using R3:R4 on other systems.

make_fcontext() was calling _exit(0) through the insecure BSS PLT.
Set R30 to use the secure PLT.  This prevents a crash when musl's
ld.so loads the executable; musl seems to require the secure PLT.

Fix ontop_fcontext() to restore the hidden pointer on Linux.  It was
passing the wrong context's hidden pointer to the ontop-function fn(),
so fn() returned a transfer_t to the wrong stack.  When fn() was
context_exit() in <boost/context/continuation_fcontext.hpp>, it freed
the old stack, then returned `transfer_t{ nullptr, nullptr }` to free
memory.  This crashed on Linux musl.

Now that ontop_fcontext() restores the hidden pointer, it must stop
abusing the same pointer to pass a transfer_t argument to fn().  Add a
new ontop_fcontext_tail() in C++, which takes arguments in registers
and allocates a transfer_t.  The code is in C++ so it can free the
transfer_t argument if fn() throws a C++ exception.

Rearrange the context frame to shrink it from 244 to 240 bytes.  This
fixes the stack alignment: the ABI requires R1 % 16 == 0, and
make_fcontext() respects this, but jump_fcontext() was adding 244 to
R1, so the new context ran with a misaligned stack (244 % 16 == 4).

Remove R13 from the context frame, so new contexts stop loading R13
with garbage.  The ABI uses R13 to point to the executable's small
data, so R13 should have the same value in every context.

Add the backchain to the context frame; make room by moving LR to the
caller's frame.  Order CR, R14 to R31, F14 to F31 at the frame's end,
as is typical for this ABI.  Provide 8-byte alignment for FPSCR and
F14 to F31, to avoid a misalignment penalty.
2019-10-19 14:06:24 -04:00
Naveenaidu
adecfdc88c S390x: Add Support for s390x arch 2019-09-06 20:08:10 +05:30
Oliver Kowalke
0c754f90c5 execution_context removed 2019-08-29 13:42:03 +02:00
Oliver Kowalke
9c772a7830 Revert "S390x Implementation: WIP" 2019-08-03 08:33:17 +02:00
Naveenaidu
cc71b90db6 Jamfile.v2: Fix binary format s390x 2019-08-03 09:27:55 +05:30
Naveenaidu
e7c5977119 architecture.jam: Add s390x arch 2019-07-22 22:53:43 +05:30
Naveenaidu
2d56804025 Jamfile.v2: Add s390x arch 2019-07-22 22:53:43 +05:30