VirtualBox

Changeset 2777 in kBuild for trunk/src


Ignore:
Timestamp:
Feb 3, 2015 9:06:31 PM (10 years ago)
Author:
bird
Message:

kmk_cc_exec.c: Make sure the variable doesn't get modified while we're running the expansion program. It'll screw up our string references.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmk_cc_exec.c

    r2772 r2777  
    325325    uint32_t                uInputHash;
    326326#endif
     327    /** Reference count. */
     328    uint32_t volatile       cRefs;
    327329} KMKCCEXPPROG;
    328330/** Pointer to a string expansion program. */
     
    14571459        pProg->pFirstInstr  = (PKMKCCEXPCORE)kmk_cc_block_get_next_ptr(pBlock);
    14581460        kmk_cc_exp_stats_init(&pProg->Stats);
     1461        pProg->cRefs        = 1;
    14591462#ifdef KMK_CC_STRICT
    14601463        pProg->uInputHash   = kmk_cc_debug_string_hash_n(0, pchStr, cchStr);
     
    19161919        pchDst = ensure_variable_buffer_space(pchDst, offStart + pProg->Stats.cchAvg + 32);
    19171920
     1921    KMK_CC_ASSERT(pProg->cRefs > 0);
     1922    pProg->cRefs++;
     1923
    19181924    pchDst = kmk_exec_expand_instruction_stream_to_var_buf(pProg->pFirstInstr, pchDst);
     1925
     1926    pProg->cRefs--;
     1927    KMK_CC_ASSERT(pProg->cRefs > 0);
    19191928
    19201929    cchResult = (uint32_t)(pchDst - variable_buffer);
     
    19621971void  kmk_cc_variable_changed(struct variable *pVar)
    19631972{
    1964     KMK_CC_ASSERT(pVar->evalprog || pVar->expandprog);
     1973    PKMKCCEXPPROG pProg = pVar->expandprog;
     1974
     1975    KMK_CC_ASSERT(pVar->evalprog || pProg);
     1976
    19651977#if 0
    19661978    if (pVar->evalprog)
     
    19701982    }
    19711983#endif
    1972     if (pVar->expandprog)
    1973     {
    1974         kmk_cc_block_free_list(pVar->expandprog->pBlockTail);
     1984
     1985    if (pProg)
     1986    {
     1987        if (pProg->cRefs == 1)
     1988            kmk_cc_block_free_list(pProg->pBlockTail);
     1989        else
     1990            fatal(NULL, _("Modifying a variable (%s) while its expansion program is running is not supported"), pVar->name);
    19751991        pVar->expandprog = NULL;
    19761992    }
     
    19852001void  kmk_cc_variable_deleted(struct variable *pVar)
    19862002{
    1987     KMK_CC_ASSERT(pVar->evalprog || pVar->expandprog);
     2003    PKMKCCEXPPROG pProg = pVar->expandprog;
     2004
     2005    KMK_CC_ASSERT(pVar->evalprog || pProg);
     2006
    19882007#if 0
    19892008    if (pVar->evalprog)
     
    19932012    }
    19942013#endif
    1995     if (pVar->expandprog)
    1996     {
    1997         kmk_cc_block_free_list(pVar->expandprog->pBlockTail);
     2014
     2015    if (pProg)
     2016    {
     2017        if (pProg->cRefs == 1)
     2018            kmk_cc_block_free_list(pProg->pBlockTail);
     2019        else
     2020            fatal(NULL, _("Deleting a variable (%s) while its expansion program is running is not supported"), pVar->name);
    19982021        pVar->expandprog = NULL;
    19992022    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette