Back to index

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