- Timestamp:
- Sep 17, 2020, 11:52:16 PM (5 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/Makefile.kmk
r3470 r3477 42 42 kash_DEFS += KASH_SEPARATE_PARSER_ALLOCATOR KASH_ASYNC_CLOSE_HANDLE 43 43 endif 44 kash_DEFS.debug = DEBUG=2 44 kash_DEFS.debug = DEBUG=2 K_STRICT 45 45 kash_DEFS.haiku = BSD 46 46 kash_DEFS.linux = BSD -
trunk/src/kash/error.c
r3438 r3477 371 371 return psh->errmsg_buf; 372 372 } 373 374 375 #ifdef K_STRICT 376 377 KHLP_DECL(void) kHlpAssertMsg1(const char *pszExpr, const char *pszFile, unsigned iLine, const char *pszFunction) 378 { 379 shinstance *psh = shthread_get_shell(); 380 381 TRACE((psh, "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine)); 382 dprintf(psh, "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine); 383 } 384 385 KHLP_DECL(void) kHlpAssertMsg2(const char *pszFormat, ...) 386 { 387 shinstance *psh = shthread_get_shell(); 388 va_list va; 389 va_start(va, pszFormat); 390 doformat(psh->out2, pszFormat, va); 391 va_end(va); 392 } 393 394 #endif /* K_STRICT */ -
trunk/src/kash/eval.c
r3475 r3477 41 41 #endif 42 42 43 #include <assert.h>44 43 #include <stddef.h> 45 44 #include <stdlib.h> … … 528 527 break; 529 528 default: 530 assert(redir->type == NHERE || redir->type == NXHERE);529 kHlpAssert(redir->type == NHERE || redir->type == NXHERE); 531 530 expfnames->names[i] = NULL; 532 531 break; 533 532 } 534 533 } 535 assert(i == expfnames->count);534 kHlpAssert(i == expfnames->count); 536 535 537 536 /* Do the linking at the end, as nesting happens when we expand backtick arguments. */ … … 545 544 { 546 545 redirexpfnames *expfnames = psh->expfnames; 547 assert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth);546 kHlpAssert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth); 548 547 while (expfnames && expfnames->depth >= depth) 549 548 expfnames = psh->expfnames = expfnames->prev; -
trunk/src/kash/exec.c
r3475 r3477 46 46 #include <stdlib.h> 47 47 #include <stddef.h> 48 #include <assert.h>49 48 50 49 /* … … 307 306 int suffix; 308 307 int isreg = stat_pc_exec_exts(psh, cmd, 0, &suffix); 309 assert(isreg > 0);308 kHlpAssert(isreg > 0); 310 309 } 311 310 #endif -
trunk/src/kash/expand.c
r3456 r3477 45 45 #include <stdlib.h> 46 46 #include <stdio.h> 47 #include <assert.h>48 47 49 48 /* -
trunk/src/kash/main.c
r3474 r3477 45 45 #endif 46 46 47 #include <assert.h>48 47 #include <errno.h> 49 48 #include <stdio.h> -
trunk/src/kash/memalloc.c
r3462 r3477 43 43 #include <stdlib.h> 44 44 #include <stddef.h> 45 #include <assert.h>46 45 47 46 #include "shell.h" … … 332 331 size_t nbytes = (size_t)(end - pstart); 333 332 334 assert((uintptr_t)end >= (uintptr_t)pstart);335 /* assert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */336 assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);337 assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);333 kHlpAssert((uintptr_t)end >= (uintptr_t)pstart); 334 /*kHlpAssert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */ 335 kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart); 336 kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes); 338 337 339 338 nbytes = SHELL_ALIGN(nbytes); 340 339 psh->stacknxt += nbytes; 341 340 psh->stacknleft -= (int)nbytes; 342 assert(psh->stacknleft >= 0);341 kHlpAssert(psh->stacknleft >= 0); 343 342 344 343 return pstart; … … 348 347 ungrabstackstr(shinstance *psh, char *s, char *p) 349 348 { 350 assert((size_t)(psh->stacknxt - p) <= SHELL_SIZE);351 assert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]);352 assert((uintptr_t)p >= (uintptr_t)s);349 kHlpAssert((size_t)(psh->stacknxt - p) <= SHELL_SIZE); 350 kHlpAssert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]); 351 kHlpAssert((uintptr_t)p >= (uintptr_t)s); 353 352 354 353 psh->stacknleft += (int)(psh->stacknxt - s); … … 374 373 while ((top = pst->top) != &pst->first) { 375 374 pst->top = top->prev; 376 assert(pst->top);375 kHlpAssert(pst->top); 377 376 top->prev = NULL; 378 377 sh_free(psh, top); … … 393 392 void pstackpop(shinstance *psh, unsigned target) 394 393 { 395 assert(target <= psh->pstacksize);394 kHlpAssert(target <= psh->pstacksize); 396 395 while (target < psh->pstacksize) { 397 396 unsigned idx = --psh->pstacksize; … … 414 413 if (psh->curpstack == psh->pstack[i]) 415 414 break; 416 assert(i < psh->pstacksize);415 kHlpAssert(i < psh->pstacksize); 417 416 } 418 417 # endif … … 423 422 { 424 423 unsigned refs = sh_atomic_inc(&pst->refs); 425 assert(refs > 1);426 assert(refs < 256 /* bogus, but useful */);424 kHlpAssert(refs > 1); 425 kHlpAssert(refs < 256 /* bogus, but useful */); 427 426 return refs; 428 427 } … … 533 532 size_t blocksize; 534 533 535 assert(pst->avail < nbytes); /* only called when we need more space */536 assert(tocopy <= pst->avail);534 kHlpAssert(pst->avail < nbytes); /* only called when we need more space */ 535 kHlpAssert(tocopy <= pst->avail); 537 536 538 537 /* Double the size used thus far and add some fudge and alignment. Make … … 562 561 char const * const copysrc = pst->nextbyte; 563 562 pstallocnewblock(psh, pst, nbytes); 564 assert(pst->avail >= nbytes);565 assert(pst->avail >= tocopy);563 kHlpAssert(pst->avail >= nbytes); 564 kHlpAssert(pst->avail >= tocopy); 566 565 memcpy(pst->nextbyte, copysrc, tocopy); 567 566 } … … 646 645 size_t const len = end - pst->nextbyte; 647 646 648 assert(pst->avail - pst->strleft == len);647 kHlpAssert(pst->avail - pst->strleft == len); 649 648 TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes)); 650 649 … … 657 656 size_t const len = end - stackblock(psh); 658 657 659 assert(stackblocksize(psh) - psh->sstrnleft == len);658 kHlpAssert(stackblocksize(psh) - psh->sstrnleft == len); 660 659 TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes)); 661 660 … … 676 675 pst->strleft++; /* PSTPUTC() already incremented it. */ 677 676 end = pstmakestrspace(psh, 1, end); 678 assert(pst->strleft > 0);677 kHlpAssert(pst->strleft > 0); 679 678 pst->strleft--; 680 679 #else 681 680 psh->sstrnleft++; /* PSTPUTC() already incremented it. */ 682 681 end = pstmakestrspace(psh, 1, end); 683 assert(psh->sstrnleft > 0);682 kHlpAssert(psh->sstrnleft > 0); 684 683 psh->sstrnleft--; 685 684 #endif … … 696 695 size_t nbytes = (size_t)(end - pstart); 697 696 698 assert((uintptr_t)end > (uintptr_t)pstart);699 assert(end[-1] == '\0');700 assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);701 assert(pst->avail - pst->strleft >= nbytes);697 kHlpAssert((uintptr_t)end > (uintptr_t)pstart); 698 kHlpAssert(end[-1] == '\0'); 699 kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart); 700 kHlpAssert(pst->avail - pst->strleft >= nbytes); 702 701 703 702 nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */ … … 712 711 size_t nbytes = (size_t)(end - pstart); 713 712 714 assert((uintptr_t)end > (uintptr_t)pstart);715 assert(end[-1] == '\0');716 assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);717 assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);713 kHlpAssert((uintptr_t)end > (uintptr_t)pstart); 714 kHlpAssert(end[-1] == '\0'); 715 kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart); 716 kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes); 718 717 719 718 nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */ -
trunk/src/kash/memalloc.h
r3461 r3477 74 74 #define STPUTC(psh, c, p) (--(psh)->sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(psh), *p++ = (c))) 75 75 #define CHECKSTRSPACE(psh, n, p) { if ((psh)->sstrnleft < n) p = makestrspace(psh); } 76 #define USTPUTC(psh, c, p) do { assert((psh)->sstrnleft > 0); \77 assert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \76 #define USTPUTC(psh, c, p) do { kHlpAssert((psh)->sstrnleft > 0); \ 77 kHlpAssert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \ 78 78 --(psh)->sstrnleft; *p++ = (c); } while (0) 79 79 #define STACKSTRNUL(psh, p) ((psh)->sstrnleft == 0? (p = growstackstr(psh), *p = '\0') : (*p = '\0')) … … 114 114 # define PSTCHECKSTRSPACE(psh, n, p) do { \ 115 115 if ((psh)->curpstack->strleft >= (n)) {/*likely*/} \ 116 else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->curpstack->strleft >= (n)); } \116 else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->curpstack->strleft >= (n)); } \ 117 117 } while (0) 118 118 # define PSTUPUTC(psh, c, p) do { \ 119 assert((psh)->curpstack->strleft > 0); \119 kHlpAssert((psh)->curpstack->strleft > 0); \ 120 120 (psh)->curpstack->strleft -= 1; \ 121 121 *(p)++ = (c); \ … … 137 137 # define PSTARTSTACKSTR(psh, p) do { (p) = (psh)->stacknxt; (psh)->sstrnleft = (psh)->stacknleft; } while (0) 138 138 # define PSTCHECKSTRSPACE(psh, n, p) do { if ((psh)->sstrnleft >= (n)) {/*likely*/} \ 139 else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->sstrnleft >= (n)); } } while (0)140 # define PSTUPUTC(psh, c, p) do { assert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0)139 else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->sstrnleft >= (n)); } } while (0) 140 # define PSTUPUTC(psh, c, p) do { kHlpAssert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0) 141 141 # define PSTPUTC(psh, c, p) do { if (--(psh)->sstrnleft >= 0) *(p)++ = (c); else (p) = pstputcgrow(psh, (p), (c)); } while (0) 142 142 # define PSTPUTSTRN(psh, str, n, p) do { if ((psh)->sstrnleft >= (n)) {/*likely?*/} else (p) = pstmakestrspace(psh, (n), (p)); \ -
trunk/src/kash/options.c
r3445 r3477 41 41 #endif 42 42 43 #include <assert.h>44 43 #include <stdlib.h> 45 44 … … 109 108 i++; 110 109 } 111 assert(psh->arg0 != NULL);110 kHlpAssert(psh->arg0 != NULL); 112 111 } 113 112 … … 131 130 psh->shellparam.reset = inherit->shellparam.reset; 132 131 psh->shellparam.nparam = left = inherit->shellparam.nparam; 133 assert(left >= 0);132 kHlpAssert(left >= 0); 134 133 psh->shellparam.p = (char **)ckmalloc(psh, (left + 1) * sizeof(psh->shellparam.p[0])); 135 134 psh->shellparam.p[left] = NULL; … … 142 141 if (inherit->shellparam.optnext) { 143 142 size_t idx = (size_t)(inherit->shellparam.optnext - inherit->shellparam.p); 144 assert(idx <= inherit->shellparam.nparam);143 kHlpAssert(idx <= inherit->shellparam.nparam); 145 144 if (idx <= inherit->shellparam.nparam) 146 145 psh->shellparam.optnext = &psh->shellparam.p[idx]; … … 169 168 off--; 170 169 } 171 assert(psh->shellparam.optptr != NULL);170 kHlpAssert(psh->shellparam.optptr != NULL); 172 171 } 173 172 … … 225 224 psh->shellparam.p = psh->argptr; 226 225 psh->shellparam.reset = 1; 227 /* assert(shellparam.malloc == 0 && shellparam.nparam == 0); */226 /* kHlpAssert(shellparam.malloc == 0 && shellparam.nparam == 0); */ 228 227 while (*psh->argptr) { 229 228 psh->shellparam.nparam++; -
trunk/src/kash/parser.c
r3461 r3477 43 43 #define SH_MEMALLOC_NO_STACK 44 44 #include <stdlib.h> 45 #include <assert.h>46 45 47 46 #include "shell.h" -
trunk/src/kash/redir.c
r3473 r3477 43 43 #include <sys/types.h> 44 44 #include <limits.h> /* PIPE_BUF */ 45 #include <assert.h>46 45 #include <string.h> 47 46 #include <errno.h> … … 158 157 idxexpfname = 0; 159 158 for (n = redir, idxexpfname = 0 ; n ; n = n->nfile.next, idxexpfname++) { 160 assert(idxexpfname < psh->expfnames->count);159 kHlpAssert(idxexpfname < psh->expfnames->count); 161 160 fd = n->nfile.fd; 162 161 try = 0; … … 196 195 openredirect(psh, n, memory, flags, psh->expfnames->names[idxexpfname]); 197 196 } 198 assert(!redir || idxexpfname == psh->expfnames->count);197 kHlpAssert(!redir || idxexpfname == psh->expfnames->count); 199 198 if (memory[1]) 200 199 psh->out1 = &psh->memout; -
trunk/src/kash/setmode.c
r2498 r3477 44 44 #include <sys/stat.h> 45 45 46 #include <assert.h>47 46 #include <ctype.h> 48 47 #include <errno.h> … … 76 75 77 76 #ifndef _DIAGASSERT 78 # define _DIAGASSERT assert77 # define _DIAGASSERT kHlpAssert 79 78 #endif 80 79 -
trunk/src/kash/shfile.c
r3473 r3477 33 33 #include <stdio.h> 34 34 #include <string.h> 35 #include <assert.h>36 35 37 36 #if K_OS == K_OS_WINDOWS … … 235 234 if (decrement_pending) 236 235 { 237 assert(g_shfile_async_close.num_pending > 0);236 kHlpAssert(g_shfile_async_close.num_pending > 0); 238 237 g_shfile_async_close.num_pending -= 1; 239 238 } … … 242 241 if (idx != g_shfile_async_close.idx_write % K_ELEMENTS(g_shfile_async_close.handles)) 243 242 { 244 assert(g_shfile_async_close.num_pending > 0);243 kHlpAssert(g_shfile_async_close.num_pending > 0); 245 244 toclose = g_shfile_async_close.handles[idx]; 246 assert(toclose);245 kHlpAssert(toclose); 247 246 g_shfile_async_close.handles[idx] = NULL; 248 247 g_shfile_async_close.idx_read = (idx + 1) % K_ELEMENTS(g_shfile_async_close.handles); … … 254 253 { 255 254 BOOL rc = SetEvent(g_shfile_async_close.evt_sync); 256 assert(rc);255 kHlpAssert(rc); 257 256 g_shfile_async_close.signal_sync = FALSE; 258 257 } … … 265 264 { 266 265 BOOL rc = CloseHandle(toclose); 267 assert(rc);266 kHlpAssert(rc); 268 267 decrement_pending = K_TRUE; 269 268 } … … 271 270 { 272 271 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); 274 273 decrement_pending = K_FALSE; 275 274 } … … 303 302 { 304 303 /* 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); 306 305 g_shfile_async_close.handles[idx] = toclose; 307 306 g_shfile_async_close.idx_write = idx_next; … … 311 310 312 311 ret = SetEvent(g_shfile_async_close.evt_workers); 313 assert(ret);312 kHlpAssert(ret); 314 313 if (ret) 315 314 { … … 322 321 intptr_t hThread = _beginthreadex(NULL /*security*/, 0 /*stack_size*/, shfile_async_close_handle_thread, 323 322 NULL /*arg*/, 0 /*initflags*/, &tid); 324 assert(hThread != -1);323 kHlpAssert(hThread != -1); 325 324 if (hThread != -1) 326 325 { … … 375 374 { 376 375 BOOL rc = ResetEvent(g_shfile_async_close.evt_sync); 377 assert(rc); K_NOREF(rc);376 kHlpAssert(rc); K_NOREF(rc); 378 377 379 378 g_shfile_async_close.signal_sync = K_TRUE; … … 384 383 TRACE2((NULL, "shfile_async_close_sync: Calling WaitForSingleObject...\n")); 385 384 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); 388 387 TRACE2((NULL, "shfile_async_close_sync: WaitForSingleObject returned %u...\n", dwRet)); 389 388 } … … 441 440 KU64 ns = shfile_nano_ts(); 442 441 BOOL fRc = CloseHandle((HANDLE)native); 443 assert(fRc); K_NOREF(fRc);442 kHlpAssert(fRc); K_NOREF(fRc); 444 443 ns = shfile_nano_ts() - ns; 445 444 if (ns > 1000000) … … 448 447 # else 449 448 BOOL fRc = CloseHandle((HANDLE)native); 450 assert(fRc); K_NOREF(fRc);449 kHlpAssert(fRc); K_NOREF(fRc); 451 450 # endif 452 451 } … … 656 655 { 657 656 shmtx_leave(&pfdtab->mtx, ptmp); 658 assert(file);657 kHlpAssert(file); 659 658 (void)file; 660 659 } … … 1069 1068 1070 1069 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; 1072 1071 if (fd2 != i) 1073 1072 rc = -1; … … 1095 1094 fFlags2 = SHFILE_FLAGS_FILE; 1096 1095 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; 1098 1097 if (fd2 != i) 1099 1098 rc = -1; … … 1136 1135 native = fd; 1137 1136 fd2 = shfile_insert(pfdtab, native, oflags, fFlags2, fd, "shtab_init", NULL); 1138 assert(fd2 == fd); (void)fd2;1137 kHlpAssert(fd2 == fd); (void)fd2; 1139 1138 if (fd2 != fd) 1140 1139 rc = -1; … … 1268 1267 #if K_OS == K_OS_WINDOWS 1269 1268 BOOL rc = CloseHandle((HANDLE)pfd->native); 1270 assert(rc == TRUE); K_NOREF(rc);1269 kHlpAssert(rc == TRUE); K_NOREF(rc); 1271 1270 #else 1272 1271 int rc = close((int)pfd->native); 1273 assert(rc == 0); K_NOREF(rc);1272 kHlpAssert(rc == 0); K_NOREF(rc); 1274 1273 #endif 1275 1274 pfd->fd = -1; … … 1330 1329 TRACE2((NULL, "shfile_set_inherit_win: %p -> %p (set=%d)\n", pfd->native, hFile, set)); 1331 1330 if (!CloseHandle((HANDLE)pfd->native)) 1332 assert(0);1331 kHlpAssert(0); 1333 1332 pfd->native = (intptr_t)hFile; 1334 1333 } … … 1336 1335 { 1337 1336 err = GetLastError(); 1338 assert(0);1337 kHlpAssert(0); 1339 1338 hFile = (HANDLE)pfd->native; 1340 1339 } … … 2043 2042 { 2044 2043 # 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); 2048 2047 rc = SetFilePointer((HANDLE)file->native, off, NULL, whench); 2049 2048 if (rc == INVALID_SET_FILE_POINTER) … … 2096 2095 { 2097 2096 # if K_OS == K_OS_WINDOWS 2098 assert(0);2097 kHlpAssert(0); 2099 2098 errno = EINVAL; 2100 2099 rc = -1; -
trunk/src/kash/shfork-win.c
r3468 r3477 6 6 #include <string.h> 7 7 #include <locale.h> 8 #include <assert.h>9 8 #include "shinstance.h" 10 9 #include <Windows.h> … … 85 84 g_stack_base = shfork_string_to_ptr(argv[5], argv[0], "--stack-base"); 86 85 g_stack_limit = shfork_string_to_ptr(argv[7], argv[0], "--stack-limit"); 87 assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);88 assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);86 kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); 87 kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); 89 88 90 89 /* … … 183 182 int rc = 0; 184 183 185 assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);186 assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);184 kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); 185 kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); 187 186 188 187 /* -
trunk/src/kash/shheap.c
r3451 r3477 32 32 #include <string.h> 33 33 #include <stdlib.h> 34 #include <assert.h>35 34 #include "shinstance.h" 36 35 … … 105 104 # define SHHEAP_CHECK() shheap_check() 106 105 # define SHHEAP_CHECK_2() shheap_check() 107 # define SHHEAP_ASSERT(expr) assert(expr)106 # define SHHEAP_ASSERT(expr) kHlpAssert(expr) 108 107 # define SHHEAP_POISON_PSH(p,v) ((shinstance *)(v)) 109 108 # define SHHEAP_POISON_NULL(v) ((void *)(v)) -
trunk/src/kash/shinstance.c
r3476 r3477 32 32 #include <string.h> 33 33 #include <stdlib.h> 34 #include <assert.h>35 34 #ifdef _MSC_VER 36 35 # include <process.h> … … 174 173 { 175 174 #if K_OS == K_OS_WINDOWS 176 assert(ptmp->i == 0x42);175 kHlpAssert(ptmp->i == 0x42); 177 176 LeaveCriticalSection((CRITICAL_SECTION *)pmtx); 178 177 ptmp->i = 0x21; … … 190 189 void sh_init_globals(void) 191 190 { 192 assert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);191 kHlpAssert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC); 193 192 shmtx_init(&g_sh_mtx); 194 193 #ifndef SH_FORKED_MODE … … 317 316 sh_free(psh, psh->threadarg); 318 317 psh->threadarg = NULL; 319 assert(!psh->subshellstatus);318 kHlpAssert(!psh->subshellstatus); 320 319 if (psh->subshellstatus) 321 320 { … … 910 909 else 911 910 { 912 assert(old.sa_handler == SIG_IGN);911 kHlpAssert(old.sa_handler == SIG_IGN); 913 912 shold.sh_handler = SH_SIG_IGN; 914 913 } … … 919 918 /* fake */ 920 919 #ifndef _MSC_VER 921 assert(0);920 kHlpAssert(0); 922 921 old.sa_handler = SIG_DFL; 923 922 old.sa_flags = 0; … … 945 944 for (cur = g_sh_head; cur; cur = cur->next) 946 945 { 947 assert(cur->sigactions[signo].sh_handler == SH_SIG_UNK);946 kHlpAssert(cur->sigactions[signo].sh_handler == SH_SIG_UNK); 948 947 cur->sigactions[signo] = shold; 949 948 } … … 988 987 else 989 988 { 990 assert(pfn != SH_SIG_ERR);989 kHlpAssert(pfn != SH_SIG_ERR); 991 990 pfn(pshDst, signo); 992 991 } … … 1125 1124 && signo != SIGTTOU 1126 1125 && signo != SIGCONT) 1127 assert(0);1126 kHlpAssert(0); 1128 1127 } 1129 1128 #else 1130 1129 if (sigaction(signo, &g_sig_state[signo].sa, NULL)) 1131 assert(0);1130 kHlpAssert(0); 1132 1131 #endif 1133 1132 … … 1417 1416 { 1418 1417 unsigned refs = sh_atomic_dec(&sts->refs); 1419 assert(refs > 1);1420 assert(refs < 16);1418 kHlpAssert(refs > 1); 1419 kHlpAssert(refs < 16); 1421 1420 return refs; 1422 1421 } … … 1428 1427 { 1429 1428 unsigned refs = sh_atomic_dec(&sts->refs); 1430 assert(refs < ~(unsigned)0/4);1429 kHlpAssert(refs < ~(unsigned)0/4); 1431 1430 if (refs == 0) 1432 1431 { … … 1463 1462 # if K_OS == K_OS_WINDOWS 1464 1463 BOOL rc = ResetEvent((HANDLE)sts->towaiton); 1465 assert(rc); K_NOREF(rc);1464 kHlpAssert(rc); K_NOREF(rc); 1466 1465 # endif 1467 1466 } … … 1477 1476 if (!sts->towaiton) 1478 1477 { 1479 assert(0);1478 kHlpAssert(0); 1480 1479 sh_free(psh, sts); 1481 1480 return NULL; … … 1508 1507 sts->status = W_EXITCODE(iExit, 0); 1509 1508 sts->done = K_TRUE; 1510 rc = SetEvent((HANDLE)sts->towaiton); assert(rc); K_NOREF(rc);1509 rc = SetEvent((HANDLE)sts->towaiton); kHlpAssert(rc); K_NOREF(rc); 1511 1510 1512 1511 hThread = (HANDLE)sts->hThread; 1513 1512 sts->hThread = 0; 1514 rc = CloseHandle(hThread); assert(rc);1513 rc = CloseHandle(hThread); kHlpAssert(rc); 1515 1514 1516 1515 shsubshellstatus_release(psh, sts); … … 1781 1780 { 1782 1781 rc = psh->children[i].subshellstatus->done; 1783 assert(rc);1782 kHlpAssert(rc); 1784 1783 if (rc) 1785 1784 { … … 1812 1811 { 1813 1812 rc = CloseHandle(psh->children[i].hChild); 1814 assert(rc);1813 kHlpAssert(rc); 1815 1814 } 1816 1815 … … 2115 2114 */ 2116 2115 dwErr = WaitForSingleObject(ProcInfo.hProcess, INFINITE); 2117 assert(dwErr == WAIT_OBJECT_0);2116 kHlpAssert(dwErr == WAIT_OBJECT_0); 2118 2117 2119 2118 if (GetExitCodeProcess(ProcInfo.hProcess, &dwExitCode)) … … 2129 2128 /* this shouldn't happen... */ 2130 2129 TRACE2((psh, "sh_execve: GetExitCodeProcess failed: %u\n", GetLastError())); 2131 assert(0);2130 kHlpAssert(0); 2132 2131 errno = EINVAL; 2133 2132 } … … 2226 2225 shpid pgid = psh->pgid; 2227 2226 #ifndef _MSC_VER 2228 assert(pgid == getpgrp());2227 kHlpAssert(pgid == getpgrp()); 2229 2228 #endif 2230 2229 … … 2244 2243 shpid pgid = psh->pgid; 2245 2244 #ifndef _MSC_VER 2246 assert(pgid == getpgrp());2245 kHlpAssert(pgid == getpgrp()); 2247 2246 #endif 2248 2247 } 2249 2248 else 2250 2249 { 2251 assert(0);2250 kHlpAssert(0); 2252 2251 errno = ESRCH; 2253 2252 pgid = -1; -
trunk/src/kash/show.c
r3444 r3477 44 44 #include <stdarg.h> 45 45 #include <stdlib.h> 46 #include <assert.h>47 46 48 47 #include "shell.h" … … 293 292 if (pos > sizeof(psh->tracebuf)) { 294 293 char *end; 295 assert(0);294 kHlpAssert(0); 296 295 end = memchr(psh->tracebuf, '\0', sizeof(psh->tracebuf)); 297 296 pos = end ? end - &psh->tracebuf[0] : 0; -
trunk/src/kash/shthread.c
r2498 r3477 27 27 #include "shthread.h" 28 28 #include "shinstance.h" 29 #include <assert.h>30 29 31 30 #if K_OS == K_OS_WINDOWS … … 66 65 { 67 66 sh_tls = TlsAlloc(); 68 assert(sh_tls != TLS_OUT_OF_INDEXES);67 kHlpAssert(sh_tls != TLS_OUT_OF_INDEXES); 69 68 } 70 69 if (!TlsSetValue(sh_tls, psh)) 71 assert(0);70 kHlpAssert(0); 72 71 73 72 #elif K_OS == K_OS_OS2 … … 75 74 { 76 75 sh_tls = __libc_TLSAlloc(); 77 assert(sh_tls != -1);76 kHlpAssert(sh_tls != -1); 78 77 } 79 78 if (__libc_TLSSet(sh_tls, psh) == -1) 80 assert(0);79 kHlpAssert(0); 81 80 #else 82 81 if (!sh_tls_inited) 83 82 { 84 83 if (pthread_key_create(&sh_tls, NULL) != 0) 85 assert(0);84 kHlpAssert(0); 86 85 sh_tls_inited = 1; 87 86 } 88 87 if (pthread_setspecific(sh_tls, psh) != 0) 89 assert(0);88 kHlpAssert(0); 90 89 #endif 91 90 } -
trunk/src/kash/shtypes.h
r3438 r3477 30 30 31 31 #include "k/kTypes.h" /* Use these, not the ones below. */ 32 #include "k/kHlpAssert.h" 32 33 33 34 #include <sys/types.h> -
trunk/src/kash/var.c
r3438 r3477 41 41 #endif 42 42 43 #include <assert.h>44 43 #include <stddef.h> 45 44 #include <stdlib.h> … … 303 302 } else 304 303 break; 305 assert(left < 256 /*whatever, just no rollover*/);304 kHlpAssert(left < 256 /*whatever, just no rollover*/); 306 305 } 307 306 *dst = *vsrc; … … 336 335 337 336 dst->vp = find_var(psh, vsrc->vp->text, NULL, NULL); 338 assert(dst->vp);337 kHlpAssert(dst->vp); 339 338 340 339 *ppdst = dst;
Note:
See TracChangeset
for help on using the changeset viewer.