Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions | Variables
pprthred.h File Reference
#include "nspr.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PR_InMonitor(m)   (PR_GetMonitorEntryCount(m) > 0)

Typedefs

typedef void(* PRThreadDumpProc )(PRFileDesc *fd, PRThread *t, void *arg)
typedef PRStatus(PR_CALLBACKPREnumerator )(PRThread *t, int i, void *arg)
typedef PRStatus(PR_CALLBACKPRScanStackFun )(PRThread *t, void **baseAddr, PRUword count, void *closure)

Functions

PR_BEGIN_EXTERN_C NSPR_API (PRThread *) PR_AttachThread(PRThreadType type
 NSPR_API (void) PR_DetachThread(void)
 Prototypes for machine dependent function implementations.
 NSPR_API (PRUint32) PR_GetThreadID(PRThread *thread)
 NSPR_API (PRInt32) PR_GetThreadAffinityMask(PRThread *thread
 NSPR_API (void *) PR_GetSP(PRThread *thread)
 NSPR_API (PRWord *) PR_GetGCRegisters(PRThread *t
 NSPR_API (PRStatus) PR_EnumerateThreads(PREnumerator func
 PR_ThreadScanStackPointers (PRThread *t, PRScanStackFun scanFun, void *scanClosure)
 PR_ScanStackPointers (PRScanStackFun scanFun, void *scanClosure)
 PR_GetStackSpaceLeft (PRThread *t)
 NSPR_API (struct _PRCPU *) _PR_GetPrimordialCPU(void)
 NSPR_API (PRMonitor *) PR_NewNamedMonitor(const char *name)
 NSPR_API (PRBool) PR_TestAndLock(PRLock *lock)
 NSPR_API (PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon)

Variables

PR_BEGIN_EXTERN_C PRThreadPriority priority
PR_BEGIN_EXTERN_C
PRThreadPriority PRThreadStack
stack
PRThreadDumpProc dump
PRThreadDumpProc voidarg
PRUint32mask
void(* start )(void *arg)
void(*) void PRThreadPriority
PRThreadScop 
scope )
void(*) void PRThreadPriority
PRThreadScope PRThreadStat 
state )
void(*) void PRThreadPriority
PRThreadScope PRThreadState
PRUint3 
stackSize )
int isCurrent
int intnp
voidenvironment

Define Documentation

Definition at line 359 of file pprthred.h.


Typedef Documentation

Definition at line 231 of file pprthred.h.

Definition at line 240 of file pprthred.h.

Definition at line 101 of file pprthred.h.


Function Documentation

NSPR_API ( void  )

Prototypes for machine dependent function implementations.

(Too bad NSPR's MD system blows so much that we have to reiterate every stinking thing we implement here in our MD header file.)

NSPR_API ( void )
NSPR_API ( PRWord )
NSPR_API ( struct _PRCPU )
NSPR_API ( PRMonitor ) const
NSPR_API ( PRIntn  )

Definition at line 195 of file prthinfo.c.

{
    PRThread *current = PR_CurrentThread();
    PRWord *sp, *esp;
    int stack_end;

#if defined(WIN16)
    /*
    ** Under WIN16, the stack of the current thread is always mapped into
    ** the "task stack" (at SS:xxxx).  So, if t is the current thread, scan
    ** the "task stack".  Otherwise, scan the "cached stack" of the inactive
    ** thread...
    */
    if (t == current) {
        sp  = (PRWord*) &stack_end;
        esp = (PRWord*) _pr_top_of_task_stack;

        PR_ASSERT(sp <= esp);
    } else {
        sp  = (PRWord*) PR_GetSP(t);
        esp = (PRWord*) t->stack->stackTop;

       PR_ASSERT((t->stack->stackSize == 0) ||
                 ((sp >  (PRWord*)t->stack->stackBottom) &&
                (sp <= (PRWord*)t->stack->stackTop)));
    }
#else   /* ! WIN16 */
#ifdef HAVE_STACK_GROWING_UP
    if (t == current) {
        esp = (PRWord*) &stack_end;
    } else {
        esp = (PRWord*) PR_GetSP(t);
    }
    sp = (PRWord*) t->stack->stackTop;
    if (t->stack->stackSize) {
        PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&
                  (esp < (PRWord*)t->stack->stackBottom));
    }
#else   /* ! HAVE_STACK_GROWING_UP */
    if (t == current) {
        sp = (PRWord*) &stack_end;
    } else {
        sp = (PRWord*) PR_GetSP(t);
    }
    esp = (PRWord*) t->stack->stackTop;
    if (t->stack->stackSize) {
       PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&
                (sp < (PRWord*)t->stack->stackTop));
    }
#endif  /* ! HAVE_STACK_GROWING_UP */
#endif  /* ! WIN16 */
    return (PRUword)t->stack->stackSize - ((PRWord)esp - (PRWord)sp);
}

