Changeset 36 for pjproject/main/pjlib/src/pj/os_core_unix.c
- Timestamp:
- Nov 9, 2005 3:37:19 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/main/pjlib/src/pj/os_core_unix.c
r35 r36 560 560 561 561 /* 562 * pj_atomic_inc_and_get() 563 */ 564 PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var) 565 { 566 pj_atomic_value_t new_value; 567 568 PJ_CHECK_STACK(); 569 570 #if PJ_HAS_THREADS 571 pj_mutex_lock( atomic_var->mutex ); 572 #endif 573 new_value = ++atomic_var->value; 574 #if PJ_HAS_THREADS 575 pj_mutex_unlock( atomic_var->mutex); 576 #endif 577 578 return new_value; 579 } 580 /* 562 581 * pj_atomic_inc() 563 582 */ 564 583 PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var) 565 584 { 585 pj_atomic_inc_and_get(atomic_var); 586 } 587 588 /* 589 * pj_atomic_dec_and_get() 590 */ 591 PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var) 592 { 593 pj_atomic_value_t new_value; 594 566 595 PJ_CHECK_STACK(); 567 596 … … 569 598 pj_mutex_lock( atomic_var->mutex ); 570 599 #endif 571 ++atomic_var->value;600 new_value = --atomic_var->value; 572 601 #if PJ_HAS_THREADS 573 602 pj_mutex_unlock( atomic_var->mutex); 574 603 #endif 604 605 return new_value; 575 606 } 576 607 … … 580 611 PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var) 581 612 { 582 PJ_CHECK_STACK(); 583 584 #if PJ_HAS_THREADS 585 pj_mutex_lock( atomic_var->mutex ); 586 #endif 587 --atomic_var->value; 588 #if PJ_HAS_THREADS 589 pj_mutex_unlock( atomic_var->mutex); 590 #endif 613 pj_atomic_dec_and_get(atomic_var); 614 } 615 616 /* 617 * pj_atomic_add_and_get() 618 */ 619 PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var, 620 pj_atomic_value_t value ) 621 { 622 pj_atomic_value_t new_value; 623 624 #if PJ_HAS_THREADS 625 pj_mutex_lock(atomic_var->mutex); 626 #endif 627 628 atomic_var->value += value; 629 new_value = atomic_var->value; 630 631 #if PJ_HAS_THREADS 632 pj_mutex_unlock(atomic_var->mutex); 633 #endif 634 635 return new_value; 591 636 } 592 637 … … 594 639 * pj_atomic_add() 595 640 */ 596 PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, pj_atomic_value_t value ) 597 { 598 #if PJ_HAS_THREADS 599 pj_mutex_lock(atomic_var->mutex); 600 #endif 601 602 atomic_var->value += value; 603 604 #if PJ_HAS_THREADS 605 pj_mutex_unlock(atomic_var->mutex); 606 #endif 607 } 608 641 PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, 642 pj_atomic_value_t value ) 643 { 644 pj_atomic_add_and_get(atomic_var, value); 645 } 609 646 610 647 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.