Back to index

lightning-sunbird  0.9+nobinonly
Functions
btlocks.c File Reference
#include "primpl.h"
#include <string.h>
#include <sys/time.h>

Go to the source code of this file.

Functions

void _PR_InitLocks (void)
 PR_NewLock (void)
 PR_DestroyLock (PRLock *lock)
 PR_Lock (PRLock *lock)
 PR_Unlock (PRLock *lock)

Function Documentation

Definition at line 50 of file btlocks.c.

{
}
PR_DestroyLock ( PRLock lock)

Definition at line 78 of file btlocks.c.

{
    status_t result;

    PR_ASSERT(NULL != lock);
    result = delete_sem(lock->semaphoreID);
    PR_ASSERT(result == B_NO_ERROR);
    PR_DELETE(lock);
}
PR_Lock ( PRLock lock)

Definition at line 89 of file btlocks.c.

{
    PR_ASSERT(lock != NULL);

    if( atomic_add( &lock->benaphoreCount, 1 ) > 0 ) {

       if( acquire_sem(lock->semaphoreID ) != B_NO_ERROR ) {

           atomic_add( &lock->benaphoreCount, -1 );
           return;
       }
    }

    lock->owner = find_thread( NULL );
}

Definition at line 55 of file btlocks.c.

{
    PRLock *lock;
    status_t semresult;

    if (!_pr_initialized) _PR_ImplicitInitialization();

    lock = PR_NEWZAP(PRLock);
    if (lock != NULL) {

       lock->benaphoreCount = 0;
       lock->semaphoreID = create_sem( 0, "nsprLockSem" );
       if( lock->semaphoreID < B_NO_ERROR ) {

           PR_DELETE( lock );
           lock = NULL;
       }
    }

    return lock;
}

Here is the call graph for this function:

PR_Unlock ( PRLock lock)

Definition at line 106 of file btlocks.c.

{
    PR_ASSERT(lock != NULL);
    lock->owner = NULL;
    if( atomic_add( &lock->benaphoreCount, -1 ) > 1 ) {

       release_sem_etc( lock->semaphoreID, 1, B_DO_NOT_RESCHEDULE );
    }

    return PR_SUCCESS;
}