michael@0: michael@0: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "xptcprivate.h" michael@0: michael@0: #if _HPUX michael@0: #error "This code is for HP-PA RISC 32 bit mode only" michael@0: #endif michael@0: michael@0: #include michael@0: michael@0: typedef unsigned nsXPCVariant; michael@0: michael@0: extern "C" int32_t michael@0: invoke_count_bytes(nsISupports* that, const uint32_t methodIndex, michael@0: const uint32_t paramCount, const nsXPTCVariant* s) michael@0: { michael@0: int32_t result = 4; /* variant records do not include self pointer */ michael@0: michael@0: /* counts the number of bytes required by the argument stack, michael@0: 64 bit integer, and double requires 8 bytes. All else requires michael@0: 4 bytes. michael@0: */ michael@0: michael@0: { michael@0: uint32_t indx; michael@0: for (indx = paramCount; indx > 0; --indx, ++s) michael@0: { michael@0: if (! s->IsPtrData()) michael@0: { michael@0: if (s->type == nsXPTType::T_I64 || s->type == nsXPTType::T_U64 || michael@0: s->type == nsXPTType::T_DOUBLE) michael@0: { michael@0: /* 64 bit integer and double aligned on 8 byte boundaries */ michael@0: result += (result & 4) + 8; michael@0: continue; michael@0: } michael@0: } michael@0: result += 4; /* all other cases use 4 bytes */ michael@0: } michael@0: } michael@0: result -= 72; /* existing stack buffer is 72 bytes */ michael@0: if (result < 0) michael@0: return 0; michael@0: { michael@0: /* round up to 64 bytes boundary */ michael@0: int32_t remainder = result & 63; michael@0: return (remainder == 0) ? result : (result + 64 - remainder); michael@0: } michael@0: } michael@0: michael@0: extern "C" uint32_t michael@0: invoke_copy_to_stack(uint32_t* d, michael@0: const uint32_t paramCount, nsXPTCVariant* s) michael@0: { michael@0: michael@0: typedef struct michael@0: { michael@0: uint32_t hi; michael@0: uint32_t lo; michael@0: } DU; michael@0: michael@0: uint32_t* dest = d; michael@0: nsXPTCVariant* source = s; michael@0: /* we clobber param vars by copying stuff on stack, have to use local var */ michael@0: michael@0: uint32_t floatflags = 0; michael@0: /* flag indicating which floating point registers to load */ michael@0: michael@0: uint32_t regwords = 1; /* register 26 is reserved for ptr to 'that' */ michael@0: uint32_t indx; michael@0: michael@0: for (indx = paramCount; indx > 0; --indx, --dest, ++source) michael@0: { michael@0: if (source->IsPtrData()) michael@0: { michael@0: *((void**) dest) = source->ptr; michael@0: ++regwords; michael@0: continue; michael@0: } michael@0: switch (source->type) michael@0: { michael@0: case nsXPTType::T_I8 : *((int32_t*) dest) = source->val.i8; break; michael@0: case nsXPTType::T_I16 : *((int32_t*) dest) = source->val.i16; break; michael@0: case nsXPTType::T_I32 : *((int32_t*) dest) = source->val.i32; break; michael@0: case nsXPTType::T_I64 : michael@0: case nsXPTType::T_U64 : michael@0: if (regwords & 1) michael@0: { michael@0: /* align on double word boundary */ michael@0: --dest; michael@0: ++regwords; michael@0: } michael@0: *((uint32_t*) dest) = ((DU *) source)->lo; michael@0: *((uint32_t*) --dest) = ((DU *) source)->hi; michael@0: /* big endian - hi word in low addr */ michael@0: regwords += 2; michael@0: continue; michael@0: case nsXPTType::T_DOUBLE : michael@0: if (regwords & 1) michael@0: { michael@0: /* align on double word boundary */ michael@0: --dest; michael@0: ++regwords; michael@0: } michael@0: switch (regwords) /* load double precision float register */ michael@0: { michael@0: case 2: michael@0: floatflags |= 1; michael@0: } michael@0: *((uint32_t*) dest) = ((DU *) source)->lo; michael@0: *((uint32_t*) --dest) = ((DU *) source)->hi; michael@0: /* big endian - hi word in low addr */ michael@0: regwords += 2; michael@0: continue; michael@0: case nsXPTType::T_FLOAT : michael@0: switch (regwords) /* load single precision float register */ michael@0: { michael@0: case 1: michael@0: floatflags |= 2; michael@0: break; michael@0: case 2: michael@0: floatflags |= 4; michael@0: break; michael@0: case 3: michael@0: floatflags |= 8; michael@0: } michael@0: *((float*) dest) = source->val.f; michael@0: break; michael@0: case nsXPTType::T_U8 : *((uint32_t*) (dest)) = source->val.u8; break; michael@0: case nsXPTType::T_U16 : *((uint32_t*) (dest)) = source->val.u16; break; michael@0: case nsXPTType::T_U32 : *((uint32_t*) (dest)) = source->val.u32; break; michael@0: case nsXPTType::T_BOOL : *((uint32_t*) (dest)) = source->val.b; break; michael@0: case nsXPTType::T_CHAR : *((uint32_t*) (dest)) = source->val.c; break; michael@0: case nsXPTType::T_WCHAR : *((int32_t*) (dest)) = source->val.wc; break; michael@0: michael@0: default: michael@0: // all the others are plain pointer types michael@0: *((void**) dest) = source->val.p; michael@0: } michael@0: ++regwords; michael@0: } michael@0: return floatflags; michael@0: } michael@0: