This is xptcall code for Tru64 Unix (Formerly Digital Unix, Formerly OSF/1).

It was written by Steve Streeter <streeter@zk3.dec.com> of Compaq.
r=jlnance a=shaver
This commit is contained in:
jim_nance%yahoo.com 2000-03-07 00:15:07 +00:00
parent 9f2fcf5a57
commit fd067ebe58
8 changed files with 353 additions and 3 deletions

View File

@ -239,7 +239,7 @@ TAR = tar
endif
endif
ifeq ($(OS_ARCH),OpenVMS)
ifneq (,$(filter OpenVMS OSF1,$(OS_ARCH)))
include $(topsrcdir)/config/$(OS_ARCH).mk
endif

View File

@ -38,7 +38,7 @@ extern int usleep(unsigned int);
** we define that the build breaks long before getting here. So
** put the prototype here explicitly.
*/
int usleep(useconds_t);
extern "C" int usleep(useconds_t);
#endif
#if defined(__QNX__)
#define usleep(s) sleep(s)

View File

@ -32,7 +32,7 @@
** we define that the build breaks long before getting here. So
** put the prototype here explicitly.
*/
int usleep(useconds_t);
extern "C" int usleep(useconds_t);
#endif
//////////////////////////////////////////////////////////////////

View File

@ -64,6 +64,13 @@ endif
# Alpha
######################################################################
#
# Tru64/Alpha
#
ifeq ($(OS_ARCH)$(OS_TEST),OSF1alpha)
CPPSRCS := xptcinvoke_osf1_alpha.cpp xptcstubs_osf1_alpha.cpp
ASFILES := xptcinvoke_asm_osf1_alpha.s xptcstubs_asm_osf1_alpha.s
endif
#
# Linux/Alpha
#
ifneq (,$(filter Linuxalpha FreeBSDalpha NetBSDalpha,$(OS_ARCH)$(OS_TEST)))

View File

@ -0,0 +1,83 @@
/*
* XPTC_PUBLIC_API(nsresult)
* XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
* PRUint32 paramCount, nsXPTCVariant* params)
*/
.text
.align 4
.globl XPTC_InvokeByIndex
.ent XPTC_InvokeByIndex
XPTC_InvokeByIndex:
.frame $15,32,$26,0
.mask 0x4008000,-32
ldgp $29,0($27)
XPTC_InvokeByIndexXv:
subq $30,32,$30
stq $26,0($30)
stq $15,8($30)
bis $30,$30,$15
.prologue 1
/*
* Allocate enough stack space to hold the greater of 6 or "paramCount"+1
* parameters. (+1 for "this" pointer) Room for at least 6 parameters
* is required for storage of those passed via registers.
*/
bis $31,5,$2 /* count = MAX(5, "paramCount") */
cmplt $2,$18,$1
cmovne $1,$18,$2
s8addq $2,16,$1 /* room for count+1 params (8 bytes each) */
bic $1,15,$1 /* stack space is rounded up to 0 % 16 */
subq $30,$1,$30
stq $16,0($30) /* save "that" (as "this" pointer) */
stq $17,16($15) /* save "methodIndex" */
addq $30,8,$16 /* pass stack pointer */
bis $18,$18,$17 /* pass "paramCount" */
bis $19,$19,$18 /* pass "params" */
jsr $26,invoke_copy_to_stack /* call invoke_copy_to_stack */
ldgp $29,0($26)
/*
* Copy the first 6 parameters to registers and remove from stack frame.
* Both the integer and floating point registers are set for each parameter
* except the first which is the "this" pointer. (integer only)
* The floating point registers are all set as doubles since the
* invoke_copy_to_stack function should have converted the floats.
*/
ldq $16,0($30) /* integer registers */
ldq $17,8($30)
ldq $18,16($30)
ldq $19,24($30)
ldq $20,32($30)
ldq $21,40($30)
ldt $f17,8($30) /* floating point registers */
ldt $f18,16($30)
ldt $f19,24($30)
ldt $f20,32($30)
ldt $f21,40($30)
addq $30,48,$30 /* remove params from stack */
/*
* Call the virtual function with the constructed stack frame.
*/
bis $16,$16,$1 /* load "this" */
ldq $2,16($15) /* load "methodIndex" */
ldq $1,0($1) /* load vtable */
s8addq $2,0,$2 /* vtable index = "methodIndex" * 8 + 16 */
addq $1,$2,$1
ldq $27,0($1) /* load address of function */
jsr $26,($27),0 /* call virtual function */
ldgp $29,0($26)
bis $15,$15,$30
ldq $26,0($30)
ldq $15,8($30)
addq $30,32,$30
ret $31,($26),1
.end XPTC_InvokeByIndex

View File

@ -0,0 +1,78 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Platform specific code to invoke XPCOM methods on native objects */
/* contributed by Steve Streeter <Stephen.Streeter@Compaq.com> */
#include "xptcprivate.h"
/* Prototype specifies unmangled function name */
extern "C" void
invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s);
extern "C" void
invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s)
{
const PRUint8 NUM_ARG_REGS = 6-1; // -1 for "this" pointer
for(PRUint32 i = 0; i < paramCount; i++, d++, s++)
{
if(s->IsPtrData())
{
*d = (PRUint64)s->ptr;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 : *d = (PRUint64)s->val.i8; break;
case nsXPTType::T_I16 : *d = (PRUint64)s->val.i16; break;
case nsXPTType::T_I32 : *d = (PRUint64)s->val.i32; break;
case nsXPTType::T_I64 : *d = (PRUint64)s->val.i64; break;
case nsXPTType::T_U8 : *d = (PRUint64)s->val.u8; break;
case nsXPTType::T_U16 : *d = (PRUint64)s->val.u16; break;
case nsXPTType::T_U32 : *d = (PRUint64)s->val.u32; break;
case nsXPTType::T_U64 : *d = (PRUint64)s->val.u64; break;
case nsXPTType::T_FLOAT :
if(i < NUM_ARG_REGS)
{
// convert floats to doubles if they are to be passed
// via registers so we can just deal with doubles later
union { PRUint64 u64; double d; } t;
t.d = (double)s->val.f;
*d = t.u64;
}
else
// otherwise copy to stack normally
*d = (PRUint64)s->val.u32;
break;
case nsXPTType::T_DOUBLE : *d = (PRUint64)s->val.u64; break;
case nsXPTType::T_BOOL : *d = (PRUint64)s->val.b; break;
case nsXPTType::T_CHAR : *d = (PRUint64)s->val.c; break;
case nsXPTType::T_WCHAR : *d = (PRUint64)s->val.wc; break;
default:
// all the others are plain pointer types
*d = (PRUint64)s->val.p;
break;
}
}
}

View File

@ -0,0 +1,48 @@
.text
.align 5
.globl SharedStub
.ent SharedStub
SharedStub:
.frame $30, 96, $26, 0
.mask 0x4000000,-96
ldgp $29,0($27)
SharedStubXv:
subq $30,96,$30
stq $26,0($30)
.prologue 1
stt $f17,16($30)
stt $f18,24($30)
stt $f19,32($30)
stt $f20,40($30)
stt $f21,48($30)
stq $17,56($30)
stq $18,64($30)
stq $19,72($30)
stq $20,80($30)
stq $21,88($30)
bis $1,$1,$17
addq $30,16,$18
bsr $26,PrepareAndDispatch
ldq $26,0($30)
addq $30,96,$30
ret $31,($26),1
.end SharedStub
#define STUB_ENTRY(n) ;\
.text ;\
.align 5 ;\
.globl Stub##n##__14nsXPTCStubBase ;\
.globl Stub##n##__14nsXPTCStubBaseXv ;\
.ent Stub##n##__14nsXPTCStubBase ;\
Stub##n##__14nsXPTCStubBase: ;\
.frame $30,0,$26,0 ;\
ldgp $29,0($27) ;\
.prologue 1 ;\
Stub##n##__14nsXPTCStubBaseXv: ;\
lda $1,n ;\
br $31,SharedStubXv ;\
.end Stub##n##__14nsXPTCStubBase \
#define SENTINEL_ENTRY(n) \
#include "xptcstubsdef.inc"

View File

@ -0,0 +1,134 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Implement shared vtbl methods. */
/* contributed by Glen Nakamura <glen.nakamura@usa.net> */
#include "xptcprivate.h"
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint64* args)
{
const PRUint8 PARAM_BUFFER_COUNT = 16;
const PRUint8 NUM_ARG_REGS = 6-1; // -1 for "this" pointer
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
nsXPTCMiniVariant* dispatchParams = NULL;
nsIInterfaceInfo* iface_info = NULL;
const nsXPTMethodInfo* info;
PRUint8 paramCount;
PRUint8 i;
nsresult result = NS_ERROR_FAILURE;
NS_ASSERTION(self,"no self");
self->GetInterfaceInfo(&iface_info);
NS_ASSERTION(iface_info,"no interface info");
iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
NS_ASSERTION(info,"no interface info");
paramCount = info->GetParamCount();
// setup variant array pointer
if(paramCount > PARAM_BUFFER_COUNT)
dispatchParams = new nsXPTCMiniVariant[paramCount];
else
dispatchParams = paramBuffer;
NS_ASSERTION(dispatchParams,"no place for params");
// args[0] to args[NUM_ARG_REGS] hold floating point register values
PRUint64* ap = args + NUM_ARG_REGS;
for(i = 0; i < paramCount; i++, ap++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
dp->val.p = (void*) *ap;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8 : dp->val.i8 = (PRInt8) *ap; break;
case nsXPTType::T_I16 : dp->val.i16 = (PRInt16) *ap; break;
case nsXPTType::T_I32 : dp->val.i32 = (PRInt32) *ap; break;
case nsXPTType::T_I64 : dp->val.i64 = (PRInt64) *ap; break;
case nsXPTType::T_U8 : dp->val.u8 = (PRUint8) *ap; break;
case nsXPTType::T_U16 : dp->val.u16 = (PRUint16) *ap; break;
case nsXPTType::T_U32 : dp->val.u32 = (PRUint32) *ap; break;
case nsXPTType::T_U64 : dp->val.u64 = (PRUint64) *ap; break;
case nsXPTType::T_FLOAT :
if(i < NUM_ARG_REGS)
{
// floats passed via registers are stored as doubles
// in the first NUM_ARG_REGS entries in args
dp->val.u64 = (PRUint64) args[i];
dp->val.f = (float) dp->val.d; // convert double to float
}
else
dp->val.u32 = (PRUint32) *ap;
break;
case nsXPTType::T_DOUBLE :
// doubles passed via registers are also stored
// in the first NUM_ARG_REGS entries in args
dp->val.u64 = (i < NUM_ARG_REGS) ? args[i] : *ap;
break;
case nsXPTType::T_BOOL : dp->val.b = (PRBool) *ap; break;
case nsXPTType::T_CHAR : dp->val.c = (char) *ap; break;
case nsXPTType::T_WCHAR : dp->val.wc = (PRUnichar) *ap; break;
default:
NS_ASSERTION(0, "bad type");
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
/*
* nsresult nsXPTCStubBase::Stub##n() ;\
* Sets arguments to registers and calls PrepareAndDispatch.
* This is defined in the ASM file.
*/
#define STUB_ENTRY(n) \
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"