OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * secport.c - portability interfaces for security libraries | 6 * secport.c - portability interfaces for security libraries |
7 * | 7 * |
8 * This file abstracts out libc functionality that libsec depends on | 8 * This file abstracts out libc functionality that libsec depends on |
9 * | 9 * |
10 * NOTE - These are not public interfaces | 10 * NOTE - These are not public interfaces |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 | 460 |
461 static void | 461 static void |
462 port_ArenaRelease(PLArenaPool *arena, void *mark, PRBool zero) | 462 port_ArenaRelease(PLArenaPool *arena, void *mark, PRBool zero) |
463 { | 463 { |
464 PORTArenaPool *pool = (PORTArenaPool *)arena; | 464 PORTArenaPool *pool = (PORTArenaPool *)arena; |
465 if (ARENAPOOL_MAGIC == pool->magic ) { | 465 if (ARENAPOOL_MAGIC == pool->magic ) { |
466 PZ_Lock(pool->lock); | 466 PZ_Lock(pool->lock); |
467 #ifdef THREADMARK | 467 #ifdef THREADMARK |
468 { | 468 { |
469 » threadmark_mark **pw, *tm; | 469 » threadmark_mark **pw; |
470 | 470 |
471 if (PR_GetCurrentThread() != pool->marking_thread ) { | 471 if (PR_GetCurrentThread() != pool->marking_thread ) { |
472 PZ_Unlock(pool->lock); | 472 PZ_Unlock(pool->lock); |
473 PORT_SetError(SEC_ERROR_NO_MEMORY); | 473 PORT_SetError(SEC_ERROR_NO_MEMORY); |
474 PORT_Assert(0); | 474 PORT_Assert(0); |
475 return /* no error indication available */ ; | 475 return /* no error indication available */ ; |
476 } | 476 } |
477 | 477 |
478 pw = &pool->first_mark; | 478 pw = &pool->first_mark; |
479 while( *pw && (mark != (*pw)->mark) ) { | 479 while( *pw && (mark != (*pw)->mark) ) { |
480 pw = &(*pw)->next; | 480 pw = &(*pw)->next; |
481 } | 481 } |
482 | 482 |
483 if (! *pw ) { | 483 if (! *pw ) { |
484 /* bad mark */ | 484 /* bad mark */ |
485 PZ_Unlock(pool->lock); | 485 PZ_Unlock(pool->lock); |
486 PORT_SetError(SEC_ERROR_NO_MEMORY); | 486 PORT_SetError(SEC_ERROR_NO_MEMORY); |
487 PORT_Assert(0); | 487 PORT_Assert(0); |
488 return /* no error indication available */ ; | 488 return /* no error indication available */ ; |
489 } | 489 } |
490 | 490 |
491 tm = *pw; | |
492 *pw = (threadmark_mark *)NULL; | 491 *pw = (threadmark_mark *)NULL; |
493 | 492 |
494 if (zero) { | 493 if (zero) { |
495 port_ArenaZeroAfterMark(arena, mark); | 494 port_ArenaZeroAfterMark(arena, mark); |
496 } | 495 } |
497 PL_ARENA_RELEASE(arena, mark); | 496 PL_ARENA_RELEASE(arena, mark); |
498 | 497 |
499 if (! pool->first_mark ) { | 498 if (! pool->first_mark ) { |
500 pool->marking_thread = (PRThread *)NULL; | 499 pool->marking_thread = (PRThread *)NULL; |
501 } | 500 } |
(...skipping 27 matching lines...) Expand all Loading... |
529 { | 528 { |
530 port_ArenaRelease(arena, mark, PR_TRUE); | 529 port_ArenaRelease(arena, mark, PR_TRUE); |
531 } | 530 } |
532 | 531 |
533 void | 532 void |
534 PORT_ArenaUnmark(PLArenaPool *arena, void *mark) | 533 PORT_ArenaUnmark(PLArenaPool *arena, void *mark) |
535 { | 534 { |
536 #ifdef THREADMARK | 535 #ifdef THREADMARK |
537 PORTArenaPool *pool = (PORTArenaPool *)arena; | 536 PORTArenaPool *pool = (PORTArenaPool *)arena; |
538 if (ARENAPOOL_MAGIC == pool->magic ) { | 537 if (ARENAPOOL_MAGIC == pool->magic ) { |
539 » threadmark_mark **pw, *tm; | 538 » threadmark_mark **pw; |
540 | 539 |
541 PZ_Lock(pool->lock); | 540 PZ_Lock(pool->lock); |
542 | 541 |
543 if (PR_GetCurrentThread() != pool->marking_thread ) { | 542 if (PR_GetCurrentThread() != pool->marking_thread ) { |
544 PZ_Unlock(pool->lock); | 543 PZ_Unlock(pool->lock); |
545 PORT_SetError(SEC_ERROR_NO_MEMORY); | 544 PORT_SetError(SEC_ERROR_NO_MEMORY); |
546 PORT_Assert(0); | 545 PORT_Assert(0); |
547 return /* no error indication available */ ; | 546 return /* no error indication available */ ; |
548 } | 547 } |
549 | 548 |
550 pw = &pool->first_mark; | 549 pw = &pool->first_mark; |
551 while( ((threadmark_mark *)NULL != *pw) && (mark != (*pw)->mark) ) { | 550 while( ((threadmark_mark *)NULL != *pw) && (mark != (*pw)->mark) ) { |
552 pw = &(*pw)->next; | 551 pw = &(*pw)->next; |
553 } | 552 } |
554 | 553 |
555 if ((threadmark_mark *)NULL == *pw ) { | 554 if ((threadmark_mark *)NULL == *pw ) { |
556 /* bad mark */ | 555 /* bad mark */ |
557 PZ_Unlock(pool->lock); | 556 PZ_Unlock(pool->lock); |
558 PORT_SetError(SEC_ERROR_NO_MEMORY); | 557 PORT_SetError(SEC_ERROR_NO_MEMORY); |
559 PORT_Assert(0); | 558 PORT_Assert(0); |
560 return /* no error indication available */ ; | 559 return /* no error indication available */ ; |
561 } | 560 } |
562 | 561 |
563 tm = *pw; | |
564 *pw = (threadmark_mark *)NULL; | 562 *pw = (threadmark_mark *)NULL; |
565 | 563 |
566 if (! pool->first_mark ) { | 564 if (! pool->first_mark ) { |
567 pool->marking_thread = (PRThread *)NULL; | 565 pool->marking_thread = (PRThread *)NULL; |
568 } | 566 } |
569 | 567 |
570 PZ_Unlock(pool->lock); | 568 PZ_Unlock(pool->lock); |
571 } | 569 } |
572 #endif /* THREADMARK */ | 570 #endif /* THREADMARK */ |
573 } | 571 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 const unsigned char *b = (const unsigned char*) ib; | 707 const unsigned char *b = (const unsigned char*) ib; |
710 size_t i; | 708 size_t i; |
711 unsigned char r = 0; | 709 unsigned char r = 0; |
712 | 710 |
713 for (i = 0; i < n; ++i) { | 711 for (i = 0; i < n; ++i) { |
714 r |= *a++ ^ *b++; | 712 r |= *a++ ^ *b++; |
715 } | 713 } |
716 | 714 |
717 return r; | 715 return r; |
718 } | 716 } |
OLD | NEW |