Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_ipf64.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 #include <stdint.h>
00046 
00047 // "This code is for IA64 only"
00048 
00049 /* Implement shared vtbl methods. */
00050 
00051 extern "C" nsresult
00052 PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex,
00053   uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
00054 {
00055 
00056 #define PARAM_BUFFER_COUNT     16
00057 
00058   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00059   nsXPTCMiniVariant* dispatchParams = NULL;
00060   nsIInterfaceInfo* iface_info = NULL;
00061   const nsXPTMethodInfo* info;
00062   nsresult result = NS_ERROR_FAILURE;
00063   uint64_t* iargs = intargs;
00064   uint64_t* fargs = floatargs;
00065   PRUint8 paramCount;
00066   PRUint8 i;
00067 
00068   NS_ASSERTION(self,"no self");
00069 
00070   self->GetInterfaceInfo(&iface_info);
00071   NS_ASSERTION(iface_info,"no interface info");
00072 
00073   iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00074   NS_ASSERTION(info,"no interface info");
00075 
00076   paramCount = info->GetParamCount();
00077 
00078   // setup variant array pointer
00079   if(paramCount > PARAM_BUFFER_COUNT)
00080     dispatchParams = new nsXPTCMiniVariant[paramCount];
00081   else
00082     dispatchParams = paramBuffer;
00083   NS_ASSERTION(dispatchParams,"no place for params");
00084 
00085   for(i = 0; i < paramCount; ++i)
00086   {
00087     int isfloat = 0;
00088     const nsXPTParamInfo& param = info->GetParam(i);
00089     const nsXPTType& type = param.GetType();
00090     nsXPTCMiniVariant* dp = &dispatchParams[i];
00091 
00092     if(param.IsOut() || !type.IsArithmetic())
00093     {
00094 #ifdef __LP64__
00095         /* 64 bit pointer mode */
00096         dp->val.p = (void*) *iargs;
00097 #else
00098         /* 32 bit pointer mode */
00099         uint32_t* adr = (uint32_t*) iargs;
00100         dp->val.p = (void*) (*(adr+1));
00101 #endif
00102     }
00103     else
00104     switch(type)
00105     {
00106     case nsXPTType::T_I8     : dp->val.i8  = *(iargs); break;
00107     case nsXPTType::T_I16    : dp->val.i16 = *(iargs); break;
00108     case nsXPTType::T_I32    : dp->val.i32 = *(iargs); break;
00109     case nsXPTType::T_I64    : dp->val.i64 = *(iargs); break;
00110     case nsXPTType::T_U8     : dp->val.u8  = *(iargs); break;
00111     case nsXPTType::T_U16    : dp->val.u16 = *(iargs); break;
00112     case nsXPTType::T_U32    : dp->val.u32 = *(iargs); break;
00113     case nsXPTType::T_U64    : dp->val.u64 = *(iargs); break;
00114     case nsXPTType::T_FLOAT  :
00115       isfloat = 1;
00116       if (i < 7)
00117         dp->val.f = (float) *((double*) fargs); /* register */
00118       else
00119         dp->val.u32 = *(fargs); /* memory */
00120       break;
00121     case nsXPTType::T_DOUBLE :
00122       isfloat = 1;
00123       dp->val.u64 = *(fargs);
00124       break;
00125     case nsXPTType::T_BOOL   : dp->val.b   = *(iargs); break;
00126     case nsXPTType::T_CHAR   : dp->val.c   = *(iargs); break;
00127     case nsXPTType::T_WCHAR  : dp->val.wc  = *(iargs); break;
00128     default:
00129       NS_ASSERTION(0, "bad type");
00130       break;
00131     }
00132     if (i < 7)
00133     {
00134       /* we are parsing register arguments */
00135       if (i == 6)
00136       {
00137         // run out of register arguments, move on to memory arguments
00138         iargs = restargs;
00139         fargs = restargs;
00140       }
00141       else
00142       {
00143         ++iargs; // advance one integer register slot
00144         if (isfloat) ++fargs; // advance float register slot if isfloat
00145       }
00146     }
00147     else
00148     {
00149       /* we are parsing memory arguments */
00150       ++iargs;
00151       ++fargs;
00152     }
00153   }
00154 
00155   result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
00156 
00157   NS_RELEASE(iface_info);
00158 
00159   if(dispatchParams != paramBuffer)
00160     delete [] dispatchParams;
00161 
00162   return result;
00163 }
00164 
00165 extern "C" int SharedStub(PRUint64,PRUint64,PRUint64,PRUint64,
00166  PRUint64,PRUint64,PRUint64,PRUint64,PRUint64,PRUint64 *);
00167 
00168 /* Variable a0-a7 were put there so we can have access to the 8 input
00169    registers on Stubxyz entry */
00170 
00171 #define STUB_ENTRY(n) \
00172 nsresult nsXPTCStubBase::Stub##n(PRUint64 a1, \
00173 PRUint64 a2,PRUint64 a3,PRUint64 a4,PRUint64 a5,PRUint64 a6,PRUint64 a7, \
00174 PRUint64 a8) \
00175 { uint64_t a0 = (uint64_t) this; \
00176  return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(PRUint64) n, &a8); \
00177 }
00178 
00179 #define SENTINEL_ENTRY(n) \
00180 nsresult nsXPTCStubBase::Sentinel##n() \
00181 { \
00182     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00183     return NS_ERROR_NOT_IMPLEMENTED; \
00184 }
00185 
00186 #include "xptcstubsdef.inc"
00187