Ticket #9437: boost-trunk-context-throw-wp8-ios.patch

File boost-trunk-context-throw-wp8-ios.patch, 10.1 KB (added by Evgeny Shapovalov <johncapfull@…>, 9 years ago)

patch with fixes

  • boost/context/detail/fcontext_arm_mac.hpp

     
     1
     2//          Copyright Oliver Kowalke 2009.
     3// Distributed under the Boost Software License, Version 1.0.
     4//    (See accompanying file LICENSE_1_0.txt or copy at
     5//          http://www.boost.org/LICENSE_1_0.txt)
     6
     7#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_MAC_H
     8#define BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_MAC_H
     9
     10#include <cstddef>
     11
     12#include <boost/config.hpp>
     13#include <boost/cstdint.hpp>
     14
     15#include <boost/context/detail/config.hpp>
     16
     17#ifdef BOOST_HAS_ABI_HEADERS
     18# include BOOST_ABI_PREFIX
     19#endif
     20
     21namespace boost {
     22namespace context {
     23
     24extern "C" {
     25
     26#define BOOST_CONTEXT_CALLDECL
     27
     28struct stack_t
     29{
     30    void    *   sp;
     31    std::size_t size;
     32
     33    stack_t() :
     34        sp( 0), size( 0)
     35    {}
     36};
     37
     38struct fp_t
     39{
     40    boost::uint32_t     fc_freg[16];
     41
     42    fp_t() :
     43        fc_freg()
     44    {}
     45};
     46
     47struct fcontext_t
     48{
     49    boost::uint32_t     fc_greg[11];
     50    stack_t             fc_stack;
     51    fp_t                fc_fp;
     52    void            *   fc_unwind_sjlj;
     53
     54    fcontext_t() :
     55        fc_greg(),
     56        fc_stack(),
     57        fc_fp()
     58    {}
     59};
     60
     61}
     62
     63}}
     64
     65#ifdef BOOST_HAS_ABI_HEADERS
     66# include BOOST_ABI_SUFFIX
     67#endif
     68
     69#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_MAC_H
  • boost/context/fcontext.hpp

     
    4949// arm
    5050#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
    5151    || defined(__TARGET_ARCH_THUMB) || defined(_ARM) || defined(_M_ARM)
    52 # include <boost/context/detail/fcontext_arm.hpp>
     52# if defined(__MACH__) && defined(__APPLE__)
     53#  include <boost/context/detail/fcontext_arm_mac.hpp>
     54# else
     55#  include <boost/context/detail/fcontext_arm.hpp>
     56# endif
    5357// mips
    5458#elif (defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) \
    5559    || defined(_R3000)
  • libs/context/src/asm/jump_arm_aapcs_macho_gas.S

     
    4242 *  -------------------------------------------------------------  *
    4343 *  | s26 | s27 | s28 | s29 | s30 | s31 |                       |  *
    4444 *  -------------------------------------------------------------  *
     45 *  -------------------------------------------------------------  *
     46 *  |  29 |                                                     |  *
     47 *  -------------------------------------------------------------  *
     48 *  | 0x74|                                                     |  *
     49 *  -------------------------------------------------------------  *
     50 *  | sjlj|                                                     |  *
     51 *  -------------------------------------------------------------  *
    4552 *                                                                 *
    4653 * *****************************************************************/
    4754
     
    6572    vldmia  a4, {d8-d15}            @ restore S16-S31
    66731:
    6774#endif
     75   
     76    mrc     p15, 0, a4, c13, c0, #3 @ locate TLS to save/restore SjLj handler
     77    bic     a4, a4, #3
    6878
     79    ldr     v1, [a4, #72]           @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key]
     80    str     v1, [a1, #116]          @ save SjLj unwind top handler
     81    ldr     v1, [a2, #116]          @ load new SjLj handler
     82    str     v1, [a4, #72]           @ store it to TLS
     83
    6984    mov     a1, a3                  @ use third arg as return value after jump
    7085                                    @ and as first arg in context function
    7186    ldmia   a2, {v1-v8,sp-pc}       @ restore v1-V8,SP-PC
  • libs/context/src/asm/jump_arm_aapcs_pe_armasm.asm

     
    1212; *  -------------------------------------------------------------  *
    1313; *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24|  *
    1414; *  -------------------------------------------------------------  *
    15 ; *  |  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  v8 |  sp |  lr |  *
     15; *  |  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  v8 |  lr |  sp |  *
    1616; *  -------------------------------------------------------------  *
    1717; *  -------------------------------------------------------------  *
    1818; *  |  10 |                                                     |  *
     
    5050    EXPORT jump_fcontext
    5151
    5252jump_fcontext PROC
    53     stmia   a1, {r4-r11,sp-lr}      ; save V1-V8,SP-LR
    54     str     lr, [a1,#40]            ; save LR as PC
     53    stmia   a1, {r4-r11,lr}           ; save V1-V8,LR
     54    str     sp, [a1,#0x24]            ; save SP separately - Thumb cannot handle stmia {sp-pc}
     55    str     lr, [a1,#0x28]            ; save LR as PC
    5556
    56     mov     a1, a3                  ; use third arg as return value after jump
    57                                     ; and as first arg in context function
    58     ldmia   a2, {r4-r11,sp-pc}      ; restore v1-V8,SP-PC
     57    ; load TIB to save/restore thread size and limit.
     58    ; we do not need preserveCPU flag and can use it's arg register
     59    mrc     p15, #0, a4, c13, c0, #2
    5960
     61    ldr     r4, [a4,#0x04]            ; current stack base
     62    ldr     r5, [a4,#0x08]            ; current stack limit
     63    sub     r5, r4, r5                ; size = base - limit
     64    str     r4, [a1,#0x2c]            ; save stack base
     65    str     r5, [a1,#0x30]            ; save stack size
     66
     67    ldr     r4, [a2,#0x2c]            ; load stack base
     68    ldr     r5, [a2,#0x30]            ; load stack limit
     69    sub     r5, r4, r5                ; limit = base - size
     70    str     r4, [a4,#0x04]            ; restore stack base
     71    str     r5, [a4,#0x08]            ; restore stack limit
     72
     73    mov     a1, a3                    ; use third arg as return value after jump
     74                                      ; and as first arg in context function
     75
     76    ldmia   a2, {r4-r11,lr}           ; restore V1-V8,LR
     77    ldr     sp, [a2,#0x24]
     78    ldr     pc, [a2,#0x28]
     79
    6080    ENDP
    6181    END
  • libs/context/src/asm/make_arm_aapcs_macho_gas.S

     
    4242 *  -------------------------------------------------------------  *
    4343 *  | s26 | s27 | s28 | s29 | s30 | s31 |                       |  *
    4444 *  -------------------------------------------------------------  *
     45 *  -------------------------------------------------------------  *
     46 *  |  29 |                                                     |  *
     47 *  -------------------------------------------------------------  *
     48 *  | 0x74|                                                     |  *
     49 *  -------------------------------------------------------------  *
     50 *  | sjlj|                                                     |  *
     51 *  -------------------------------------------------------------  *
    4552 *                                                                 *
    4653 * *****************************************************************/
    4754
     
    5057.align 2
    5158_make_fcontext:
    5259    mov     a4, a1          @ save address of context stack (base) A4
    53     sub     a1, a1, #116    @ reserve space for fcontext_t at top of context stack
     60    sub     a1, a1, #120    @ reserve space for fcontext_t at top of context stack
    5461
    5562    @ shift address in A1 to lower 16 byte boundary
    5663    @ == pointer to fcontext_t and address of context stack
  • libs/context/src/asm/make_arm_aapcs_pe_armasm.asm

     
    1212; *  -------------------------------------------------------------  *
    1313; *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24|  *
    1414; *  -------------------------------------------------------------  *
    15 ; *  |  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  v8 |  sp |  lr |  *
     15; *  |  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  v8 |  lr |  sp |  *
    1616; *  -------------------------------------------------------------  *
    1717; *  -------------------------------------------------------------  *
    1818; *  |  10 |                                                     |  *
     
    5353
    5454make_fcontext PROC
    5555    mov     a4, a1          ; save address of context stack (base) A4
    56     sub     a1, a1, #116    ; reserve space for fcontext_t at top of context stack
     56    sub     a1, a1, #0x74   ; reserve space for fcontext_t at top of context stack
    5757
    5858    ; shift address in A1 to lower 16 byte boundary
    5959    ; == pointer to fcontext_t and address of context stack
    60     bic     a1, a1, #15
     60    bic     a1, a1, #0x0f
    6161
    62     str     a4, [a1,#44]    ; save address of context stack (base) in fcontext_t
    63     str     a2, [a1,#48]    ; save context stack size in fcontext_t
    64     str     a3, [a1,#40]    ; save address of context function in fcontext_t
     62    str     a4, [a1,#0x2c]    ; save address of context stack (base) in fcontext_t
     63    str     a2, [a1,#0x30]    ; save context stack size in fcontext_t
     64    str     a3, [a1,#0x28]    ; save address of context function in fcontext_t
    6565
    66     str     a1, [a1,#32]    ; save address in A4 as stack pointer for context function
     66    str     a1, [a1,#0x24]    ; save address in A4 as stack pointer for context function
    6767
    6868    adr     a2, finish      ; compute abs address of label finish
    69     str     a2, [a1,#36]    ; save address of finish as return address for context function
     69    str     a2, [a1,#0x20]  ; save address of finish as return address for context function
    7070                            ; entered after context function returns
    7171
    7272    bx      lr