Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
ncr.c File Reference
#include "primpl.h"
#include <setjmp.h>
#include "prlock.h"

Go to the source code of this file.

Defines

#define NEED_LOCALTIME_R
#define NEED_GMTIME_R
#define NEED_ASCTIME_R
#define NEED_STRTOK_R
#define NEED_CTIME_R

Functions

void _MD_EarlyInit (void)
PRWord_MD_HomeGCRegisters (PRThread *t, int isCurrent, int *np)
void _MD_SET_PRIORITY (_MDThread *thread, PRUintn newPri)
PRStatus _MD_InitializeThread (PRThread *thread)
PRStatus _MD_WAIT (PRThread *thread, PRIntervalTime ticks)
PRStatus _MD_WAKEUP_WAITER (PRThread *thread)
void _MD_YIELD (void)
PRStatus _MD_CREATE_THREAD (PRThread *thread, void(*start)(void *), PRUintn priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize)
struct tmlocaltime_r (const time_t *clock, struct tm *result)
struct tmgmtime_r (const time_t *clock, struct tm *result)
char * ctime_r (const time_t *clock, char *buf, int buflen)
char * asctime_r (const struct tm *tm, char *buf, int buflen)
char * strtok_r (char *s, const char *delim, char **last)

Variables

static PRLocklocaltime_r_monitor = NULL
static PRLockgmtime_r_monitor = NULL
static PRLockctime_r_monitor = NULL
static PRLockasctime_r_monitor = NULL

Define Documentation

Definition at line 196 of file ncr.c.

Definition at line 198 of file ncr.c.

Definition at line 195 of file ncr.c.

Definition at line 194 of file ncr.c.

Definition at line 197 of file ncr.c.


Function Documentation

PRStatus _MD_CREATE_THREAD ( PRThread thread,
void(*)(void *)  start,
PRUintn  priority,
PRThreadScope  scope,
PRThreadState  state,
PRUint32  stackSize 
)

Definition at line 173 of file ncr.c.

{
    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Unixware.");
    return PR_FAILURE;
}

Definition at line 45 of file ncr.c.

{
}
PRWord* _MD_HomeGCRegisters ( PRThread t,
int  isCurrent,
int np 
)

Definition at line 49 of file ncr.c.

{
    if (isCurrent) {
       (void) setjmp(CONTEXT(t));
    }
    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
    return (PRWord *) CONTEXT(t);
}

Definition at line 143 of file ncr.c.

{
       return PR_SUCCESS;
}
void _MD_SET_PRIORITY ( _MDThread thread,
PRUintn  newPri 
)

Definition at line 137 of file ncr.c.

{
    return;
}
PRStatus _MD_WAIT ( PRThread thread,
PRIntervalTime  ticks 
)

Definition at line 149 of file ncr.c.

{
    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    _PR_MD_SWITCH_CONTEXT(thread);
    return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 157 of file ncr.c.

{
    if (thread) {
       PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    }
    return PR_SUCCESS;
}

Definition at line 167 of file ncr.c.

{
    PR_NOT_REACHED("_MD_YIELD should not be called for Unixware.");
}
char* asctime_r ( const struct tm tm,
char *  buf,
int  buflen 
)

Definition at line 313 of file ncr.c.

{
    char *cbuf;
    int needLock = PR_Initialized();  /* We need to use a lock to protect
                                       * against NSPR threads only when the
                                       * NSPR thread system is activated. */

    if (needLock) {
        if (asctime_r_monitor == NULL) {
            asctime_r_monitor = PR_NewLock();
        }
        PR_Lock(asctime_r_monitor);
    }

    cbuf = asctime (tm);
    if (cbuf) {
        strncpy (buf, cbuf, buflen - 1);
        buf[buflen - 1] = 0;
    }

    if (needLock) PR_Unlock(asctime_r_monitor);

    return cbuf;

}

Here is the call graph for this function:

char* ctime_r ( const time_t *  clock,
char *  buf,
int  buflen 
)

Definition at line 280 of file ncr.c.

{
    char *cbuf;
    int needLock = PR_Initialized();  /* We need to use a lock to protect
                                       * against NSPR threads only when the
                                       * NSPR thread system is activated. */

    if (needLock) {

        if (ctime_r_monitor == NULL) {
            ctime_r_monitor = PR_NewLock();
        }
        PR_Lock(ctime_r_monitor);
    }

    cbuf = ctime (clock);
    if (cbuf) {
        strncpy (buf, cbuf, buflen - 1);
        buf[buflen - 1] = 0;
    }

    if (needLock) PR_Unlock(ctime_r_monitor);

    return cbuf;
}

Here is the call graph for this function:

struct tm* gmtime_r ( const time_t *  clock,
struct tm result 
) [read]

Definition at line 248 of file ncr.c.

{
    struct tm *tmPtr;
    int needLock = PR_Initialized();  /* We need to use a lock to protect
                                       * against NSPR threads only when the
                                       * NSPR thread system is activated. */

    if (needLock) {
        if (gmtime_r_monitor == NULL) {
            gmtime_r_monitor = PR_NewLock();
        }
        PR_Lock(gmtime_r_monitor);
    }

    tmPtr = gmtime(clock);
    if (tmPtr) {
        *result = *tmPtr;
    } else {
        result = NULL;
    }

    if (needLock) PR_Unlock(gmtime_r_monitor);

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct tm* localtime_r ( const time_t *  clock,
struct tm result 
) [read]

Definition at line 208 of file ncr.c.

{
    struct tm *tmPtr;
    int needLock = PR_Initialized();  /* We need to use a lock to protect
                                       * against NSPR threads only when the
                                       * NSPR thread system is activated. */

    if (needLock) {
        if (localtime_r_monitor == NULL) {

            localtime_r_monitor = PR_NewLock();
        }
        PR_Lock(localtime_r_monitor);
    }

    /*
     * On Windows, localtime() returns a NULL pointer if 'clock'
     * represents a time before midnight January 1, 1970.  In
     * that case, we also return a NULL pointer and the struct tm
     * object pointed to by 'result' is not modified.
     */

    tmPtr = localtime(clock);
    if (tmPtr) {
        *result = *tmPtr;
    } else {
        result = NULL;
    }

    if (needLock) PR_Unlock(localtime_r_monitor);

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* strtok_r ( char *  s,
const char *  delim,
char **  last 
)

Definition at line 343 of file ncr.c.

{
        register char *spanp;
        register int c, sc;
        char *tok;


        if (s == NULL && (s = *last) == NULL)
                return (NULL);

        /*
         * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
         */
cont:

        c = *s++;
        for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
                if (c == sc)
                        goto cont;
        }

        if (c == 0) {           /* no non-delimiter characters */
                *last = NULL;
                return (NULL);
        }
        tok = s - 1;

        /*
         * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
         * Note that delim must have one NUL; we stop if we see that, too.
         */
        for (;;) {
                c = *s++;
                spanp = (char *)delim;
                do {
                        if ((sc = *spanp++) == c) {
                                if (c == 0)
                                        s = NULL;

                                else
                                        s[-1] = 0;
                                *last = s;
                                return (tok);
                        }
                } while (sc != 0);
        }
        /* NOTREACHED */
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 310 of file ncr.c.

Definition at line 278 of file ncr.c.

Definition at line 246 of file ncr.c.

Definition at line 206 of file ncr.c.