Back to index

lightning-sunbird  0.9+nobinonly
xptcinvoke_sparc64_openbsd.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * The contents of this file are subject to the Mozilla Public
00004  * License Version 1.1 (the "License"); you may not use this file
00005  * except in compliance with the License. You may obtain a copy of
00006  * the License at http://www.mozilla.org/MPL/
00007  * 
00008  * Software distributed under the License is distributed on an "AS
00009  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00010  * implied. See the License for the specific language governing
00011  * rights and limitations under the License.
00012  * 
00013  * The Original Code is mozilla.org code.
00014  * 
00015  * The Initial Developer of the Original Code is Netscape
00016  * Communications Corporation. Portions created by Netscape are
00017  * Copyright (C) 2001 Netscape Communications Corporation. All
00018  * Rights Reserved.
00019  * 
00020  * Contributor(s): 
00021  *   Stuart Parmenter <pavlov@netscape.com>
00022  *   Chris Seawood <cls@seawood.org>
00023  */
00024 
00025 
00026 /* Platform specific code to invoke XPCOM methods on native objects */
00027 
00028 #include "xptcprivate.h"
00029 
00030 #if !defined(__sparc) && !defined(__sparc__)
00031 #error "This code is for Sparc only"
00032 #endif
00033 
00034 extern "C" PRUint64
00035 invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s)
00036 {
00037   /*
00038     We need to copy the parameters for this function to locals and use them
00039     from there since the parameters occupy the same stack space as the stack
00040     we're trying to populate.
00041   */
00042   PRUint64 *l_d = d;
00043   nsXPTCVariant *l_s = s;
00044   PRUint64 l_paramCount = paramCount;
00045   PRUint64 regCount = 0;  // return the number of registers to load from the stack
00046 
00047   for(PRUint64 i = 0; i < l_paramCount; i++, l_d++, l_s++)
00048   {
00049     if (regCount < 5) regCount++;
00050 
00051     if (l_s->IsPtrData())
00052     {
00053       *l_d = (PRUint64)l_s->ptr;
00054       continue;
00055     }
00056     switch (l_s->type)
00057     {
00058       case nsXPTType::T_I8    : *((PRInt64*)l_d)     = l_s->val.i8;    break;
00059       case nsXPTType::T_I16   : *((PRInt64*)l_d)     = l_s->val.i16;   break;
00060       case nsXPTType::T_I32   : *((PRInt64*)l_d)     = l_s->val.i32;   break;
00061       case nsXPTType::T_I64   : *((PRInt64*)l_d)     = l_s->val.i64;   break;
00062       
00063       case nsXPTType::T_U8    : *((PRUint64*)l_d)    = l_s->val.u8;    break;
00064       case nsXPTType::T_U16   : *((PRUint64*)l_d)    = l_s->val.u16;   break;
00065       case nsXPTType::T_U32   : *((PRUint64*)l_d)    = l_s->val.u32;   break;
00066       case nsXPTType::T_U64   : *((PRUint64*)l_d)    = l_s->val.u64;   break;
00067 
00068       /* in the case of floats, we want to put the bits in to the
00069          64bit space right justified... floats in the paramter array on
00070          sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip
00071          the space that would be occupied by %f0, %f2, etc.
00072       */
00073       case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f;     break;
00074       case nsXPTType::T_DOUBLE: *((double*)l_d)      = l_s->val.d;     break;
00075       case nsXPTType::T_BOOL  : *((PRInt64*)l_d)     = l_s->val.b;     break;
00076       case nsXPTType::T_CHAR  : *((PRUint64*)l_d)    = l_s->val.c;     break;
00077       case nsXPTType::T_WCHAR : *((PRInt64*)l_d)     = l_s->val.wc;    break;
00078 
00079       default:
00080         // all the others are plain pointer types
00081         *((void**)l_d) = l_s->val.p;
00082         break;
00083     }
00084   }
00085   
00086   return regCount;
00087 }