Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
whatnspr.c File Reference
#include "base.h"

Go to the source code of this file.

Defines

#define WHATNSPR   (whatnspr ? whatnspr : set_whatnspr())

Functions

static int set_whatnspr (void)
NSS_IMPLEMENT PRStatus nss_NewThreadPrivateIndex (PRUintn *ip, PRThreadPrivateDTOR dtor)
NSS_IMPLEMENT voidnss_GetThreadPrivate (PRUintn i)
NSS_IMPLEMENT void nss_SetThreadPrivate (PRUintn i, void *v)

Variables

static int whatnspr = 0

Define Documentation

Definition at line 97 of file whatnspr.c.


Function Documentation

Definition at line 127 of file whatnspr.c.

{
  switch( WHATNSPR ) {
  case 1:
    {
      PRLibrary *l = (PRLibrary *)0;
      void *f = PR_FindSymbolAndLibrary("PR_GetThreadPrivate", &l);
      typedef void *(*gtpt)(PRThread *, PRInt32);
      gtpt gtp = (gtpt) f;

      PR_ASSERT((void *)0 != f);

      return gtp(PR_CurrentThread(), i);
    }
  case 2:
  default:
    return PR_GetThreadPrivate(i);
  }
}

Definition at line 101 of file whatnspr.c.

{
  switch( WHATNSPR ) {
  case 1:
    {
      PRLibrary *l = (PRLibrary *)0;
      void *f = PR_FindSymbolAndLibrary("PR_NewThreadPrivateID", &l);
      typedef PRInt32 (*ntpt)(void);
      ntpt ntp = (ntpt) f;

      PR_ASSERT((void *)0 != f);

      *ip = ntp();
      return PR_SUCCESS;
    }
  case 2:
  default:
    return PR_NewThreadPrivateIndex(ip, dtor);
  }
}
NSS_IMPLEMENT void nss_SetThreadPrivate ( PRUintn  i,
void v 
)

Definition at line 151 of file whatnspr.c.

{
  switch( WHATNSPR ) {
  case 1:
    {
      PRLibrary *l = (PRLibrary *)0;
      void *f = PR_FindSymbolAndLibrary("PR_SetThreadPrivate", &l);
      typedef PRStatus (*stpt)(PRThread *, PRInt32, void *);
      stpt stp = (stpt) f;

      PR_ASSERT((void *)0 != f);

      (void)stp(PR_CurrentThread(), i, v);
      return;
    }
  case 2:
  default:
    (void)PR_SetThreadPrivate(i, v);
    return;
  }
}
static int set_whatnspr ( void  ) [static]

Definition at line 58 of file whatnspr.c.

{
  /*
   * The only runtime difference I could find was the
   * return value of PR_dtoa.  We can't just look for
   * a symbol in NSPR >=2, because it'll always be
   * found (because we compile against NSPR >=2).
   * Maybe we could look for a symbol merely in NSPR 1?
   *
   */

  char buffer[64];
  int decpt = 0, sign = 0;
  char *rve = (char *)0;
  /* extern int PR_dtoa(double, int, int, int *, int *, char **, char *, int); */
  int r = (int)PR_dtoa((double)1.0, 0, 5, &decpt, &sign, &rve, 
                       buffer, sizeof(buffer));

  switch( r ) {
  case 0:
  case -1:
    whatnspr = 2;
    /*
     * If we needed to, *now* we could look up "libVersionPoint"
     * and get more data there.. except all current NSPR's (up
     * to NSPR 4.x at time of writing) still say 2 in their
     * version structure.
     */
    break;
  default:
    whatnspr = 1;
    break;
  }

  return whatnspr;
}

Here is the call graph for this function:


Variable Documentation

int whatnspr = 0 [static]

Definition at line 54 of file whatnspr.c.