home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / md / os2 / os2gc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.3 KB  |  74 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * GC related routines
  21.  *
  22.  */
  23. #include "primpl.h"
  24.  
  25. extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD);
  26.  
  27. PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) 
  28. {
  29.     CONTEXTRECORD context;
  30.     context.ContextFlags = CONTEXT_INTEGER;
  31.  
  32.     if (_PR_IS_NATIVE_THREAD(t)) {
  33.         context.ContextFlags |= CONTEXT_CONTROL;
  34.         if (QueryThreadContext(t->md.handle, CONTEXT_CONTROL, &context)) {
  35.             t->md.gcContext[0] = context.ctx_RegEax;
  36.             t->md.gcContext[1] = context.ctx_RegEbx;
  37.             t->md.gcContext[2] = context.ctx_RegEcx;
  38.             t->md.gcContext[3] = context.ctx_RegEdx;
  39.             t->md.gcContext[4] = context.ctx_RegEsi;
  40.             t->md.gcContext[5] = context.ctx_RegEdi;
  41.             t->md.gcContext[6] = context.ctx_RegEsp;
  42.             t->md.gcContext[7] = context.ctx_RegEbp;
  43.             *np = PR_NUM_GCREGS;
  44.         } else {
  45.             PR_ASSERT(0);/* XXX */
  46.         }
  47.     }
  48.     return (PRWord *)&t->md.gcContext;
  49. }
  50.  
  51. /* This function is not used right now, but is left as a reference.
  52.  * If you ever need to get the fiberID from the currently running fiber, 
  53.  * this is it.
  54.  */
  55. void *
  56. GetMyFiberID()
  57. {
  58.     void *fiberData = 0;
  59.  
  60.     /* A pointer to our tib entry is found at FS:[18]
  61.      * At offset 10h is the fiberData pointer.  The context of the 
  62.      * fiber is stored in there.  
  63.      */
  64. #ifdef HAVE_ASM
  65.     __asm {
  66.         mov    EDX, FS:[18h]
  67.         mov    EAX, DWORD PTR [EDX+10h]
  68.         mov    [fiberData], EAX
  69.     }
  70. #endif
  71.   
  72.     return fiberData;
  73. }
  74.