Ignore:
Timestamp:
Sep 17, 2020, 11:52:16 PM (5 years ago)
Author:
bird
Message:

kash: Use kHlpAssert instead of assert.h (debugger stops on the assertion rather than at exit process code).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shfile.c

    r3473 r3477  
    3333#include <stdio.h>
    3434#include <string.h>
    35 #include <assert.h>
    3635
    3736#if K_OS == K_OS_WINDOWS
     
    235234        if (decrement_pending)
    236235        {
    237             assert(g_shfile_async_close.num_pending > 0);
     236            kHlpAssert(g_shfile_async_close.num_pending > 0);
    238237            g_shfile_async_close.num_pending -= 1;
    239238        }
     
    242241        if (idx != g_shfile_async_close.idx_write % K_ELEMENTS(g_shfile_async_close.handles))
    243242        {
    244             assert(g_shfile_async_close.num_pending > 0);
     243            kHlpAssert(g_shfile_async_close.num_pending > 0);
    245244            toclose = g_shfile_async_close.handles[idx];
    246             assert(toclose);
     245            kHlpAssert(toclose);
    247246            g_shfile_async_close.handles[idx] = NULL;
    248247            g_shfile_async_close.idx_read = (idx + 1) % K_ELEMENTS(g_shfile_async_close.handles);
     
    254253            {
    255254                BOOL rc = SetEvent(g_shfile_async_close.evt_sync);
    256                 assert(rc);
     255                kHlpAssert(rc);
    257256                g_shfile_async_close.signal_sync = FALSE;
    258257            }
     
    265264        {
    266265            BOOL rc = CloseHandle(toclose);
    267             assert(rc);
     266            kHlpAssert(rc);
    268267            decrement_pending = K_TRUE;
    269268        }
     
    271270        {
    272271            DWORD dwRet = WaitForSingleObject(g_shfile_async_close.evt_workers, 10000 /*ms*/);
    273             assert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
     272            kHlpAssert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
    274273            decrement_pending = K_FALSE;
    275274        }
     
    303302    {
    304303        /* Write the handle to the ring buffer: */
    305         assert(g_shfile_async_close.handles[idx] == NULL);
     304        kHlpAssert(g_shfile_async_close.handles[idx] == NULL);
    306305        g_shfile_async_close.handles[idx] = toclose;
    307306        g_shfile_async_close.idx_write    = idx_next;
     
    311310
    312311        ret = SetEvent(g_shfile_async_close.evt_workers);
    313         assert(ret);
     312        kHlpAssert(ret);
    314313        if (ret)
    315314        {
     
    322321                intptr_t hThread = _beginthreadex(NULL /*security*/, 0 /*stack_size*/, shfile_async_close_handle_thread,
    323322                                                  NULL /*arg*/, 0 /*initflags*/, &tid);
    324                 assert(hThread != -1);
     323                kHlpAssert(hThread != -1);
    325324                if (hThread != -1)
    326325                {
     
    375374        {
    376375            BOOL rc = ResetEvent(g_shfile_async_close.evt_sync);
    377             assert(rc); K_NOREF(rc);
     376            kHlpAssert(rc); K_NOREF(rc);
    378377
    379378            g_shfile_async_close.signal_sync = K_TRUE;
     
    384383        TRACE2((NULL, "shfile_async_close_sync: Calling WaitForSingleObject...\n"));
    385384        dwRet = WaitForSingleObject(g_shfile_async_close.evt_sync, 10000 /*ms*/);
    386         assert(dwRet == WAIT_OBJECT_0);
    387         assert(g_shfile_async_close.num_pending == 0);
     385        kHlpAssert(dwRet == WAIT_OBJECT_0);
     386        kHlpAssert(g_shfile_async_close.num_pending == 0);
    388387        TRACE2((NULL, "shfile_async_close_sync: WaitForSingleObject returned %u...\n", dwRet));
    389388    }
     
    441440    KU64 ns = shfile_nano_ts();
    442441    BOOL fRc = CloseHandle((HANDLE)native);
    443     assert(fRc); K_NOREF(fRc);
     442    kHlpAssert(fRc); K_NOREF(fRc);
    444443    ns = shfile_nano_ts() - ns;
    445444    if (ns > 1000000)
     
    448447#  else
    449448    BOOL fRc = CloseHandle((HANDLE)native);
    450     assert(fRc); K_NOREF(fRc);
     449    kHlpAssert(fRc); K_NOREF(fRc);
    451450#  endif
    452451    }
     
    656655{
    657656    shmtx_leave(&pfdtab->mtx, ptmp);
    658     assert(file);
     657    kHlpAssert(file);
    659658    (void)file;
    660659}
     
    10691068
    10701069                            fd2 = shfile_insert(pfdtab, (intptr_t)h, fFlags, fFlags2, i, "shtab_init", NULL);
    1071                             assert(fd2 == i); (void)fd2;
     1070                            kHlpAssert(fd2 == i); (void)fd2;
    10721071                            if (fd2 != i)
    10731072                                rc = -1;
     
    10951094                                fFlags2 = SHFILE_FLAGS_FILE;
    10961095                            fd2 = shfile_insert(pfdtab, (intptr_t)hFile, fFlags, fFlags2, i, "shtab_init", NULL);
    1097                             assert(fd2 == i); (void)fd2;
     1096                            kHlpAssert(fd2 == i); (void)fd2;
    10981097                            if (fd2 != i)
    10991098                                rc = -1;
     
    11361135                                native = fd;
    11371136                            fd2 = shfile_insert(pfdtab, native, oflags, fFlags2, fd, "shtab_init", NULL);
    1138                             assert(fd2 == fd); (void)fd2;
     1137                            kHlpAssert(fd2 == fd); (void)fd2;
    11391138                            if (fd2 != fd)
    11401139                                rc = -1;
     
    12681267#if K_OS == K_OS_WINDOWS
    12691268                    BOOL rc = CloseHandle((HANDLE)pfd->native);
    1270                     assert(rc == TRUE); K_NOREF(rc);
     1269                    kHlpAssert(rc == TRUE); K_NOREF(rc);
    12711270#else
    12721271                    int rc = close((int)pfd->native);
    1273                     assert(rc == 0); K_NOREF(rc);
     1272                    kHlpAssert(rc == 0); K_NOREF(rc);
    12741273#endif
    12751274                    pfd->fd     = -1;
     
    13301329            TRACE2((NULL, "shfile_set_inherit_win: %p -> %p (set=%d)\n", pfd->native, hFile, set));
    13311330            if (!CloseHandle((HANDLE)pfd->native))
    1332                 assert(0);
     1331                kHlpAssert(0);
    13331332            pfd->native = (intptr_t)hFile;
    13341333        }
     
    13361335        {
    13371336            err = GetLastError();
    1338             assert(0);
     1337            kHlpAssert(0);
    13391338            hFile = (HANDLE)pfd->native;
    13401339        }
     
    20432042    {
    20442043# if K_OS == K_OS_WINDOWS
    2045         assert(SEEK_SET == FILE_BEGIN);
    2046         assert(SEEK_CUR == FILE_CURRENT);
    2047         assert(SEEK_END == FILE_END);
     2044        kHlpAssert(SEEK_SET == FILE_BEGIN);
     2045        kHlpAssert(SEEK_CUR == FILE_CURRENT);
     2046        kHlpAssert(SEEK_END == FILE_END);
    20482047        rc = SetFilePointer((HANDLE)file->native, off, NULL, whench);
    20492048        if (rc == INVALID_SET_FILE_POINTER)
     
    20962095                {
    20972096# if K_OS == K_OS_WINDOWS
    2098                     assert(0);
     2097                    kHlpAssert(0);
    20992098                    errno = EINVAL;
    21002099                    rc = -1;
Note: See TracChangeset for help on using the changeset viewer.