Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view ProcrContext.c @ 157:8cc3d3812c8a
smaller Hists for malloc, free and plugin
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 06 Oct 2011 15:58:34 +0200 |
| parents | 521c75d64cef |
| children |
line source
1 /*
2 * This File contains all hardware dependent C code.
3 */
6 #include "VMS.h"
7 #include "ProcrContext.h"
9 /*Create stack, then create __cdecl structure on it and put initialData and
10 * pointer to the new structure instance into the parameter positions on
11 * the stack
12 *Then put function pointer into nextInstrPt -- the stack is setup in std
13 * call structure, so jumping to function ptr is same as a GCC generated
14 * function call
15 *No need to save registers on old stack frame, because there's no old
16 * animator state to return to --
17 *
18 */
19 inline VirtProcr *
20 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr,
21 void *initialData, void *stackLocs )
22 {
23 void *stackPtr;
25 newPr->startOfStack = stackLocs;
26 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
27 newPr->initialData = initialData;
28 newPr->requests = NULL;
29 newPr->schedSlot = NULL;
31 /*
32 * Hardware dependent part
33 */
34 //instead of calling the function directly, call a wrapper function to fetch
35 //arguments from stack
36 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
38 //fnPtr takes two params -- void *initData & void *animProcr
39 //alloc stack locations, make stackPtr be the highest addr minus room
40 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
41 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
42 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
44 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
45 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
46 *((void**)stackPtr + 1 ) = initialData; //next param to left
47 *((void**)stackPtr) = (void*)fnPtr;
49 /*
50 * end of Hardware dependent part
51 */
53 newPr->stackPtr = stackPtr; //core loop will switch to this, then
54 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
56 //============================= MEASUREMENT STUFF ========================
57 #ifdef STATS__TURN_ON_PROBES
58 //struct timeval timeStamp;
59 //gettimeofday( &(timeStamp), NULL);
60 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
61 // _VMSMasterEnv->createPtInSecs;
62 #endif
63 //========================================================================
65 return newPr;
66 }
