Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_ipf32.cpp
Go to the documentation of this file.
00001 
00002 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1999
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 
00041 #include "xptcprivate.h"
00042 
00043 #include <stddef.h>
00044 #include <stdlib.h>
00045 
00046 // "This code is for IA64 only"
00047 
00048 /* Implement shared vtbl methods. */
00049 
00050 extern "C" nsresult
00051 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
00052   uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
00053 {
00054 
00055 #define PARAM_BUFFER_COUNT     16
00056 
00057   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00058   nsXPTCMiniVariant* dispatchParams = NULL;
00059   nsIInterfaceInfo* iface_info = NULL;
00060   const nsXPTMethodInfo* info;
00061   nsresult result = NS_ERROR_FAILURE;
00062   uint64_t* iargs = intargs;
00063   uint64_t* fargs = floatargs;
00064   PRUint8 paramCount;
00065   PRUint8 i;
00066 
00067   NS_ASSERTION(self,"no self");
00068 
00069   self->GetInterfaceInfo(&iface_info);
00070   NS_ASSERTION(iface_info,"no interface info");
00071 
00072   iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00073   NS_ASSERTION(info,"no interface info");
00074 
00075   paramCount = info->GetParamCount();
00076 
00077   // setup variant array pointer
00078   if(paramCount > PARAM_BUFFER_COUNT)
00079     dispatchParams = new nsXPTCMiniVariant[paramCount];
00080   else
00081     dispatchParams = paramBuffer;
00082   NS_ASSERTION(dispatchParams,"no place for params");
00083 
00084   for(i = 0; i < paramCount; ++i)
00085   {
00086     int isfloat = 0;
00087     const nsXPTParamInfo& param = info->GetParam(i);
00088     const nsXPTType& type = param.GetType();
00089     nsXPTCMiniVariant* dp = &dispatchParams[i];
00090 
00091     if(param.IsOut() || !type.IsArithmetic())
00092     {
00093 #ifdef __LP64__
00094         /* 64 bit pointer mode */
00095         dp->val.p = (void*) *iargs;
00096 #else
00097         /* 32 bit pointer mode */
00098         uint32_t* adr = (uint32_t*) iargs;
00099         dp->val.p = (void*) (*(adr+1));
00100 #endif
00101     }
00102     else
00103     switch(type)
00104     {
00105     case nsXPTType::T_I8     : dp->val.i8  = *(iargs); break;
00106     case nsXPTType::T_I16    : dp->val.i16 = *(iargs); break;
00107     case nsXPTType::T_I32    : dp->val.i32 = *(iargs); break;
00108     case nsXPTType::T_I64    : dp->val.i64 = *(iargs); break;
00109     case nsXPTType::T_U8     : dp->val.u8  = *(iargs); break;
00110     case nsXPTType::T_U16    : dp->val.u16 = *(iargs); break;
00111     case nsXPTType::T_U32    : dp->val.u32 = *(iargs); break;
00112     case nsXPTType::T_U64    : dp->val.u64 = *(iargs); break;
00113     case nsXPTType::T_FLOAT  :
00114       isfloat = 1;
00115       if (i < 7)
00116         dp->val.f = (float) *((double*) fargs); /* register */
00117       else
00118         dp->val.u32 = *(fargs); /* memory */
00119       break;
00120     case nsXPTType::T_DOUBLE :
00121       isfloat = 1;
00122       dp->val.u64 = *(fargs);
00123       break;
00124     case nsXPTType::T_BOOL   : dp->val.b   = *(iargs); break;
00125     case nsXPTType::T_CHAR   : dp->val.c   = *(iargs); break;
00126     case nsXPTType::T_WCHAR  : dp->val.wc  = *(iargs); break;
00127     default:
00128       NS_ASSERTION(0, "bad type");
00129       break;
00130     }
00131     if (i < 7)
00132     {
00133       /* we are parsing register arguments */
00134       if (i == 6)
00135       {
00136         // run out of register arguments, move on to memory arguments
00137         iargs = restargs;
00138         fargs = restargs;
00139       }
00140       else
00141       {
00142         ++iargs; // advance one integer register slot
00143         if (isfloat) ++fargs; // advance float register slot if isfloat
00144       }
00145     }
00146     else
00147     {
00148       /* we are parsing memory arguments */
00149       ++iargs;
00150       ++fargs;
00151     }
00152   }
00153 
00154   result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
00155 
00156   NS_RELEASE(iface_info);
00157 
00158   if(dispatchParams != paramBuffer)
00159     delete [] dispatchParams;
00160 
00161   return result;
00162 }
00163 
00164 extern "C" int SharedStub(PRUint64,PRUint64,PRUint64,PRUint64,
00165  PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64 *);
00166 
00167 /* Variable a0-a7 were put there so we can have access to the 8 input
00168    registers on Stubxyz entry */
00169 
00170 #define STUB_ENTRY(n) \
00171 nsresult nsXPTCStubBase::Stub##n(PRUint64 a1, \
00172 PRUint64 a2,PRUint64 a3,PRUint64 a4,PRUint64 a5,PRUint64 a6,PRUint64 a7, \
00173 PRUint64 a8) \
00174 { uint64_t a0 = (uint64_t) this; \
00175  return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(PRUint64) n, &a8); \
00176 }
00177 
00178 #define SENTINEL_ENTRY(n) \
00179 nsresult nsXPTCStubBase::Sentinel##n() \
00180 { \
00181     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00182     return NS_ERROR_NOT_IMPLEMENTED; \
00183 }
00184 
00185 #include "xptcstubsdef.inc"
00186