Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsprstub.c File Reference
#include "seccomon.h"
#include "prmem.h"
#include "prerror.h"
#include "plarena.h"
#include "secerr.h"
#include "prmon.h"
#include "prbit.h"
#include "ck.h"
#include "prlock.h"
#include "prinit.h"

Go to the source code of this file.

Functions

 nss_SetError (PRUint32 value)
 NSS_GetError (void)
 NSS_GetErrorStack (void)
 nss_ClearErrorStack (void)
 PR_GetCurrentThread (void)
 PR_Assert (const char *expr, const char *file, int line)
 PR_Alloc (PRUint32 bytes)
 PR_Malloc (PRUint32 bytes)
 PR_Calloc (PRUint32 blocks, PRUint32 bytes)
 PR_Realloc (void *blocks, PRUint32 bytes)
 PR_Free (void *ptr)
 PR_IMPLEMENT (PRInt32)
 nssSetLockArgs (CK_C_INITIALIZE_ARGS_PTR pInitArgs, CryptokiLockingState *returned)
 PR_NewLock (void)
 PR_DestroyLock (PRLock *lock)
 PR_Lock (PRLock *lock)
 PR_Unlock (PRLock *lock)
 PR_NewMonitor (void)
 PR_EnterMonitor (PRMonitor *mon)
 PR_ExitMonitor (PRMonitor *mon)
 PR_IMPLEMENT (PRStatus)
PRIntn PR_CeilingLog2 (PRUint32 i)

Variables

static PRInt32 stack [2] = {0, 0}
static CK_C_INITIALIZE_ARGS_PTR nssstub_pInitArgs = NULL
static CK_C_INITIALIZE_ARGS nssstub_initArgs
static NSSArena * nssstub_arena = NULL
static CryptokiLockingState nssstub_LockingState = SingleThreaded

Function Documentation

Definition at line 245 of file nsprstub.c.

