Why don't you just have Boost.Context be a wrapper around getcontext/setcontext/swapcontext and ignore the save_fp argument? Then you don't need to write anything special for AARCH64 or any new target?
Thanks, Andrew
-----Original Message----- From: linaro-toolchain-bounces@lists.linaro.org [mailto:linaro-toolchain-bounces@lists.linaro.org] On Behalf Of Edward Nevill Sent: Tuesday, February 24, 2015 6:54 AM To: linaro-toolchain@lists.linaro.org Subject: Problems porting Boost.Context to aarch64 gcc
Hi,
I am trying to port the Boost.Context library (from www.boost.org) to aarch64 gcc and have come across a gnarly problem.
Boost.Context essentially does co-routine style context switching. It has a structure f_context which it uses to save and restore contexts. The structure f_context contains both integer (x0..xN) and floating point VFP (d8..d15) context.
The function jump_context switches contexts
typedef struct f_context *f_context_t
extern void jump_context(fcontext_t *old, f_context_t new, bool save_fp);
So this jumps to a new context returning the old context in *old. If save_fp is set the floating point context must be saved because the application uses floating point. Otherwise the save and restore of the floating point context may be ignored.
So, essentially, to save the old context it does
jump_fcontext: # prepare stack for GP + FPU sub sp, sp, #0xb0
# test if fpu env should be preserved cmp w3, #0 b.eq 1f
# save d8 - d15 stp d8, d9, [sp, #0x00] stp d10, d11, [sp, #0x10] stp d12, d13, [sp, #0x20] stp d14, d15, [sp, #0x30]
1: # save x19-x30 stp x19, x20, [sp, #0x40] stp x21, x22, [sp, #0x50] stp x23, x24, [sp, #0x60] stp x25, x26, [sp, #0x70] stp x27, x28, [sp, #0x80] stp x29, x30, [sp, #0x90]
However, there is a problem with this because gcc may store integer value in floating point registers around a function call.
So, I have no way of knowing whether it is actually necessary to save/restore floating point context.
Even worse applications using Boost.Context may be completely borken if they assume it is safe to call jump_context with save_fp == 0.
Any suggestions?
Ed.
_______________________________________________ linaro-toolchain mailing list linaro-toolchain@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-toolchain