Changeset 1488


Ignore:
Timestamp:
Sep 10, 2004, 9:39:57 AM (21 years ago)
Author:
bird
Message:

Going to bed. something is still broken.

Location:
trunk/src/emx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/386/builtin.h

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1487 r1488  
    299299
    300300
     301/**
     302 * Atomically compare and exchange a 32-bit word.
     303 *
     304 * @returns 1 if changed, 0 if unchanged (i.e. boolean).
     305 * @param   pu32    Pointer to the value to compare & exchange.
     306 * @param   u32New  The new value.
     307 * @param   u32Cur  The current value. Only update if *pu32 equals this one.
     308 */
     309static inline unsigned __atomic_cmpxchg32(volatile uint32_t *pu32, uint32_t u32New, uint32_t u32Old)
     310{
     311    __asm__ __volatile__("lock  cmpxchgl %2, %1\n\t"
     312                         "setz  %%al\n\t"
     313                         "movzx %%al, %%eax\n\t"
     314                         : "=a" (u32Old),
     315                           "=m" (*pu32)
     316                         : "r"  (u32New),
     317                           "0" (u32Old));
     318    return (unsigned)u32Old;
     319}
     320
     321
    301322#define __ROTATE_FUN(F,I,T) \
    302323  static __inline__ T F (T value, int shift) \
  • trunk/src/emx/src/lib/sys/__spawnve.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1487 r1488  
    1414#include <emx/syscalls.h>
    1515#include <InnoTekLIBC/sharedpm.h>
     16#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_PROCESS
     17#include <InnoTekLIBC/logstrict.h>
    1618#include "syscalls.h"
    1719
     
    2426static __LIBC_PSPMINHERIT doInherit(void)
    2527{
     28    LIBCLOG_ENTER("\n");
    2629    size_t                  cbFH;
    2730    __LIBC_PSPMINHFHBHDR    pFH;
     
    4548            memcpy(pRet->pFHBundles, pFH, cbFH);
    4649            free(pFH);
    47             return pRet;
     50            LIBCLOG_RETURN_P(pRet);
    4851        }
    4952        /* cleanup on failure */
     
    5255    }
    5356
    54     return pRet;
     57    LIBCLOG_RETURN_P(pRet);
    5558}
    5659
     
    8487int __spawnve (struct _new_proc *np)
    8588{
    86   ULONG rc;
     89  LIBCLOG_ENTER("np=%p:{mode=%#x}\n", (void *)np, np->mode);
     90  int   rc;
    8791  ULONG exec_flag, mode;
    8892  RESULTCODES res;
     
    111115    default:
    112116      errno = EINVAL;
    113       return -1;
     117      LIBCLOG_RETURN_INT(-1);
    114118    }
    115119  pgm_name = alloca (strlen ((const char *)np->fname_off) + 5);
     
    217221          if (!rc)
    218222          {
     223              if (exec_flag == EXEC_ASYNCRESULT || exec_flag == EXEC_ASYNC)
     224              {
     225                  __atomic_cmpxchg32((volatile uint32_t *)(void *)&pEmbryo->pid, (uint32_t)res.codeTerminate, 0);
     226                  LIBCLOG_MSG("Spawned pid=%04lx (%ld)\n", res.codeTerminate, res.codeTerminate);
     227              }
     228
    219229              /* cleanup embryo and other stuff. */
    220230              __libc_spmRelease(pEmbryo);
     
    228238                {
    229239                case P_WAIT:
    230                   return res.codeResult;
     240                  LIBCLOG_RETURN_INT((int)res.codeResult);
    231241                case P_NOWAIT:
    232                   return res.codeTerminate;
     242                  LIBCLOG_RETURN_INT((int)res.codeTerminate);
    233243                case P_OVERLAY:
    234244                  FS_SAVE_LOAD();
     245                #if 1 /* hack... */
     246                {
     247                  PID pid = res.codeTerminate;
     248                  for (;;)
     249                  {
     250                      PID   pidEnded = 0;
     251                      LIBCLOG_MSG("Calling DosWaitChild(,,,,0x%04lx)\n", pid);
     252                      rc = DosWaitChild(DCWA_PROCESS, DCWW_WAIT, &res, &pidEnded, pid);
     253                      if (rc)
     254                      {
     255                          LIBCLOG_MSG("Calling DosWaitChild(,,,,0x%04lx) -> rc=%d\n", pid, rc);
     256                          break;
     257                      }
     258                      LIBCLOG_MSG("Calling DosWaitChild(,,,,0x%04lx) pidEnded=0x%04lx res.codeTerminate=%ld res.codeResult=%ld\n",
     259                                  pid, pidEnded, res.codeTerminate, res.codeResult);
     260                      while (pid == pidEnded)
     261                          DosExit(EXIT_PROCESS, res.codeResult);
     262                  }
     263                }
     264                #endif
     265                  LIBCLOG_MSG("Calling DosExit(,0)\n");
    235266                  while (1)
    236267                    DosExit (EXIT_PROCESS, 0);
    237268                default:
    238269                  errno = EINVAL;
    239                   return -1;
     270                  LIBCLOG_RETURN_INT(-1);
    240271                }
    241272              /* won't ever get here! */
     
    252283    _tfree (arg_buf);
    253284  _fmutex_release(&__libc_gmtxExec);
    254   return -1;
     285  LIBCLOG_RETURN_INT(-1);
    255286}
  • trunk/src/emx/src/lib/sys/filehandles.c

    • Property cvs2svn:cvs-rev changed from 1.11 to 1.12
    r1487 r1488  
    141141     */
    142142    pInherit = __libc_spmInheritRequest();
    143     if (!pInherit || pInherit->pFHBundles)
     143    if (!pInherit || !pInherit->pFHBundles)
    144144    {
    145145        /*
     
    151151         *      for usage validation in any of LIBC apis.
    152152         */
     153        if (pInherit)
     154            __libc_spmInheritRelease();
    153155        if (cMaxFHs > 3)
    154156            cMaxFHs = 3;
  • trunk/src/emx/src/lib/sys/libcfork.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1487 r1488  
    636636                    pForkHandle->enmStage           = __LIBC_FORK_STAGE_PRE_EXEC;
    637637
    638                     LIBCLOG_MSG("Created fork handle %p of size %d and buffer size %d\n", (void *)pForkHandle, pForkHandle->cb, pForkHandle->cbBuf);
     638                    LIBCLOG_MSG("Created fork handle %p of size %d and buffer size %d; hmtx=%08lx hevParent=%08lx hevChild=%08lx\n",
     639                                (void *)pForkHandle, pForkHandle->cb, pForkHandle->cbBuf,
     640                                pForkHandle->hmtx, pForkHandle->hevParent, pForkHandle->hevChild);
    639641                    LIBCLOG_RETURN_P(pForkHandle);
    640642                }
     
    678680    LIBCLOG_ENTER("pForkHandle=%p pModules=%p\n", (void *)pForkHandle, (void *)pModules);
    679681    int rc = forkBthProcessModules(pForkHandle, pModules, __LIBC_FORK_OP_EXEC_PARENT);
    680     LIBCLOG_MSG("%d bytes of the fork buffer was used during EXEC_PARENT.\n", pForkHandle->cbBufLeft);
     682    LIBCLOG_MSG("%d bytes of the fork buffer was used during EXEC_PARENT.\n", pForkHandle->cbBuf - pForkHandle->cbBufLeft);
    681683    LIBCLOG_RETURN_INT(rc);
    682684}
     
    746748        if (!rc)
    747749        {
     750            __atomic_cmpxchg32((volatile uint32_t *)(void *)&pProcessChild->pid, (uint32_t)rsc.codeTerminate, 0);
     751
    748752            *ppid = rsc.codeTerminate;
    749753            pForkHandle->fFlushable = 1;
     754            LIBCLOG_MSG("DosExecPgm created process 0x%04x (%d); pidChild=0x%04x\n", *ppid, *ppid, pForkHandle->pidChild);
    750755
    751756            /*
     
    756761            {
    757762                int fNext = 0;
     763                LIBC_ASSERTM(pForkHandle->pidChild == *ppid,
     764                             "Invalid child process id! pidChild=%04x *ppid=%04x\n", pForkHandle->pidChild, *ppid);
    758765                rc = forkBthBufferProcess(pForkHandle, __LIBC_FORK_CTX_PARENT, &fNext);
    759766                if (!rc && !fNext)
     
    773780    }
    774781
     782#if 1
     783    if (pProcessChild->enmState == __LIBC_PROCSTATE_EMBRYO)
     784    {
     785        LIBCLOG_MSG("The embryo %p wasn't used. pNext=%p pPrev=%p\n", (void *)pProcessChild,
     786                    (void *)pProcessChild->pNext, (void *)pProcessChild->pPrev);
     787        __libc_SpmCheck(0, 1);
     788    }
     789#endif
    775790    __libc_spmRelease(pProcessChild);
    776791    LIBCLOG_RETURN_INT(rc);
     
    812827                    if (!rc)
    813828                    {
    814                         /* succesfully opened the handle for the first time. */
     829                        /*
     830                         * Succesfully opened the handle for the first time.
     831                         * Set the pidChild.
     832                         */
     833                        PTIB pTib;
     834                        PPIB pPib;
     835                        DosGetInfoBlocks(&pTib, &pPib);
     836                        pForkHandle->pidChild = pPib->pib_ulpid;
     837                        LIBC_ASSERTM(pForkHandle->pidParent == pPib->pib_ulppid,
     838                                     "Invalid parent pid... pidParent=%04x pib_ulppid=%04lx (pib_ulpid=%04lx).\n",
     839                                     pForkHandle->pidParent, pPib->pib_ulppid, pPib->pib_ulpid);
    815840                        LIBCLOG_RETURN_P(pForkHandle);
    816841                    }
  • trunk/src/emx/src/lib/sys/logstrict.c

    • Property cvs2svn:cvs-rev changed from 1.11 to 1.12
    r1487 r1488  
    257257                                 (unsigned)pPib->pib_hmte);
    258258        DosWrite(pInst->hFile, pszMsg, cch, &cb);
    259         if (DosQueryModuleName(pPib->pib_hmte, sizeof(pszMsg), pszMsg))
     259        if (DosQueryModuleName(pPib->pib_hmte, CCHTMPMSGBUFFER, pszMsg))
    260260            pszMsg[0] = '\0';
    261261        cch = strlen(pszMsg);
    262         DosWrite(pInst->hFile, pszMsg, cch, &cb);
    263262        pszMsg[cch++] = ')';
    264263        pszMsg[cch++] = '\n';
     
    273272        cch = strlen(psz);
    274273        DosWrite(pInst->hFile, psz, cch, &cb);
    275         DosWrite(pInst->hFile, "\n", 1, &cb);
    276 
     274
     275        char    szMod[CCHMAXPATH];
     276        ULONG   iObj = ~0;
     277        ULONG   offObj = ~0;
     278        HMODULE hmod = ~0;
     279        if (DosQueryModFromEIP(&hmod, &iObj, sizeof(szMod), &szMod[0], &offObj, (uintptr_t)__libc_logInit))
     280            szMod[0] = '\0';
    277281        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    278282                                 "\n"
     283                                 "CRT Module: %s hmod=%#lx\n"
     284                                 "__libc_logInit: addr %p iObj=%ld offObj=%#lx\n",
     285                                 szMod, hmod, (void *)__libc_logInit, iObj, offObj);
     286        DosWrite(pInst->hFile, pszMsg, cch, &cb);
     287
     288
     289        cch = __libc_logSNPrintf(pszMsg, CCHTMPMSGBUFFER,
    279290                                 "   Millsecond Timestamp.\n"
    280291                                 "   |     Thread ID.\n"
     
    15641575
    15651576
    1566 /**
    1567  * Partial vsprintf implementation.
     1577
     1578/**
     1579 * __libc_logVSNPrintf worker.
    15681580 *
    15691581 * @returns number of bytes formatted.
     
    15731585 * @param   args        Argument list.
    15741586 */
    1575 static int      __libc_logVSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
    1576 {
    1577     int             rc;
    1578     char           *pszBufferIn = pszBuffer;
    1579     size_t          cchBufferIn = cchBuffer;
    1580     const char     *pszFormatIn = pszFormat;
    1581     unsigned        cch = 0;
    1582     __LIBC_XCPTREG  XcptRegRec = { { (void *)-1, __libc_logXcptHandler }, };
    1583     FS_VAR();
    1584 
    1585     FS_SAVE_LOAD();
    1586     DosSetExceptionHandler(&XcptRegRec.RegRec);
    1587     rc = setjmp(XcptRegRec.jmp);
    1588     if (!rc)
    1589     {
    1590         while (*pszFormat != '\0' && cchBuffer)
     1587static int      __libc_logVSNPrintfInt(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
     1588{
     1589    int cch = 0;
     1590    while (*pszFormat != '\0' && cchBuffer)
     1591    {
     1592        if (*pszFormat == '%')
    15911593        {
    1592             if (*pszFormat == '%')
     1594            pszFormat++;  /* skip '%' */
     1595            if (*pszFormat == '%')    /* '%%'-> '%' */
    15931596            {
    1594                 pszFormat++;  /* skip '%' */
    1595                 if (*pszFormat == '%')    /* '%%'-> '%' */
     1597                *pszBuffer++ = '%';
     1598                cchBuffer--;
     1599                pszFormat++;
     1600                cch++;
     1601            }
     1602            else
     1603            {
     1604                unsigned int fFlags = 0;
     1605                int          cchWidth = -1;
     1606                int          cchPrecision = -1;
     1607                unsigned int uiBase = 10;
     1608                char         chArgSize;
     1609
     1610                /* flags */
     1611                for (;;)
    15961612                {
    1597                     *pszBuffer++ = '%';
    1598                     cchBuffer--;
     1613                    switch (*pszFormat++)
     1614                    {
     1615                        case '#':   fFlags |= NTSF_SPECIAL; continue;
     1616                        case '-':   fFlags |= NTSF_LEFT; continue;
     1617                        case '+':   fFlags |= NTSF_PLUS; continue;
     1618                        case ' ':   fFlags |= NTSF_BLANK; continue;
     1619                        case '0':   fFlags |= NTSF_ZEROPAD; continue;
     1620                    }
     1621                    pszFormat--;
     1622                    break;
     1623                }
     1624                /* width */
     1625                if (ISDIGIT(*pszFormat))
     1626                {
     1627                    for (cchWidth = 0; ISDIGIT(*pszFormat); pszFormat++)
     1628                    {
     1629                        cchWidth *= 10;
     1630                        cchWidth += *pszFormat - '0';
     1631                    }
     1632                }
     1633                else if (*pszFormat == '*')
     1634                {
    15991635                    pszFormat++;
    1600                     cch++;
     1636                    cchWidth = va_arg(args, int);
     1637                    if (cchWidth < 0)
     1638                    {
     1639                        cchWidth = -cchWidth;
     1640                        fFlags |= NTSF_LEFT;
     1641                    }
    16011642                }
    1602                 else
     1643
     1644                /* precision */
     1645                if (*pszFormat == '.')
    16031646                {
    1604                     unsigned int fFlags = 0;
    1605                     int          cchWidth = -1;
    1606                     int          cchPrecision = -1;
    1607                     unsigned int uiBase = 10;
    1608                     char         chArgSize;
    1609 
    1610                     /* flags */
    1611                     for (;;)
    1612                     {
    1613                         switch (*pszFormat++)
    1614                         {
    1615                             case '#':   fFlags |= NTSF_SPECIAL; continue;
    1616                             case '-':   fFlags |= NTSF_LEFT; continue;
    1617                             case '+':   fFlags |= NTSF_PLUS; continue;
    1618                             case ' ':   fFlags |= NTSF_BLANK; continue;
    1619                             case '0':   fFlags |= NTSF_ZEROPAD; continue;
    1620                         }
    1621                         pszFormat--;
    1622                         break;
    1623                     }
    1624                     /* width */
     1647                    pszFormat++;
    16251648                    if (ISDIGIT(*pszFormat))
    16261649                    {
    1627                         for (cchWidth = 0; ISDIGIT(*pszFormat); pszFormat++)
     1650                        for (cchPrecision = 0; ISDIGIT(*pszFormat); pszFormat++)
    16281651                        {
    1629                             cchWidth *= 10;
    1630                             cchWidth += *pszFormat - '0';
     1652                            cchPrecision *= 10;
     1653                            cchPrecision += *pszFormat - '0';
    16311654                        }
     1655
    16321656                    }
    16331657                    else if (*pszFormat == '*')
    16341658                    {
    16351659                        pszFormat++;
    1636                         cchWidth = va_arg(args, int);
    1637                         if (cchWidth < 0)
    1638                         {
    1639                             cchWidth = -cchWidth;
    1640                             fFlags |= NTSF_LEFT;
    1641                         }
     1660                        cchPrecision = va_arg(args, int);
    16421661                    }
    1643 
    1644                     /* precision */
    1645                     if (*pszFormat == '.')
     1662                    if (cchPrecision < 0)
     1663                        cchPrecision = 0;
     1664                }
     1665
     1666                /* argsize */
     1667                chArgSize = *pszFormat;
     1668                if (chArgSize != 'l' && chArgSize != 'L' && chArgSize != 'H')
     1669                    chArgSize = 0;
     1670                else if (*++pszFormat == 'l' && chArgSize == 'l')
     1671                {
     1672                    chArgSize = 'L';
     1673                    pszFormat++;
     1674                }
     1675
     1676                /* type */
     1677                switch (*pszFormat++)
     1678                {
     1679                    /* char */
     1680                    case 'c':
    16461681                    {
    1647                         pszFormat++;
    1648                         if (ISDIGIT(*pszFormat))
    1649                         {
    1650                             for (cchPrecision = 0; ISDIGIT(*pszFormat); pszFormat++)
    1651                             {
    1652                                 cchPrecision *= 10;
    1653                                 cchPrecision += *pszFormat - '0';
    1654                             }
    1655 
    1656                         }
    1657                         else if (*pszFormat == '*')
    1658                         {
    1659                             pszFormat++;
    1660                             cchPrecision = va_arg(args, int);
    1661                         }
    1662                         if (cchPrecision < 0)
    1663                             cchPrecision = 0;
    1664                     }
    1665 
    1666                     /* argsize */
    1667                     chArgSize = *pszFormat;
    1668                     if (chArgSize != 'l' && chArgSize != 'L' && chArgSize != 'H')
    1669                         chArgSize = 0;
    1670                     else if (*++pszFormat == 'l' && chArgSize == 'l')
    1671                     {
    1672                         chArgSize = 'L';
    1673                         pszFormat++;
    1674                     }
    1675 
    1676                     /* type */
    1677                     switch (*pszFormat++)
    1678                     {
    1679                         /* char */
    1680                         case 'c':
    1681                         {
    1682                             char ch;
    1683 
    1684                             if (!(fFlags & NTSF_LEFT))
    1685                                 while (--cchWidth > 0 && cchBuffer)
    1686                                 {
    1687                                     cchBuffer--;
    1688                                     *pszBuffer++ = ' ';
    1689                                     cch++;
    1690                                 }
    1691 
    1692                             ch = (char)va_arg(args, int);
    1693                             if (!cchBuffer)
    1694                                 break;
    1695 
    1696                             cchBuffer--;
    1697                             *pszBuffer++ = ch;
    1698                             cch++;
    1699 
     1682                        char ch;
     1683
     1684                        if (!(fFlags & NTSF_LEFT))
    17001685                            while (--cchWidth > 0 && cchBuffer)
    17011686                            {
     
    17041689                                cch++;
    17051690                            }
    1706                             continue;
     1691
     1692                        ch = (char)va_arg(args, int);
     1693                        if (!cchBuffer)
     1694                            break;
     1695
     1696                        cchBuffer--;
     1697                        *pszBuffer++ = ch;
     1698                        cch++;
     1699
     1700                        while (--cchWidth > 0 && cchBuffer)
     1701                        {
     1702                            cchBuffer--;
     1703                            *pszBuffer++ = ' ';
     1704                            cch++;
    17071705                        }
    1708 
    1709                         case 's':   /* string */
    1710                         {
    1711                             int   cchStr;
    1712                             char *pszStr = va_arg(args, char*);
    1713 
    1714                             if (pszStr < (char*)0x10000)
    1715                                 pszStr = "<NULL>";
    1716                             cchStr = strnlen(pszStr, (unsigned)cchPrecision);
    1717                             if (!(fFlags & NTSF_LEFT))
    1718                                 while (--cchWidth >= cchStr && cchBuffer)
    1719                                 {
    1720                                     cchBuffer--;
    1721                                     *pszBuffer++ = ' ';
    1722                                     cch++;
    1723                                 }
    1724 
    1725                             while (cchStr && cchBuffer)
    1726                             {
    1727                                 cchStr--;
    1728                                 cchBuffer--;
    1729                                 *pszBuffer++ = *pszStr++;
    1730                                 cch++;
    1731                             }
    1732 
     1706                        continue;
     1707                    }
     1708
     1709                    case 's':   /* string */
     1710                    {
     1711                        int   cchStr;
     1712                        char *pszStr = va_arg(args, char*);
     1713
     1714                        if (pszStr < (char*)0x10000)
     1715                            pszStr = "<NULL>";
     1716                        cchStr = strnlen(pszStr, (unsigned)cchPrecision);
     1717                        if (!(fFlags & NTSF_LEFT))
    17331718                            while (--cchWidth >= cchStr && cchBuffer)
    17341719                            {
     
    17371722                                cch++;
    17381723                            }
    1739                             continue;
     1724
     1725                        while (cchStr && cchBuffer)
     1726                        {
     1727                            cchStr--;
     1728                            cchBuffer--;
     1729                            *pszBuffer++ = *pszStr++;
     1730                            cch++;
    17401731                        }
    17411732
    1742                         /*-----------------*/
    1743                         /* integer/pointer */
    1744                         /*-----------------*/
    1745                         case 'd':
    1746                         case 'i':
    1747                         case 'o':
    1748                         case 'p':
    1749                         case 'u':
    1750                         case 'x':
    1751                         case 'X':
    1752                         case 'L':
     1733                        while (--cchWidth >= cchStr && cchBuffer)
    17531734                        {
    1754                             char    achNum[64]; /* FIXME */
    1755                             char   *pszNum;
    1756                             int     cchNum;
    1757 
    1758                             switch (pszFormat[-1])
     1735                            cchBuffer--;
     1736                            *pszBuffer++ = ' ';
     1737                            cch++;
     1738                        }
     1739                        continue;
     1740                    }
     1741
     1742                    /*-----------------*/
     1743                    /* integer/pointer */
     1744                    /*-----------------*/
     1745                    case 'd':
     1746                    case 'i':
     1747                    case 'o':
     1748                    case 'p':
     1749                    case 'u':
     1750                    case 'x':
     1751                    case 'X':
     1752                    case 'L':
     1753                    {
     1754                        char    achNum[64]; /* FIXME */
     1755                        char   *pszNum;
     1756                        int     cchNum;
     1757
     1758                        switch (pszFormat[-1])
     1759                        {
     1760                            case 'd': /* signed decimal integer */
     1761                            case 'i':
     1762                                fFlags |= NTSF_VALSIGNED;
     1763                                break;
     1764
     1765                            case 'o':
     1766                                uiBase = 8;
     1767                                break;
     1768
     1769                            case 'p':
     1770                                fFlags |= NTSF_SPECIAL | NTSF_ZEROPAD; /* Note not standard behaviour (but I like it this way!) */
     1771                                uiBase = 16;
     1772                                if (cchWidth < 0)
     1773                                    cchWidth = sizeof(char *) * 2 + 2;
     1774                                break;
     1775
     1776                            case 'u':
     1777                                uiBase = 10;
     1778                                break;
     1779
     1780                            case 'X':
     1781                                fFlags |= NTSF_CAPITAL;
     1782                            case 'x':
     1783                                uiBase = 16;
     1784                                break;
     1785
     1786                            case 'L':
     1787                                uiBase = 10;
     1788                                chArgSize = 'L';
     1789                                break;
     1790                        }
     1791
     1792                        pszNum = &achNum[0];
     1793                        if (chArgSize == 'L')
     1794                        {
     1795                            unsigned long long ullValue;
     1796                            ullValue = va_arg(args, unsigned long long);
     1797                            cchNum = llnumtostr(pszNum, ullValue, uiBase, cchWidth, cchPrecision, fFlags) - pszNum;
     1798                        }
     1799                        else
     1800                        {
     1801                            unsigned long ulValue;
     1802                            if (pszFormat[-1] == 'p')
     1803                                ulValue = (unsigned long)va_arg(args, char *);
     1804                            else if (chArgSize == 'l')
     1805                                ulValue = va_arg(args, signed long);
     1806                            else if (chArgSize == 'h')
     1807                                ulValue = va_arg(args, signed short);
     1808                            else
     1809                                ulValue = va_arg(args, signed int);
     1810                            cchNum = numtostr(pszNum, ulValue, uiBase, cchWidth, cchPrecision, fFlags) - pszNum;
     1811                        }
     1812
     1813                        for (; cchNum && cchBuffer; cchNum--, cchBuffer--, pszBuffer++, pszNum++, cch++)
     1814                            *pszBuffer = *pszNum;
     1815                        continue;
     1816                    }
     1817
     1818                    /* extensions. */
     1819                    case 'Z':
     1820                    {
     1821                        pszFormat++;
     1822                        switch (*pszFormat++)
     1823                        {
     1824                            /* hex dump */
     1825                            case 'd':
    17591826                            {
    1760                                 case 'd': /* signed decimal integer */
    1761                                 case 'i':
    1762                                     fFlags |= NTSF_VALSIGNED;
    1763                                     break;
    1764 
    1765                                 case 'o':
    1766                                     uiBase = 8;
    1767                                     break;
    1768 
    1769                                 case 'p':
    1770                                     fFlags |= NTSF_SPECIAL | NTSF_ZEROPAD; /* Note not standard behaviour (but I like it this way!) */
    1771                                     uiBase = 16;
    1772                                     if (cchWidth < 0)
    1773                                         cchWidth = sizeof(char *) * 2 + 2;
    1774                                     break;
    1775 
    1776                                 case 'u':
    1777                                     uiBase = 10;
    1778                                     break;
    1779 
    1780                                 case 'X':
    1781                                     fFlags |= NTSF_CAPITAL;
    1782                                 case 'x':
    1783                                     uiBase = 16;
    1784                                     break;
    1785 
    1786                                 case 'L':
    1787                                     uiBase = 10;
    1788                                     chArgSize = 'L';
    1789                                     break;
    1790                             }
    1791 
    1792                             pszNum = &achNum[0];
    1793                             if (chArgSize == 'L')
    1794                             {
    1795                                 unsigned long long ullValue;
    1796                                 ullValue = va_arg(args, unsigned long long);
    1797                                 cchNum = llnumtostr(pszNum, ullValue, uiBase, cchWidth, cchPrecision, fFlags) - pszNum;
    1798                             }
    1799                             else
    1800                             {
    1801                                 unsigned long ulValue;
    1802                                 if (pszFormat[-1] == 'p')
    1803                                     ulValue = (unsigned long)va_arg(args, char *);
    1804                                 else if (chArgSize == 'l')
    1805                                     ulValue = va_arg(args, signed long);
    1806                                 else if (chArgSize == 'h')
    1807                                     ulValue = va_arg(args, signed short);
    1808                                 else
    1809                                     ulValue = va_arg(args, signed int);
    1810                                 cchNum = numtostr(pszNum, ulValue, uiBase, cchWidth, cchPrecision, fFlags) - pszNum;
    1811                             }
    1812 
    1813                             for (; cchNum && cchBuffer; cchNum--, cchBuffer--, pszBuffer++, pszNum++, cch++)
    1814                                 *pszBuffer = *pszNum;
    1815                             continue;
    1816                         }
    1817 
    1818                         /* extensions. */
    1819                         case 'Z':
    1820                         {
    1821                             pszFormat++;
    1822                             switch (*pszFormat++)
    1823                             {
    1824                                 /* hex dump */
    1825                                 case 'd':
     1827                                const char *pb = va_arg(args, const char *);
     1828                                int cb = cchPrecision;
     1829                                if (cb <= 0)
     1830                                    cb = cchWidth;
     1831                                if (cb <= 0)
     1832                                    cb = 4;
     1833                                if (pb < (const char *)0x10000)
    18261834                                {
    1827                                     const char *pb = va_arg(args, const char *);
    1828                                     int cb = cchPrecision;
    1829                                     if (cb <= 0)
    1830                                         cb = cchWidth;
    1831                                     if (cb <= 0)
    1832                                         cb = 4;
    1833                                     if (pb < (const char *)0x10000)
     1835                                    if (cb && cchBuffer >= 2)
    18341836                                    {
    1835                                         if (cb && cchBuffer >= 2)
     1837                                        char ch = *pb++;
     1838                                        *pszBuffer++ = gszHexDigits[(unsigned)ch >> 4];
     1839                                        *pszBuffer++ = gszHexDigits[(unsigned)ch & 0xf];
     1840                                        cb--;
     1841                                        cchBuffer -= 2;
     1842                                        cch += 2;
     1843
     1844                                        while (cb && cchBuffer >= 3)
    18361845                                        {
    1837                                             char ch = *pb++;
     1846                                            ch = *pb++;
     1847                                            cb--;
     1848                                            *pszBuffer++ = ' ';
    18381849                                            *pszBuffer++ = gszHexDigits[(unsigned)ch >> 4];
    18391850                                            *pszBuffer++ = gszHexDigits[(unsigned)ch & 0xf];
    1840                                             cb--;
    1841                                             cchBuffer -= 2;
    1842                                             cch += 2;
    1843 
    1844                                             while (cb && cchBuffer >= 3)
    1845                                             {
    1846                                                 ch = *pb++;
    1847                                                 cb--;
    1848                                                 *pszBuffer++ = ' ';
    1849                                                 *pszBuffer++ = gszHexDigits[(unsigned)ch >> 4];
    1850                                                 *pszBuffer++ = gszHexDigits[(unsigned)ch & 0xf];
    1851                                                 cchBuffer -= 3;
    1852                                                 cch += 3;
    1853                                             }
     1851                                            cchBuffer -= 3;
     1852                                            cch += 3;
    18541853                                        }
    18551854                                    }
    1856                                     else
     1855                                }
     1856                                else
     1857                                {
     1858                                    pb = "<NULL>";
     1859                                    cb = 6;
     1860                                    while (cb && cchBuffer)
    18571861                                    {
    1858                                         pb = "<NULL>";
    1859                                         cb = 6;
    1860                                         while (cb && cchBuffer)
    1861                                         {
    1862                                             *pszBuffer++ = *pb++;
    1863                                             cb--;
    1864                                             cchBuffer--;
    1865                                             cch++;
    1866                                         }
     1862                                        *pszBuffer++ = *pb++;
     1863                                        cb--;
     1864                                        cchBuffer--;
     1865                                        cch++;
    18671866                                    }
    1868                                     break;
    18691867                                }
    1870 
    1871                                 default:
    1872                                     continue;
     1868                                break;
    18731869                            }
     1870
     1871                            default:
     1872                                continue;
    18741873                        }
    1875 
    1876 
    1877                         default:
    1878                             continue;
    18791874                    }
     1875
     1876
     1877                    default:
     1878                        continue;
    18801879                }
    18811880            }
    1882             else
    1883             {
    1884                 *pszBuffer++ = *pszFormat++;
    1885                 cchBuffer--;
    1886                 cch++;
    1887             }
    18881881        }
    1889 
    1890         /*
    1891          * Terminator.
    1892          */
    1893         if (cchBuffer)
    1894             *pszBuffer = '\0';
    1895         else /* Use last buffer entry */
     1882        else
    18961883        {
    1897             pszBuffer[-1] = '\0';
    1898             cch--;
     1884            *pszBuffer++ = *pszFormat++;
     1885            cchBuffer--;
     1886            cch++;
    18991887        }
     1888    }
     1889
     1890    /*
     1891     * Terminator.
     1892     */
     1893    if (cchBuffer)
     1894        *pszBuffer = '\0';
     1895    else /* Use last buffer entry */
     1896    {
     1897        pszBuffer[-1] = '\0';
     1898        cch--;
     1899    }
     1900
     1901    return cch;
     1902}
     1903
     1904
     1905/**
     1906 * Partial vsprintf implementation.
     1907 *
     1908 * @returns number of bytes formatted.
     1909 * @param   pszBuffer   Where to put the the formatted string.
     1910 * @param   cchBuffer   Size of the buffer.
     1911 * @param   pszFormat   Format string.
     1912 * @param   args        Argument list.
     1913 */
     1914static int      __libc_logVSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
     1915{
     1916    int             rc;
     1917    int             cch;
     1918    __LIBC_XCPTREG  XcptRegRec = { { (void *)-1, __libc_logXcptHandler }, };
     1919    FS_VAR();
     1920
     1921    FS_SAVE_LOAD();
     1922    DosSetExceptionHandler(&XcptRegRec.RegRec);
     1923    rc = setjmp(XcptRegRec.jmp);
     1924    if (!rc)
     1925    {
     1926        cch = __libc_logVSNPrintfInt(pszBuffer, cchBuffer, pszFormat, args);
    19001927        DosUnsetExceptionHandler(&XcptRegRec.RegRec);
    19011928    }
     
    19111938        DosUnsetExceptionHandler(&XcptRegRec.RegRec);
    19121939        cch = 0;
    1913         while (*pszMsg && cchBufferIn)
     1940        while (*pszMsg && cchBuffer)
    19141941        {
    1915             *pszBufferIn++ = *pszMsg++;
     1942            *pszBuffer++ = *pszMsg++;
    19161943            cch++;
    1917             cchBufferIn--;
     1944            cchBuffer--;
    19181945        }
    1919         while (*pszFormatIn && cchBufferIn)
     1946        if (__libc_StrictStringR(pszFormat, cchBuffer))
    19201947        {
    1921             *pszBufferIn++ = *pszFormatIn++;
    1922             cch++;
    1923             cchBufferIn--;
     1948            while (*pszFormat && cchBuffer)
     1949            {
     1950                *pszBuffer++ = *pszFormat++;
     1951                cch++;
     1952                cchBuffer--;
     1953            }
    19241954        }
     1955        if (!cchBuffer)
     1956            pszBuffer[-1] = '\0';
    19251957    }
    19261958
  • trunk/src/emx/src/lib/sys/sharedpm.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1487 r1488  
    187187
    188188                /* Free it safely. */
     189                LIBCLOG_MSG("Cleanup embryo %p.\n", (void *)pProcess);
    189190                spmZombieOrFree(pProcess);
    190191
     
    429430            {
    430431                __LIBC_PSPMPROCESS      pProcessNext = pProcess->pNext;
     432                LIBCLOG_MSG("Reaping embryo %p pidParent=%04x pid=%08x pForkHandle=%p uTimestamp=%08x (cur %08x)\n",
     433                            (void *)pProcess, pProcess->pidParent, pProcess->pid, pProcess->pvForkHandle,
     434                            pProcess->uTimestamp, uTimestamp);
    431435                spmFreeProcess(pProcess);
    432436                pProcess = pProcessNext;
     
    602606    if (pProcess->cReferences > 0)
    603607        pProcess->cReferences--;
     608
    604609    /*
    605610     * Free the process.
    606      * Note that we do not free embryos. We'll reap them at other places
    607      * if they don't become alive.
    608      */
    609     if (pProcess->cReferences == 0 && pProcess->enmState != __LIBC_PROCSTATE_EMBRYO)
     611     * Note that we do not free embryos unless they are failed fork attempts.
     612     * We'll reap them at other places if they don't become alive.
     613     */
     614    if (    pProcess->cReferences == 0
     615        &&  (pProcess->enmState != __LIBC_PROCSTATE_EMBRYO || pProcess->pvForkHandle))
    610616        spmFreeProcess(pProcess);
    611617
     
    945951            DosGetInfoBlocks(&pTib, &pPib);
    946952            gpSPMSelf = __libc_spmQueryProcessInState(pPib->pib_ulpid, __LIBC_PROCSTATE_ALIVE);
    947             LIBC_ASSERTM(gpSPMSelf, "Couldn't find our self after fork - impossibled. pid=%ld ppid=%ld\n", pPib->pib_ulpid, pPib->pib_ulppid);
     953            LIBC_ASSERTM(gpSPMSelf, "Couldn't find our self after fork - impossibled! pid=%ld ppid=%ld\n", pPib->pib_ulpid, pPib->pib_ulppid);
     954            LIBC_ASSERTM(gpSPMSelf->cReferences >= 2, "cReferences=%d!\n", gpSPMSelf->cReferences);
     955            gpSPMSelf->cReferences--;
    948956            FS_RESTORE();
    949957            LIBCLOG_RETURN_INT(0);
     
    10631071    }
    10641072
     1073    __atomic_xchg((volatile unsigned *)(void *)&rc, 0); /* ..... */
    10651074    DosUnsetExceptionHandler(&pRegRec->Core);
    10661075    DosExitMustComplete(&ul);
     
    12691278static void spmZombieOrFree(__LIBC_PSPMPROCESS pProcess)
    12701279{
     1280    LIBCLOG_ENTER("pProcess=%p\n", (void *)pProcess);
     1281    LIBC_ASSERT(pProcess->enmState != __LIBC_PROCSTATE_FREE);
    12711282    /*
    12721283     * Dereference it.
    1273      */
    1274     LIBC_ASSERT(pProcess->cReferences > 0);
     1284     * Note that if we're cleaning up embyos, the referenc count is 0.
     1285     */
    12751286    if (pProcess->cReferences > 0)
    12761287        pProcess->cReferences--;
     
    12861297    else if (pProcess->enmState != __LIBC_PROCSTATE_ZOMBIE)
    12871298    {
     1299        LIBCLOG_MSG("Making process %p a zombie (pid=%04x pidParent=%04x cReferences=%d enmState=%d)\n",
     1300                    (void *)pProcess, pProcess->pid, pProcess->pidParent, pProcess->cReferences, pProcess->enmState);
     1301
    12881302        /* free data a zombie won't be needing. */
    12891303        if (pProcess->pInherit)
     
    13101324    }
    13111325    /* else already zombie */
     1326
     1327    LIBCLOG_RETURN_VOID();
    13121328}
    13131329
     
    13451361    LIBCLOG_ENTER("pid=%d pidParent=%d\n", pid, pidParent);
    13461362    __LIBC_PSPMPROCESS pProcess;
     1363    __LIBC_PSPMPROCESS pProcessBest;
    13471364
    13481365    /*
     
    13551372     * See if we're in the embryo list.
    13561373     */
    1357     for (pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO]; pProcess; pProcess = pProcess->pNext)
     1374    for (pProcessBest = NULL,  pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO]; pProcess; pProcess = pProcess->pNext)
    13581375    {
    13591376        /* sanity */
     
    13651382                     pProcess->cReferences, pProcess->pid);
    13661383
    1367         /* our daddy? */
    1368         if (pProcess->pidParent == pidParent)
    1369         {
    1370             /* set data. */
    1371             pProcess->cReferences++;
    1372             pProcess->pid = pid;
    1373 
    1374             /* link out. */
    1375             if (pProcess->pNext)
    1376                 pProcess->pNext->pPrev = pProcess->pPrev;
    1377             if (pProcess->pPrev)
    1378                 pProcess->pPrev->pNext = pProcess->pNext;
    1379             else
    1380                 gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO] = pProcess->pNext;
    1381 
    1382             /* update state and instert at head of that state list. */
    1383             pProcess->enmState = __LIBC_PROCSTATE_ALIVE;
    1384             pProcess->pNext = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE];
    1385             if (pProcess->pNext)
    1386                 pProcess->pNext->pPrev = pProcess;
    1387             pProcess->pPrev = NULL;
    1388             gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE] = pProcess;
    1389 
    1390             gpSPMSelf = pProcess;
    1391 
    1392             /* return. */
    1393             LIBCLOG_RETURN_P(pProcess);
    1394         }
    1395 
    1396         /* more sanity checks. */
    1397         LIBC_ASSERTM(pProcess->pNext != gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO], "Circular list! pid=%d\n", pProcess->pid);
    1398         LIBC_ASSERTM(pProcess->pNext != pProcess, "Circular list with self! pid=%d\n", pProcess->pid);
     1384        /* our daddy? daddy updated it with our pid? */
     1385        if (    pProcess->pidParent == pidParent)
     1386        {
     1387            if (pProcess->pid == pid)
     1388            {
     1389                pProcessBest = pProcess;
     1390                break;
     1391            }
     1392            if (!pProcessBest)
     1393                pProcessBest = pProcess;
     1394        }
     1395        LIBCLOG_MSG("Walking by embryo %p (pidParent=%04x cReferences=%d)\n",
     1396                    (void *)pProcess, pProcess->pidParent, pProcess->cReferences);
     1397
    13991398        /* cure insanity... no fix for paranoia? */
    14001399        if (    pProcess->pNext == gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO]
    14011400            ||  pProcess->pNext == pProcess)
     1401        {
     1402            LIBC_ASSERTM(pProcess->pNext != gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO], "Circular list! pid=%d\n", pProcess->pid);
     1403            LIBC_ASSERTM(pProcess->pNext != pProcess, "Circular list with self! pid=%d\n", pProcess->pid);
    14021404            pProcess->pNext = NULL;
     1405        }
     1406    }
     1407
     1408    if (pProcessBest)
     1409    {
     1410        pProcess = pProcessBest;
     1411        LIBCLOG_MSG("Found my embryo %p (pidParent=%04x pid=%04x cReferences=%d uTimestamp=%04x)\n",
     1412                    (void *)pProcess, pProcess->pidParent, pProcess->pid, pProcess->cReferences, pProcess->uTimestamp);
     1413
     1414        /* set data. */
     1415        pProcess->cReferences++;
     1416        pProcess->pid = pid;
     1417
     1418        /* link out. */
     1419        if (pProcess->pNext)
     1420            pProcess->pNext->pPrev = pProcess->pPrev;
     1421        if (pProcess->pPrev)
     1422            pProcess->pPrev->pNext = pProcess->pNext;
     1423        else
     1424            gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO] = pProcess->pNext;
     1425
     1426        /* update state and insert at head of that state list. */
     1427        pProcess->enmState = __LIBC_PROCSTATE_ALIVE;
     1428        pProcess->pNext = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE];
     1429        if (pProcess->pNext)
     1430            pProcess->pNext->pPrev = pProcess;
     1431        pProcess->pPrev = NULL;
     1432        gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE] = pProcess;
     1433
     1434        gpSPMSelf = pProcess;
     1435
     1436        /* return. */
     1437        LIBCLOG_RETURN_P(pProcess);
    14031438    }
    14041439
     
    14261461        LIBC_ASSERTM(pProcess->pid != pid, "Found pid %d with parent %d when searching for that pid but with parent %d\n",
    14271462                     pid, pProcess->pidParent, pidParent);
    1428         LIBC_ASSERTM(pProcess->pNext != gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE], "Circular list! pid=%d\n", pProcess->pid);
    1429         LIBC_ASSERTM(pProcess->pNext != pProcess, "Circular list with self! pid=%d\n", pProcess->pid);
    14301463        /* make sane... who's paranoid here... */
    14311464        if (    pProcess->pNext == gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]
    14321465            ||  pProcess->pNext == pProcess)
     1466        {
     1467            LIBC_ASSERTM(pProcess->pNext != gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE], "Circular list! pid=%d\n", pProcess->pid);
     1468            LIBC_ASSERTM(pProcess->pNext != pProcess, "Circular list with self! pid=%d\n", pProcess->pid);
    14331469            pProcess->pNext = NULL;
     1470        }
    14341471    }
    14351472
     
    15031540            else
    15041541                gpSPMHdr->apHeads[__LIBC_PROCSTATE_ZOMBIE] = NULL;
     1542            LIBCLOG_MSG("Reaping zombie %p (pid=%04x pidParent=%04x cRefrences=%d)\n",
     1543                        (void *)pProcess, pProcess->pid, pProcess->pidParent, pProcess->cReferences);
    15051544        }
    15061545        bzero(pProcess, gpSPMHdr->cbProcess);
     
    15181557static void spmFreeProcess(__LIBC_PSPMPROCESS pProcess)
    15191558{
     1559    LIBCLOG_ENTER("pProcess=%p:{pid=%04x pidParent=%04x cReferences=%d enmState=%d pvForkHandle=%p pNext=%p pPrev=%p}\n",
     1560                  (void *)pProcess, pProcess->pid, pProcess->pidParent, pProcess->cReferences, pProcess->enmState,
     1561                  pProcess->pvForkHandle, (void *)pProcess->pNext, (void *)pProcess->pPrev);
     1562
    15201563    /*
    15211564     * Free pool pointers.
     
    15521595    pProcess->pPrev    = NULL;
    15531596    gpSPMHdr->apHeads[__LIBC_PROCSTATE_FREE] = pProcess;
     1597
     1598    LIBCLOG_RETURN_VOID();
    15541599}
    15551600
     
    15891634    if (!pv)
    15901635    {
     1636        unsigned            uTimestamp;
    15911637        __LIBC_PSPMPROCESS  pProcess;
     1638        LIBCLOG_MSG("SPM IS LOW ON MEMORY!!! cbFree=%d cb=%d (cbSize=%d)\n", gpSPMHdr->cbFree, gpSPMHdr->cb, cbSize);
     1639        spmCheck(0, 1);
    15921640
    15931641        /*
    15941642         * Free embryos which are more than 15 seconds old.
    15951643         */
     1644        uTimestamp = spmTimestamp();
    15961645        pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_EMBRYO];
    15971646        if (pProcess)
    15981647        {
    1599             unsigned    uTimestamp = spmTimestamp();
    16001648            do
    16011649            {
     
    16071655                {
    16081656                    __LIBC_PSPMPROCESS      pProcessNext = pProcess->pNext;
     1657                    LIBCLOG_MSG("Reaping embryo %p pidParent=%04x pid=%08x pForkHandle=%p uTimestamp=%08x (now=%08x) pNext=%p pPrev=%p\n",
     1658                                (void *)pProcess, pProcess->pidParent, pProcess->pid, pProcess->pvForkHandle, pProcess->uTimestamp, uTimestamp,
     1659                                (void *)pProcess->pNext, (void *)pProcess->pPrev);
    16091660                    spmFreeProcess(pProcess);
    16101661                    pProcess = pProcessNext;
     
    16251676            SPM_ASSERT_PTR_NULL(pProcess->pNext);
    16261677            SPM_ASSERT_PTR_NULL(pProcess->pPrev);
     1678            LIBC_ASSERTM(pProcess->enmState == __LIBC_PROCSTATE_FREE, "enmState=%d pProcess=%p\n",
     1679                         pProcess->enmState, (void *)pProcess);
     1680            LIBCLOG_MSG("Reaping free process %p (pid=%04x pidParent=%04x)\n",
     1681                        (void *)pProcess, pProcess->pid, pProcess->pidParent);
     1682
    16271683            gpSPMHdr->apHeads[__LIBC_PROCSTATE_FREE] = pProcess->pNext;
    16281684            if (pProcess->pNext)
     
    16351691
    16361692        /*
    1637          * Free up inherit data of processes in the alive list.
     1693         * Free up inherit data of processes which have been around for more than 15 seconds.
    16381694         */
    16391695        for (pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]; pProcess; pProcess = pProcess->pNext)
     
    16421698            SPM_ASSERT_PTR_NULL(pProcess->pNext);
    16431699            SPM_ASSERT_PTR_NULL(pProcess->pPrev);
    1644             if (pProcess->pInherit)
     1700            if (    pProcess->pInherit
     1701                &&  uTimestamp - pProcess->uTimestamp >= 15*1000)
    16451702            {
    16461703                void *pv = (void *)__atomic_xchg((unsigned *)(void *)&gpSPMSelf->pInherit, 0);
     1704                LIBCLOG_MSG("Reaping inherit data (%p) of process %p (pid=%04x pidParent=%04x)\n",
     1705                            pv, (void *)pProcess, pProcess->pid, pProcess->pidParent);
    16471706                spmFree(pv);
    16481707            }
     
    21122171              gpSPMHdr->cbProcess);
    21132172    for (i = 0; i < __LIBC_PROCSTATE_MAX; i++)
    2114         CHECK_LOG("apHeads[%d]            %p\n", i, (void *)gpSPMHdr->apHeads[i]);
     2173        CHECK_LOG("apHeads[%d]             %p\n", i, (void *)gpSPMHdr->apHeads[i]);
    21152174    CHECK_LOG("pTcpip                 %p\n"
    21162175              "pidCreate              %#x (%d)\n"
     
    21402199    for (i = 0; i < __LIBC_PROCSTATE_MAX; i++)
    21412200    {
    2142         __LIBC_PSPMPROCESS   pProcess;
    2143         __LIBC_PSPMPROCESS   pProcessLast;
     2201        __LIBC_PSPMPROCESS  pProcess;
     2202        __LIBC_PSPMPROCESS  pProcessLast;
     2203        unsigned            cProcesses;
    21442204        char                sz[64];
    21452205        sprintf(sz, "i=%d\n", i);
     
    21522212
    21532213        /* validate the list. */
     2214        cProcesses = 0;
    21542215        pProcessLast = NULL;
    21552216        pProcess = gpSPMHdr->apHeads[i];
    21562217        while (pProcess)
    21572218        {
     2219            cProcesses++;
    21582220            CHECK_PTR(pProcess, sz);
    21592221            if (!SPM_VALID_PTR(pProcess))
     
    21942256            pProcess = pProcess->pNext;
    21952257        }
     2258        CHECK_LOG("%d processes of type %d\n", cProcesses, i);
    21962259    }
    21972260
     
    22132276                        (uintptr_t)pFree, (uintptr_t)pFree->pNext, (uintptr_t)pFree->pPrev, pFree->cb,
    22142277                        (uintptr_t)pFree->core.pNext, (uintptr_t)pFree->core.pPrev);
    2215         sprintf(szMsg, "pFree=%p\n", pFree);
     2278        sprintf(szMsg, "pFree=%p\n", (void *)pFree);
    22162279        CHECK_PTR_NULL(pFree->pNext, szMsg);
    22172280        CHECK_PTR_NULL(pFree->pPrev, szMsg);
     
    22742337        CHECK_LOG("pChunk=%08x pNext=%08x pPrev=%08x\n",
    22752338                        (uintptr_t)pChunk, (uintptr_t)pChunk->pNext, (uintptr_t)pChunk->pPrev);
    2276         sprintf(szMsg, "pChunk=%p\n", pChunk);
     2339        sprintf(szMsg, "pChunk=%p\n", (void *)pChunk);
    22772340        CHECK_PTR_NULL(pChunk->pNext, szMsg);
    22782341        CHECK_PTR_NULL(pChunk->pPrev, szMsg);
     
    23182381}
    23192382
     2383
Note: See TracChangeset for help on using the changeset viewer.