{
    stack[0] = 0;
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file nsprstub.c.

{
    return(stack[0]);
}

Here is the call graph for this function:

Definition at line 239 of file nsprstub.c.

{
    return(&stack[0]);
}

Here is the call graph for this function:

nss_SetError ( PRUint32  value)

Definition at line 225 of file nsprstub.c.

{      
    stack[0] = value;
    return;
}

Here is the call graph for this function:

Definition at line 357 of file nsprstub.c.

{
    CK_ULONG count = (CK_ULONG)0;
    CK_BBOOL os_ok = CK_FALSE;
    CK_RV rv = CKR_OK;
    if (nssstub_pInitArgs == NULL) {
       if (pInitArgs != NULL) {
           nssstub_initArgs = *pInitArgs;
           nssstub_pInitArgs = &nssstub_initArgs;
            if( (CK_CREATEMUTEX )NULL != pInitArgs->CreateMutex  ) count++;
            if( (CK_DESTROYMUTEX)NULL != pInitArgs->DestroyMutex ) count++;
            if( (CK_LOCKMUTEX   )NULL != pInitArgs->LockMutex    ) count++;
            if( (CK_UNLOCKMUTEX )NULL != pInitArgs->UnlockMutex  ) count++;
            os_ok = (pInitArgs->flags & CKF_OS_LOCKING_OK) ? CK_TRUE : CK_FALSE;

            if( (0 != count) && (4 != count) ) {
                rv = CKR_ARGUMENTS_BAD;
                goto loser;
            }
       } else {
           nssstub_pInitArgs = pInitArgs;
       }
       /* nssstub_arena = NSSArena_Create(); */
    }

    if( (0 == count) && (CK_TRUE == os_ok) ) {
      /*
       * This is case #2 in the description of C_Initialize:
       * The library will be called in a multithreaded way, but
       * no routines were specified: os locking calls should be
       * used.  Unfortunately, this can be hard.. like, I think
       * I may have to dynamically look up the entry points in
       * the instance of NSPR already going in the application.
       *
       * I know that *we* always specify routines, so this only
       * comes up if someone is using NSS to create their own
       * PCKS#11 modules for other products.  Oh, heck, I'll 
       * worry about this then.
       */
      rv = CKR_CANT_LOCK;
      goto loser;
    }

    if( 0 == count ) {
      /*
       * With the above test out of the way, we know this is case
       * #1 in the description of C_Initialize: this library will
       * not be called in a multithreaded way.
       */

      nssstub_LockingState = SingleThreaded;
    } else {
      /*
       * We know that we're in either case #3 or #4 in the description
       * of C_Initialize.  Case #3 says we should use the specified
       * functions, case #4 cays we can use either the specified ones
       * or the OS ones.  I'll use the specified ones.
       */
      nssstub_LockingState = MultiThreaded;
    }

    loser:
    *returned = nssstub_LockingState;
    return rv;
}
PR_Alloc ( PRUint32  bytes)

Definition at line 309 of file nsprstub.c.

{ return malloc(bytes); }
PR_Assert ( const char *  expr,
const char *  file,
int  line 
)

Definition at line 304 of file nsprstub.c.

                                                        {
    return; 
}
PR_Calloc ( PRUint32  blocks,
PRUint32  bytes 
)

Definition at line 315 of file nsprstub.c.

{ return calloc(blocks,bytes); }

Here is the call graph for this function:

PRIntn PR_CeilingLog2 ( PRUint32  i)

Definition at line 512 of file nsprstub.c.

                                  {
       PRIntn log2;
       PR_CEILING_LOG2(log2,i);
       return log2;
}
PR_DestroyLock ( PRLock lock)

Definition at line 445 of file nsprstub.c.

                             {
       NSSCKFWMutex *mlock = (NSSCKFWMutex *)lock;
       if (lock == (PRLock *)1) return;
       nssCKFWMutex_Destroy(mlock);
}

Here is the call graph for this function:

Definition at line 481 of file nsprstub.c.

{
    PR_Lock( (PRLock *)mon );
}

Definition at line 487 of file nsprstub.c.

{
    return PR_Unlock( (PRLock *)mon );
}
PR_Free ( void ptr)

Definition at line 321 of file nsprstub.c.

{ free(ptr); }

Definition at line 296 of file nsprstub.c.

{
     return (PRThread *)1;
}

Definition at line 348 of file nsprstub.c.

{ return ++(*val); }

Definition at line 496 of file nsprstub.c.

{
    /* This is not really atomic! */
    if (1 == PR_AtomicIncrement(&once->initialized)) {
       once->status = (*func)();
    }  else {
       /* Should wait to be sure that func has finished before returning. */
    }
    return once->status;
}

Here is the call graph for this function:

PR_Lock ( PRLock lock)

Definition at line 452 of file nsprstub.c.

                      {
       NSSCKFWMutex *mlock = (NSSCKFWMutex *)lock;
       if (lock == (PRLock *)1) return;
       nssCKFWMutex_Lock(mlock);
}

Here is the call graph for this function:

PR_Malloc ( PRUint32  bytes)

Definition at line 312 of file nsprstub.c.

{ return malloc(bytes); }

Definition at line 431 of file nsprstub.c.

                 {
       PRLock *lock = NULL;
       NSSCKFWMutex *mlock = NULL;
       CK_RV error;

       mlock = nssCKFWMutex_Create(nssstub_pInitArgs,nssstub_LockingState,nssstub_arena,&error);
       lock = (PRLock *)mlock;

       /* if we don't have a lock, nssCKFWMutex can deal with things */
       if (lock == NULL) lock=(PRLock *) 1;
       return lock;
}

Here is the call graph for this function:

Definition at line 474 of file nsprstub.c.

{
    return (PRMonitor *) PR_NewLock();
}

Here is the call graph for this function:

PR_Realloc ( void blocks,
PRUint32  bytes 
)

Definition at line 318 of file nsprstub.c.

{ return realloc(blocks,bytes); }

Here is the call graph for this function:

PR_Unlock ( PRLock lock)

Definition at line 459 of file nsprstub.c.

                        {
       NSSCKFWMutex *mlock = (NSSCKFWMutex *)lock;
       if (lock == (PRLock *)1) return PR_SUCCESS;
       nssCKFWMutex_Unlock(mlock);
       return PR_SUCCESS;
}

Here is the call graph for this function:


Variable Documentation

NSSArena* nssstub_arena = NULL [static]

Definition at line 353 of file nsprstub.c.

Definition at line 352 of file nsprstub.c.

Definition at line 354 of file nsprstub.c.

Definition at line 351 of file nsprstub.c.

PRInt32 stack[2] = {0, 0} [static]

Definition at line 222 of file nsprstub.c.