VirtualBox

Changeset 2618 in kBuild for trunk/src


Ignore:
Timestamp:
Aug 2, 2012 3:34:40 AM (12 years ago)
Author:
bird
Message:

kObjCache: Redid the buffering in the optimizer.

Location:
trunk/src/kObjCache
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kObjCache/Makefile.kmk

    r2612 r2618  
    2929PROGRAMS += kObjCache
    3030kObjCache_TEMPLATE = BIN
     31kObjCache_DEFS.release = NASSERT
    3132kObjCache_SOURCES = kObjCache.c
    3233kObjCache_LIBS = \
  • trunk/src/kObjCache/kObjCache.c

    r2617 r2618  
    885885
    886886
     887static void kOCDepEnter(PKOCDEP pDepState, const char *pszUnescFilename, size_t cchFilename)
     888{
     889    if (cchFilename + 1 >= pDepState->cbFilenameAlloced)
     890    {
     891        pDepState->cbFilenameAlloced = (cchFilename + 1 + 15) & ~15;
     892        pDepState->pszFilename = (char *)xrealloc(pDepState->pszFilename, pDepState->cbFilenameAlloced);
     893    }
     894
     895    memcpy(pDepState->pszFilename, pszUnescFilename, cchFilename);
     896    pDepState->pszFilename[cchFilename] = '\0';
     897    cchFilename = kOCDepUnescape(pDepState->pszFilename);
     898
     899    if (   !pDepState->pCurDep
     900        || cchFilename != pDepState->pCurDep->cchFilename
     901        || strcmp(pDepState->pszFilename, pDepState->pCurDep->szFilename))
     902        pDepState->pCurDep = depAdd(pDepState->pszFilename, cchFilename);
     903}
     904
     905
    887906/**
    888907 * This consumes the preprocessor output and generate dependencies from it.
     
    11101129    size_t cbBufAlloc;
    11111130    /** Amount preprocessor output that we've completed optimizations for. */
    1112     size_t cchOptimized;
     1131    size_t cchDstOptimized;
     1132    /** Offset to the start of the unoptimized source. */
     1133    size_t offSrcUnoptimized;
    11131134    /** The offset of the next bits to process. */
    1114     size_t offCur;
     1135    size_t offSrcCur;
    11151136    /** The offset where to put more raw preprocessor output. */
    1116     size_t offRead;
     1137    size_t offSrcRead;
    11171138    /** The line number corresponding to offOptimized. */
    11181139    uint32_t uOptLineNo;
    11191140    /** The current line number. */
    11201141    uint32_t uCurLineNo;
    1121     /** The number of lines found to be empty starting at cchOptimized. */
    1122     uint32_t cEmptyLines;
    11231142    /** Set if we're done, clear if we're expecting more preprocessor output. */
    11241143    int fDone;
     
    11391158    /** The size of the buffer pointed to by pszLineBuf. */
    11401159    size_t cbLineBuf;
     1160
     1161    /** Set if we should work the dependency generator as well. */
     1162    PKOCDEP pDepState;
    11411163} KOCCPPRD;
    11421164/** Pointer to a preprocessor reader state. */
     
    11511173 *                      there was not previous run.
    11521174 * @param   fOptimize   Whether optimizations are enabled.
    1153  */
    1154 static void kOCCppRdInit(PKOCCPPRD pCppRd, size_t cbOldCpp, int fOptimize)
    1155 {
     1175 * @param   pDepState   Pointer to the dependency generator.  Must only be set
     1176 *                      if @a fOptimize is also set.
     1177 */
     1178static void kOCCppRdInit(PKOCCPPRD pCppRd, size_t cbOldCpp, int fOptimize, PKOCDEP pDepState)
     1179{
     1180    assert(!pDepState || fOptimize);
     1181
    11561182    pCppRd->cbBufAlloc = cbOldCpp ? (cbOldCpp + KOC_BUF_INCR) & ~(KOC_BUF_ALIGNMENT - 1) : KOC_BUF_MIN;
    11571183    pCppRd->pszBuf = xmalloc(pCppRd->cbBufAlloc);
    11581184    pCppRd->cchCurFileNm = 0;
    1159     pCppRd->cchOptimized = 0;
    1160     pCppRd->offCur = 0;
    1161     pCppRd->offRead = 0;
     1185    pCppRd->cchDstOptimized = 0;
     1186    pCppRd->offSrcUnoptimized = 0;
     1187    pCppRd->offSrcCur = 0;
     1188    pCppRd->offSrcRead = 0;
    11621189    pCppRd->uOptLineNo = 1;
    11631190    pCppRd->uCurLineNo = 1;
    1164     pCppRd->cEmptyLines = 0;
    11651191    pCppRd->fDone = 0;
    11661192    pCppRd->chSaved = 0;
     
    11731199    pCppRd->pszLineBuf = NULL;
    11741200    pCppRd->cbLineBuf = 0;
     1201
     1202    pCppRd->pDepState = pDepState;
    11751203}
    11761204
     
    11991227    pCppRd->pszBuf = xrealloc(pCppRd->pszBuf, pCppRd->cbBufAlloc);
    12001228
    1201     return pCppRd->cbBufAlloc - pCppRd->offRead;
    1202 }
    1203 
    1204 
    1205 static char *kOCCppRdOptRemove(PKOCCPPRD pCppRd, char *pszStart, size_t cbRemove)
    1206 {
    1207     size_t offStart = pszStart - pCppRd->pszBuf;
    1208     size_t cbToMove = pCppRd->offRead - offStart;
    1209 
    1210     assert(pCppRd->offRead >= offStart);
    1211 
    1212     g_cMemMoves++;
    1213     g_cbMemMoved += cbToMove + 1;
    1214     memmove(pszStart, pszStart + cbRemove, cbToMove + 1);
    1215 
    1216     pCppRd->offRead -= cbRemove;
    1217     assert(offStart >= pCppRd->offCur);
    1218     assert(pCppRd->offRead < 1 || pCppRd->pszBuf[pCppRd->offRead - 1] != '\0');
    1219     return pszStart;
    1220 }
    1221 
    1222 
    1223 static size_t kOCCppRdOptReplace(PKOCCPPRD pCppRd, size_t offStart, size_t cchReplaced,
    1224                                  const char *pchReplacement, size_t cchReplacement)
    1225 {
    1226     size_t offDelta = cchReplacement - cchReplaced;
    1227 
    1228     if (offDelta)
    1229     {
    1230         size_t cbToMove = pCppRd->offRead - offStart - cchReplaced;
    1231         assert(cbToMove <= pCppRd->offRead);
    1232 
    1233         if (cchReplacement > cchReplaced)
    1234             while (pCppRd->offRead + offDelta >= pCppRd->cbBufAlloc)
    1235                 kOCCppRdGrowBuffer(pCppRd);
     1229    return pCppRd->cbBufAlloc - pCppRd->offSrcRead;
     1230}
     1231
     1232
     1233static size_t kOCCppRdOptInsert(PKOCCPPRD pCppRd, size_t cchSrcReplaced, const char *pchInsert, size_t cchInsert)
     1234{
     1235    size_t offDelta = 0;
     1236    size_t cchAvail;
     1237
     1238    pCppRd->offSrcUnoptimized += cchSrcReplaced;
     1239    assert(pCppRd->offSrcUnoptimized <= pCppRd->offSrcCur);
     1240    cchAvail = pCppRd->offSrcUnoptimized - pCppRd->cchDstOptimized;
     1241    if (cchAvail < cchInsert)
     1242    {
     1243        size_t const cbToMove = pCppRd->offSrcRead - pCppRd->offSrcUnoptimized;
     1244        assert(cbToMove <= pCppRd->offSrcRead);
     1245        offDelta = cchInsert - cchAvail;
     1246
     1247        while (pCppRd->offSrcRead + offDelta >= pCppRd->cbBufAlloc)
     1248            kOCCppRdGrowBuffer(pCppRd);
    12361249
    12371250        g_cMemMoves++;
    12381251        g_cbMemMoved += cbToMove + 1;
    1239         memmove(pCppRd->pszBuf + offStart + cchReplacement,
    1240                 pCppRd->pszBuf + offStart + cchReplaced,
     1252        memmove(pCppRd->pszBuf + pCppRd->offSrcUnoptimized + offDelta,
     1253                pCppRd->pszBuf + pCppRd->offSrcUnoptimized,
    12411254                cbToMove + 1);
    12421255
    1243         pCppRd->offRead += offDelta;
    1244         if (pCppRd->offCur > offStart)
    1245         {
    1246             assert(pCppRd->offCur >= offStart + cchReplaced);
    1247             pCppRd->offCur += offDelta;
    1248         }
    1249         assert(pCppRd->offRead < 1 || pCppRd->pszBuf[pCppRd->offRead - 1] != '\0');
    1250     }
    1251 
    1252     memcpy(pCppRd->pszBuf + offStart, pchReplacement, cchReplacement);
     1256        pCppRd->offSrcRead += offDelta;
     1257        pCppRd->offSrcUnoptimized += offDelta;
     1258        pCppRd->offSrcCur += offDelta;
     1259        assert(pCppRd->offSrcRead < 1 || pCppRd->pszBuf[pCppRd->offSrcRead - 1] != '\0');
     1260    }
     1261
     1262    memcpy(pCppRd->pszBuf + pCppRd->cchDstOptimized, pchInsert, cchInsert);
     1263    pCppRd->cchDstOptimized += cchInsert;
    12531264
    12541265    return offDelta;
     
    12561267
    12571268
    1258 static void kOCCppRdOptCommitEx(PKOCCPPRD pCppRd, size_t offCur)
    1259 {
    1260     pCppRd->cchOptimized = offCur;
    1261     pCppRd->uOptLineNo = pCppRd->uCurLineNo;
    1262 }
    1263 
    1264 
    12651269static void kOCCppRdOptCommit(PKOCCPPRD pCppRd)
    12661270{
    1267     pCppRd->cchOptimized = pCppRd->offCur;
     1271    size_t cchToCommit = pCppRd->offSrcCur - pCppRd->offSrcUnoptimized;
     1272    assert(pCppRd->offSrcUnoptimized <= pCppRd->offSrcCur);
     1273
     1274    if (cchToCommit)
     1275    {
     1276        memmove(pCppRd->pszBuf + pCppRd->cchDstOptimized, pCppRd->pszBuf + pCppRd->offSrcUnoptimized, cchToCommit);
     1277        pCppRd->cchDstOptimized += cchToCommit;
     1278        pCppRd->offSrcUnoptimized = pCppRd->offSrcCur;
     1279    }
     1280
    12681281    pCppRd->uOptLineNo = pCppRd->uCurLineNo;
    12691282}
     
    13421355
    13431356
    1344 static char *kOCCppRdOptFlush(PKOCCPPRD pCppRd, char *pszCur, int fLineDirNext)
    1345 {
    1346     size_t const cchOptimized = pCppRd->cchOptimized;
    1347     size_t const offTmp = pszCur - pCppRd->pszBuf;
    1348     assert(offTmp >= cchOptimized);
    1349     if (pCppRd->offCur > cchOptimized)
     1357static size_t kOCCppRdOptFlush(PKOCCPPRD pCppRd, size_t offSrcCur, int fLineDirNext)
     1358{
     1359    size_t offDelta = 0;
     1360    size_t const offSrcUnoptimized = pCppRd->offSrcUnoptimized;
     1361    assert(offSrcUnoptimized <= offSrcCur);
     1362
     1363    if (offSrcCur > offSrcUnoptimized)
    13501364    {
    13511365        /*
    13521366         * We've got unflushed whitelines.
    13531367         */
    1354         size_t const cchInQuestion = pCppRd->offCur - cchOptimized;
     1368        size_t const cchSrcInQuestion = offSrcCur - offSrcUnoptimized;
    13551369        uint32_t const cLinesInQuestion = pCppRd->uCurLineNo - pCppRd->uOptLineNo;
    13561370        size_t cchLineDir;
    1357         size_t offDelta;
    13581371
    13591372        if (   cLinesInQuestion <= 7
     
    13611374            cchLineDir = kOCCppRdOptFmtNewLines(pCppRd, cLinesInQuestion);
    13621375
    1363         offDelta = kOCCppRdOptReplace(pCppRd, cchOptimized, cchInQuestion, pCppRd->pszLineBuf, cchLineDir);
    1364         pszCur += offDelta;
    1365 
    1366         kOCCppRdOptCommitEx(pCppRd, cchOptimized + cchLineDir);
    1367         /* pCppRd->offCur is adjusted by the replace call */
     1376        offDelta = kOCCppRdOptInsert(pCppRd, cchSrcInQuestion, pCppRd->pszLineBuf, cchLineDir);
    13681377    }
    13691378
    13701379    (void)fLineDirNext; /* Use later if required. */
    1371     return pszCur;
     1380    return offDelta;
    13721381}
    13731382
     
    14671476static char *kOCCppRdOptHandleLine(PKOCCPPRD pCppRd, char *pszCur, size_t *pcbLeft, int *pfEmptyLine, char *pszEol)
    14681477{
    1469     size_t const cchEol = pszEol - pszCur;
     1478    size_t const offSrcLine = pCppRd->offSrcCur;
     1479    size_t const cchSrcLine = pszEol - pCppRd->pszBuf - pCppRd->offSrcCur;
     1480    size_t const cbLeftAssert = *pcbLeft;
    14701481    char *pszNewFile;
    14711482    size_t cchNewFile;
     
    14731484    assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
    14741485
     1486    /* Advance to the end of the line before we do anything.  This can be a
     1487       little confusing but it saves effort and avoid trouble in the end. */
     1488    pCppRd->offSrcCur = pszEol - pCppRd->pszBuf;
     1489    *pcbLeft -= pszEol - pszCur;
     1490    assert(*pcbLeft <= cbLeftAssert); (void)cbLeftAssert;
     1491
     1492    /*
     1493     * Try parse the directive a '#line' one....
     1494     */
    14751495    if (!kOCCppRdOptParseLine(pCppRd, pszCur, pszEol, &uNewLineNo, &pszNewFile, &cchNewFile))
    14761496    {
     
    14791499         * the line isn't empty and needs to be commited at EOL.
    14801500         */
    1481         pszEol = kOCCppRdOptFlush(pCppRd, pszEol, 0);
     1501        kOCCppRdOptFlush(pCppRd, offSrcLine, 0);
    14821502        *pfEmptyLine = 0;
    14831503    }
     
    15001520                 * the file and emit another directive for starting the new one.
    15011521                 */
    1502                 size_t const cchOrgLine = pszEol - pCppRd->pszBuf - pCppRd->offCur;
    15031522                size_t cchLineDir;
    1504                 pszEol = kOCCppRdOptFlush(pCppRd, pszEol, 1);
     1523                kOCCppRdOptFlush(pCppRd, offSrcLine, 1);
    15051524
    15061525                cchLineDir = kOCCppRdOptFmtLine(pCppRd, uNewLineNo, NULL, 0) - 1; /* sans \n */
    1507 
    1508                 pszEol += kOCCppRdOptReplace(pCppRd, pCppRd->offCur, cchOrgLine,
    1509                                              pCppRd->pszLineBuf, cchLineDir);
     1526                kOCCppRdOptInsert(pCppRd, cchSrcLine, pCppRd->pszLineBuf, cchLineDir);
    15101527
    15111528                *pfEmptyLine = 0;
     
    15171534             * The #line directive changed the file.
    15181535             */
    1519             size_t const cchOrgLine = pszEol - pCppRd->pszBuf - pCppRd->offCur;
    15201536            size_t cchLineDir;
    1521             size_t offDelta;
    1522             assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
    1523 
    1524             offDelta = kOCCppRdOptFlush(pCppRd, pszEol, 1) - pszEol;
    1525             pszEol += offDelta;
    1526             pszNewFile += offDelta;
    1527             assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
    1528 
    1529             kOCCppRdOptSetFile(pCppRd, pszNewFile, cchNewFile);
    1530             cchLineDir = kOCCppRdOptFmtLine(pCppRd, uNewLineNo, pszNewFile, cchNewFile) - 1; /* sans \n */
    1531             assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
    1532 
    1533             pszEol += kOCCppRdOptReplace(pCppRd, pCppRd->offCur, cchOrgLine,
    1534                                          pCppRd->pszLineBuf, cchLineDir);
    1535             assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
     1537
     1538            kOCCppRdOptSetFile(pCppRd, pszNewFile, cchNewFile); /* save to do this early */
     1539            kOCCppRdOptFlush(pCppRd, offSrcLine, 1);
     1540
     1541            cchLineDir = kOCCppRdOptFmtLine(pCppRd, uNewLineNo, pCppRd->pszFileNmBuf, cchNewFile) - 1; /* sans \n */
     1542            kOCCppRdOptInsert(pCppRd, cchSrcLine, pCppRd->pszLineBuf, cchLineDir);
     1543
     1544            if (pCppRd->pDepState)
     1545                kOCDepEnter(pCppRd->pDepState, pCppRd->pszFileNmBuf, cchNewFile);
    15361546
    15371547            *pfEmptyLine = 0;
     
    15391549
    15401550        pCppRd->uCurLineNo = uNewLineNo - 1;
    1541         assert(*pszEol == '\r' || *pszEol == '\n' || *pszEol == '\0');
    1542     }
    1543 
    1544     pCppRd->offCur = pszEol - pCppRd->pszBuf;
    1545     *pcbLeft -= cchEol;
    1546     return pszEol;
     1551    }
     1552
     1553    return pCppRd->pszBuf + pCppRd->offSrcCur;
    15471554}
    15481555
     
    15521559    size_t cch;
    15531560    char *pszEol;
    1554     char *pszCur = pCppRd->pszBuf + pCppRd->offCur;
    1555     size_t cbTodo = pCppRd->offRead - pCppRd->offCur;
     1561    char *pszCur = pCppRd->pszBuf + pCppRd->offSrcCur;
     1562    size_t cbTodo = pCppRd->offSrcRead - pCppRd->offSrcCur;
    15561563    int fEmptyLine = 1;
    15571564
     
    15651572
    15661573            case '\n':
    1567                 pCppRd->offCur = pszCur - pCppRd->pszBuf + 1;
     1574                pCppRd->offSrcCur = pszCur - pCppRd->pszBuf + 1;
    15681575                pCppRd->uCurLineNo++;
    15691576                if (!fEmptyLine)
    15701577                    kOCCppRdOptCommit(pCppRd);
    1571                 else
    1572                     pCppRd->cEmptyLines++;
    15731578                fEmptyLine = 1;
    15741579                break;
    15751580
    15761581            case '\r': /* "\r\n" -> "\n" */
    1577                 if (cbTodo == 1 && !pCppRd->fDone)
     1582                if (cbTodo <= 1 && !pCppRd->fDone)
    15781583                    return;
    1579                 if (pszCur[1] == '\n')
     1584                if (pszCur[1] == '\n' && !fEmptyLine)
    15801585                {
    1581                     pszCur = kOCCppRdOptRemove(pCppRd, pszCur, 1);
    1582                     cbTodo -= 1;
     1586                    /* Commit the part up to the '\r' first, replace '\r\n' with '\n'. */
     1587                    pCppRd->offSrcCur = pszCur - pCppRd->pszBuf;
     1588                    kOCCppRdOptCommit(pCppRd);
     1589
     1590                    pCppRd->offSrcCur += 2;
     1591                    kOCCppRdOptInsert(pCppRd, 2, "\n", 1);
     1592
     1593                    assert(cbTodo >= 2);
     1594                    cbTodo -= 2;
     1595                    pszCur += 2;
     1596
     1597                    fEmptyLine = 1;
    15831598                    continue;
    15841599                }
     
    16031618                cch = pszEol - pszCur;
    16041619
    1605                 pszCur = kOCCppRdOptFlush(pCppRd, pszCur, 0);
    1606 
     1620                pszCur += kOCCppRdOptFlush(pCppRd, pCppRd->offSrcCur, 0);
     1621
     1622                assert(cch <= cbTodo);
    16071623                cbTodo -= cch;
    16081624                pszCur += cch;
     
    16191635{
    16201636    pCppRd->fDone = 1;
    1621     assert(pCppRd->offRead < 1 || pCppRd->pszBuf[pCppRd->offRead - 1] != '\0');
    1622     pCppRd->pszBuf[pCppRd->offRead] = '\0';
     1637    assert(pCppRd->offSrcRead < 1 || pCppRd->pszBuf[pCppRd->offSrcRead - 1] != '\0');
     1638    pCppRd->pszBuf[pCppRd->offSrcRead] = '\0';
    16231639    kOCCppRdOpt(pCppRd);
    1624     kOCCppRdOptFlush(pCppRd, pCppRd->pszBuf + pCppRd->offCur, 0);
     1640
     1641    assert(pCppRd->offSrcCur == pCppRd->offSrcRead);
     1642    kOCCppRdOptFlush(pCppRd, pCppRd->offSrcCur, 0);
    16251643}
    16261644
     
    16501668         * Optimize the C preprocessor output on the way thru.
    16511669         */
    1652         size_t const cchOldOptimized = pCppRd->cchOptimized;
     1670        size_t const cchOldOptimized = pCppRd->cchDstOptimized;
    16531671        if (pCppRd->chSaved)
    1654             pCppRd->pszBuf[pCppRd->cchOptimized] = pCppRd->chSaved;
     1672            pCppRd->pszBuf[pCppRd->cchDstOptimized] = pCppRd->chSaved;
    16551673
    16561674        do
    16571675        {
    16581676            /* Read more raw C preprocessor output. */
    1659             cbLeft = pCppRd->cbBufAlloc - pCppRd->offRead;
     1677            cbLeft = pCppRd->cbBufAlloc - pCppRd->offSrcRead;
    16601678            if (cbLeft <= 1)
    16611679                cbLeft = kOCCppRdGrowBuffer(pCppRd);
    1662             if (cbLeft > 256*1024)
    1663                 cbLeft = 256*1024;  /* memmove() get's expensive if there is to much to work on - bad algorithm! */
    16641680
    16651681            do
    1666                 cbRead = read(fdIn, pCppRd->pszBuf + pCppRd->offRead, (long)(cbLeft - 1));
     1682                cbRead = read(fdIn, pCppRd->pszBuf + pCppRd->offSrcRead, (long)(cbLeft - 1));
    16671683            while (cbRead < 0 && errno == EINTR);
    16681684            if (cbRead < 0)
    16691685                FatalDie("kOCCppRdRead - read(%d,,%ld) failed: %s\n",
    16701686                         fdIn, (long)(cbLeft - 1), strerror(errno));
    1671             pCppRd->offRead += cbRead;
     1687            pCppRd->offSrcRead += cbRead;
    16721688
    16731689            /* Optimize it. */
     
    16781694            }
    16791695            kOCCppRdOpt(pCppRd);
    1680         } while (pCppRd->cchOptimized == cchOldOptimized);
     1696        } while (pCppRd->cchDstOptimized == cchOldOptimized);
    16811697
    16821698        *ppszRet = &pCppRd->pszBuf[cchOldOptimized];
    1683         pCppRd->chSaved = pCppRd->pszBuf[pCppRd->cchOptimized];
    1684         pCppRd->pszBuf[pCppRd->cchOptimized] = '\0';
    1685         cbRead = (long)(pCppRd->cchOptimized - cchOldOptimized);
     1699        pCppRd->chSaved = pCppRd->pszBuf[pCppRd->cchDstOptimized];
     1700        pCppRd->pszBuf[pCppRd->cchDstOptimized] = '\0';
     1701        cbRead = (long)(pCppRd->cchDstOptimized - cchOldOptimized);
    16861702    }
    16871703    else
     
    16911707         */
    16921708        char *pszBuf;
    1693         cbLeft = pCppRd->cbBufAlloc - pCppRd->offRead;
     1709        cbLeft = pCppRd->cbBufAlloc - pCppRd->offSrcRead;
    16941710        if (cbLeft <= 1)
    16951711            cbLeft = kOCCppRdGrowBuffer(pCppRd);
    1696         pszBuf = pCppRd->pszBuf + pCppRd->offRead;
     1712        pszBuf = pCppRd->pszBuf + pCppRd->offSrcRead;
    16971713
    16981714        do
     
    17041720
    17051721        *ppszRet = pszBuf;
    1706         pCppRd->offRead += cbRead;
     1722        pCppRd->offSrcRead += cbRead;
    17071723        pszBuf[cbRead] = '\0';
    17081724    }
     
    17211737static void kOCCppRdGrabOutput(PKOCCPPRD pCppRd, char **ppszRet, size_t *pcbRet)
    17221738{
    1723     assert(pCppRd->offRead < 1 || pCppRd->pszBuf[pCppRd->offRead - 1] != '\0');
     1739    assert(pCppRd->offSrcRead < 1 || pCppRd->pszBuf[pCppRd->offSrcRead - 1] != '\0');
    17241740    *ppszRet = pCppRd->pszBuf;
    1725     *pcbRet  = pCppRd->offRead;
     1741    *pcbRet  = pCppRd->fOptimize ? pCppRd->cchDstOptimized : pCppRd->offSrcRead;
    17261742    pCppRd->pszBuf = NULL;
    1727     pCppRd->offRead = 0;
     1743    pCppRd->offSrcRead = 0;
    17281744}
    17291745
     
    29622978            FatalDie("%s - _open_osfhandle failed: %d\n", pszMsg, strerror(errno));
    29632979    }
    2964     else if (   _pipe(paFDs, 256*1024, _O_NOINHERIT | (fText ? _O_BINARY : _O_TEXT)) < 0
    2965              && _pipe(paFDs,        0, _O_NOINHERIT | (fText ? _O_BINARY : _O_TEXT)) < 0)
     2980    else if (   _pipe(paFDs, 256*1024, _O_NOINHERIT | (fText ? _O_TEXT : _O_BINARY)) < 0
     2981             && _pipe(paFDs,        0, _O_NOINHERIT | (fText ? _O_TEXT : _O_BINARY)) < 0)
    29662982#else
    29672983    if (pipe(paFDs) < 0)
     
    31283144
    31293145    kOCSumInitWithCtx(&pEntry->New.SumHead, &Ctx);
    3130     kOCCppRdInit(&CppRd, pEntry->Old.cbCpp, pEntry->fOptimizeCpp);
     3146    kOCCppRdInit(&CppRd, pEntry->Old.cbCpp, pEntry->fOptimizeCpp,
     3147                 pEntry->pszMakeDepFilename ? &pEntry->DepState : NULL);
    31313148
    31323149    for (;;)
     
    31443161         */
    31453162        kOCSumUpdate(&pEntry->New.SumHead, &Ctx, psz, cbRead);
    3146         if (pEntry->pszMakeDepFilename)
     3163        if (pEntry->pszMakeDepFilename && !pEntry->fOptimizeCpp)
    31473164            kOCDepConsumer(&pEntry->DepState, psz, cbRead);
    31483165    }
     
    33823399
    33833400    kOCSumInitWithCtx(&pEntry->New.SumHead, &Ctx);
    3384     kOCCppRdInit(&CppRd, pEntry->Old.cbCpp, pEntry->fOptimizeCpp);
     3401    kOCCppRdInit(&CppRd, pEntry->Old.cbCpp, pEntry->fOptimizeCpp,
     3402                 pEntry->pszMakeDepFilename ? &pEntry->DepState : NULL);
    33853403    InfoMsg(3, "preprocessor|compile - starting passhtru...\n");
    33863404    for (;;)
     
    33993417         */
    34003418        kOCSumUpdate(&pEntry->New.SumHead, &Ctx, psz, cbRead);
    3401         if (pEntry->pszMakeDepFilename)
     3419        if (pEntry->pszMakeDepFilename && !pEntry->fOptimizeCpp)
    34023420            kOCDepConsumer(&pEntry->DepState, psz, cbRead);
    34033421
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