1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/md/os2/os2gc.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * GC related routines 1.11 + * 1.12 + */ 1.13 +#include "primpl.h" 1.14 + 1.15 +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) 1.16 +{ 1.17 + CONTEXTRECORD context; 1.18 + context.ContextFlags = CONTEXT_INTEGER; 1.19 + 1.20 + if (_PR_IS_NATIVE_THREAD(t)) { 1.21 + context.ContextFlags |= CONTEXT_CONTROL; 1.22 + if (QueryThreadContext(t->md.handle, CONTEXT_CONTROL, &context)) { 1.23 + t->md.gcContext[0] = context.ctx_RegEax; 1.24 + t->md.gcContext[1] = context.ctx_RegEbx; 1.25 + t->md.gcContext[2] = context.ctx_RegEcx; 1.26 + t->md.gcContext[3] = context.ctx_RegEdx; 1.27 + t->md.gcContext[4] = context.ctx_RegEsi; 1.28 + t->md.gcContext[5] = context.ctx_RegEdi; 1.29 + t->md.gcContext[6] = context.ctx_RegEsp; 1.30 + t->md.gcContext[7] = context.ctx_RegEbp; 1.31 + *np = PR_NUM_GCREGS; 1.32 + } else { 1.33 + PR_ASSERT(0);/* XXX */ 1.34 + } 1.35 + } 1.36 + return (PRWord *)&t->md.gcContext; 1.37 +} 1.38 + 1.39 +/* This function is not used right now, but is left as a reference. 1.40 + * If you ever need to get the fiberID from the currently running fiber, 1.41 + * this is it. 1.42 + */ 1.43 +void * 1.44 +GetMyFiberID() 1.45 +{ 1.46 + void *fiberData = 0; 1.47 + 1.48 + /* A pointer to our tib entry is found at FS:[18] 1.49 + * At offset 10h is the fiberData pointer. The context of the 1.50 + * fiber is stored in there. 1.51 + */ 1.52 +#ifdef HAVE_ASM 1.53 + __asm { 1.54 + mov EDX, FS:[18h] 1.55 + mov EAX, DWORD PTR [EDX+10h] 1.56 + mov [fiberData], EAX 1.57 + } 1.58 +#endif 1.59 + 1.60 + return fiberData; 1.61 +}