Ticket #8993: boost_1_54_0-m68k-1.patch

File boost_1_54_0-m68k-1.patch, 2.9 KB (added by Mikael Pettersson <mikpe@…>, 9 years ago)

explicitly pad arrays of VAR_EDITs on the stack to a multiple of sizeof(LIST*)

  • boost_1_54_0/tools/build/v2/engine/function.c

    old new struct _stack  
    216216
    217217static void * stack;
    218218
     219static size_t align_down( size_t n )
     220{
     221    return n & ~( sizeof( LIST * ) - 1 );
     222}
     223
     224static size_t align_up( size_t n )
     225{
     226    return align_down( n + sizeof( LIST * ) - 1 );
     227}
     228
    219229STACK * stack_global()
    220230{
    221231    static STACK result;
    STACK * stack_global()  
    223233    {
    224234        int const size = 1 << 21;
    225235        stack = BJAM_MALLOC( size );
    226         result.data = (char *)stack + size;
     236        result.data = (void *)align_down( (size_t)( (char *)stack + size ) );
    227237    }
    228238    return &result;
    229239}
    static int expand_modifiers( STACK * s,  
    854864
    855865    if ( total != 0 )
    856866    {
    857         VAR_EDITS * out = stack_allocate( s, total * sizeof( VAR_EDITS ) );
     867        VAR_EDITS * out = stack_allocate( s, align_up( total * sizeof( VAR_EDITS ) ) );
    858868        LISTITER * iter = stack_allocate( s, n * sizeof( LIST * ) );
    859869        for ( i = 0; i < n; ++i )
    860870            iter[ i ] = list_begin( args[ i ] );
    LIST * function_run( FUNCTION * function  
    42634273            stack_push( s, l );
    42644274            l = apply_modifiers( s, n );
    42654275            list_free( stack_pop( s ) );
    4266             stack_deallocate( s, n * sizeof( VAR_EDITS ) );
     4276            stack_deallocate( s, align_up( n * sizeof( VAR_EDITS ) ) );
    42674277            for ( i = 0; i < code->arg; ++i )
    42684278                list_free( stack_pop( s ) );  /* pop modifiers */
    42694279            stack_push( s, l );
    LIST * function_run( FUNCTION * function  
    42894299            l = apply_subscript_and_modifiers( s, n );
    42904300            list_free( stack_pop( s ) );
    42914301            list_free( stack_pop( s ) );
    4292             stack_deallocate( s, n * sizeof( VAR_EDITS ) );
     4302            stack_deallocate( s, align_up( n * sizeof( VAR_EDITS ) ) );
    42934303            for ( i = 0; i < code->arg; ++i )
    42944304                list_free( stack_pop( s ) );  /* pop modifiers */
    42954305            stack_push( s, l );
    LIST * function_run( FUNCTION * function  
    43124322                list_free( stack_pop( s ) );
    43134323            }
    43144324            list_free( vars );
    4315             stack_deallocate( s, n * sizeof( VAR_EDITS ) );
     4325            stack_deallocate( s, align_up( n * sizeof( VAR_EDITS ) ) );
    43164326            for ( i = 0; i < code->arg; ++i )
    43174327                list_free( stack_pop( s ) );  /* pop modifiers */
    43184328            stack_push( s, result );
    LIST * function_run( FUNCTION * function  
    43584368            }
    43594369            list_free( stack_pop( s ) );
    43604370            list_free( vars );
    4361             stack_deallocate( s, n * sizeof( VAR_EDITS ) );
     4371            stack_deallocate( s, align_up( n * sizeof( VAR_EDITS ) ) );
    43624372            for ( i = 0; i < code->arg; ++i )
    43634373                list_free( stack_pop( s ) );  /* pop modifiers */
    43644374            stack_push( s, result );