Here is the call graph for this function:

PR_ScanStackPointers ( PRScanStackFun  scanFun,
void scanClosure 
)

Definition at line 186 of file prthinfo.c.

{
    PRScanStackData data;
    data.scanFun = scanFun;
    data.scanClosure = scanClosure;
    return PR_EnumerateThreads(pr_ScanStack, &data);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PR_ThreadScanStackPointers ( PRThread t,
PRScanStackFun  scanFun,
void scanClosure 
)

Definition at line 54 of file prthinfo.c.

{
    PRThread* current = PR_GetCurrentThread();
    PRWord *sp, *esp, *p0;
    int n;
    void **ptd;
    PRStatus status;
    PRUint32 index;
    int stack_end;

    /*
    ** Store the thread's registers in the thread structure so the GC
    ** can scan them. Then scan them.
    */
    p0 = _MD_HomeGCRegisters(t, t == current, &n);
    status = scanFun(t, (void**)p0, n, scanClosure);
    if (status != PR_SUCCESS)
        return status;

    /* Scan the C stack for pointers into the GC heap */
#if defined(XP_PC) && defined(WIN16)
    /*
    ** Under WIN16, the stack of the current thread is always mapped into
    ** the "task stack" (at SS:xxxx).  So, if t is the current thread, scan
    ** the "task stack".  Otherwise, scan the "cached stack" of the inactive
    ** thread...
    */
    if (t == current) {
        sp  = (PRWord*) &stack_end;
        esp = (PRWord*) _pr_top_of_task_stack;

        PR_ASSERT(sp <= esp);
    } else {
        sp  = (PRWord*) PR_GetSP(t);
        esp = (PRWord*) t->stack->stackTop;

        PR_ASSERT((t->stack->stackSize == 0) ||
                  ((sp >  (PRWord*)t->stack->stackBottom) &&
                   (sp <= (PRWord*)t->stack->stackTop)));
    }
#else   /* ! WIN16 */
#ifdef HAVE_STACK_GROWING_UP
    if (t == current) {
        esp = (PRWord*) &stack_end;
    } else {
        esp = (PRWord*) PR_GetSP(t);
    }
    sp = (PRWord*) t->stack->stackTop;
    if (t->stack->stackSize) {
        PR_ASSERT((esp > (PRWord*)t->stack->stackTop) &&
                  (esp < (PRWord*)t->stack->stackBottom));
    }
#else   /* ! HAVE_STACK_GROWING_UP */
    if (t == current) {
        sp = (PRWord*) &stack_end;
    } else {
        sp = (PRWord*) PR_GetSP(t);
    }
    esp = (PRWord*) t->stack->stackTop;
    if (t->stack->stackSize) {
        PR_ASSERT((sp > (PRWord*)t->stack->stackBottom) &&
                  (sp < (PRWord*)t->stack->stackTop));
    }
#endif  /* ! HAVE_STACK_GROWING_UP */
#endif  /* ! WIN16 */

#if defined(WIN16)
    {
        prword_t scan;
        prword_t limit;
        
        scan = (prword_t) sp;
        limit = (prword_t) esp;
        while (scan < limit) {
            prword_t *test;

            test = *((prword_t **)scan);
            status = scanFun(t, (void**)&test, 1, scanClosure);
            if (status != PR_SUCCESS)
                return status;
            scan += sizeof(char);
        }
    }
#else
    if (sp < esp) {
        status = scanFun(t, (void**)sp, esp - sp, scanClosure);
        if (status != PR_SUCCESS)
            return status;
    }
#endif

    /*
    ** Mark all of the per-thread-data items attached to this thread
    **
    ** The execution environment better be accounted for otherwise it
    ** will be collected
    */
    status = scanFun(t, (void**)&t->environment, 1, scanClosure);
    if (status != PR_SUCCESS)
        return status;

#ifndef GC_LEAK_DETECTOR
    /* if thread is not allocated on stack, this is redundant. */
    ptd = t->privateData;
    for (index = 0; index < t->tpdLength; index++, ptd++) {
        status = scanFun(t, (void**)ptd, 1, scanClosure);
        if (status != PR_SUCCESS)
            return status;
    }
#endif
    
    return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 103 of file pprthred.h.

Definition at line 103 of file pprthred.h.

Definition at line 222 of file pprthred.h.

Definition at line 211 of file pprthred.h.

Definition at line 113 of file pprthred.h.

Definition at line 211 of file pprthred.h.

Definition at line 74 of file pprthred.h.

void(*) void PRThreadPriority PRThreadScop scope)

Definition at line 156 of file pprthred.h.

Definition at line 74 of file pprthred.h.

Definition at line 156 of file pprthred.h.

Definition at line 155 of file pprthred.h.

Definition at line 156 of file pprthred.h.