Back to index

lightning-sunbird  0.9+nobinonly
xptcstubs_linux_s390.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 /* Implement shared vtbl methods. */
00040 
00041 #include "xptcprivate.h"
00042 
00043 static nsresult
00044 PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, 
00045                    PRUint32* a_gpr, PRUint64 *a_fpr, PRUint32 *a_ov)
00046 {
00047 #define PARAM_BUFFER_COUNT     16
00048 
00049     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
00050     nsXPTCMiniVariant* dispatchParams = NULL;
00051     nsIInterfaceInfo* iface_info = NULL;
00052     const nsXPTMethodInfo* info;
00053     PRUint8 paramCount;
00054     PRUint8 i;
00055     nsresult result = NS_ERROR_FAILURE;
00056 
00057     NS_ASSERTION(self,"no self");
00058 
00059     self->GetInterfaceInfo(&iface_info);
00060     NS_ASSERTION(iface_info,"no interface info");
00061 
00062     iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
00063     NS_ASSERTION(info,"no interface info");
00064 
00065     paramCount = info->GetParamCount();
00066 
00067     // setup variant array pointer
00068     if(paramCount > PARAM_BUFFER_COUNT)
00069         dispatchParams = new nsXPTCMiniVariant[paramCount];
00070     else
00071         dispatchParams = paramBuffer;
00072     NS_ASSERTION(dispatchParams,"no place for params");
00073 
00074     PRUint32 gpr = 1, fpr = 0;
00075 
00076     for(i = 0; i < paramCount; i++)
00077     {
00078         const nsXPTParamInfo& param = info->GetParam(i);
00079         const nsXPTType& type = param.GetType();
00080         nsXPTCMiniVariant* dp = &dispatchParams[i];
00081 
00082         if(param.IsOut() || !type.IsArithmetic())
00083         {
00084             if (gpr < 5)
00085                 dp->val.p = (void*) *a_gpr++, gpr++;
00086             else
00087                 dp->val.p = (void*) *a_ov++;
00088             continue;
00089         }
00090         // else
00091         switch(type)
00092         {
00093         case nsXPTType::T_I8     : 
00094             if (gpr < 5)
00095                 dp->val.i8  = *((PRInt32*) a_gpr), a_gpr++, gpr++;
00096             else
00097                 dp->val.i8  = *((PRInt32*) a_ov ), a_ov++;
00098             break;
00099         case nsXPTType::T_I16    : 
00100             if (gpr < 5)
00101                 dp->val.i16 = *((PRInt32*) a_gpr), a_gpr++, gpr++;
00102             else
00103                 dp->val.i16 = *((PRInt32*) a_ov ), a_ov++;
00104             break;
00105         case nsXPTType::T_I32    : 
00106             if (gpr < 5)
00107                 dp->val.i32 = *((PRInt32*) a_gpr), a_gpr++, gpr++;
00108             else
00109                 dp->val.i32 = *((PRInt32*) a_ov ), a_ov++;
00110             break;
00111         case nsXPTType::T_I64    : 
00112             if (gpr < 4)
00113                 dp->val.i64 = *((PRInt64*) a_gpr), a_gpr+=2, gpr+=2;
00114             else
00115                 dp->val.i64 = *((PRInt64*) a_ov ), a_ov+=2, gpr=5;
00116             break;
00117         case nsXPTType::T_U8     : 
00118             if (gpr < 5)
00119                 dp->val.u8  = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00120             else
00121                 dp->val.u8  = *((PRUint32*)a_ov ), a_ov++;
00122             break;
00123         case nsXPTType::T_U16    : 
00124             if (gpr < 5)
00125                 dp->val.u16 = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00126             else
00127                 dp->val.u16 = *((PRUint32*)a_ov ), a_ov++;
00128             break;
00129         case nsXPTType::T_U32    : 
00130             if (gpr < 5)
00131                 dp->val.u32 = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00132             else
00133                 dp->val.u32 = *((PRUint32*)a_ov ), a_ov++;
00134             break;
00135         case nsXPTType::T_U64    : 
00136             if (gpr < 4)
00137                 dp->val.u64 = *((PRUint64*)a_gpr), a_gpr+=2, gpr+=2;
00138             else
00139                 dp->val.u64 = *((PRUint64*)a_ov ), a_ov+=2, gpr=5;
00140             break;
00141         case nsXPTType::T_FLOAT  : 
00142             if (fpr < 2)
00143                 dp->val.f   = *((float*)   a_fpr), a_fpr++, fpr++;
00144             else
00145                 dp->val.f   = *((float*)   a_ov ), a_ov++;
00146             break;
00147         case nsXPTType::T_DOUBLE : 
00148             if (fpr < 2)
00149                 dp->val.d   = *((double*)  a_fpr), a_fpr++, fpr++;
00150             else
00151                 dp->val.d   = *((double*)  a_ov ), a_ov+=2;
00152             break;
00153         case nsXPTType::T_BOOL   : 
00154             if (gpr < 5)
00155                 dp->val.b   = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00156             else
00157                 dp->val.b   = *((PRUint32*)a_ov ), a_ov++;
00158             break;
00159         case nsXPTType::T_CHAR   : 
00160             if (gpr < 5)
00161                 dp->val.c   = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00162             else
00163                 dp->val.c   = *((PRUint32*)a_ov ), a_ov++;
00164             break;
00165         case nsXPTType::T_WCHAR  : 
00166             if (gpr < 5)
00167                 dp->val.wc  = *((PRUint32*)a_gpr), a_gpr++, gpr++;
00168             else
00169                 dp->val.wc  = *((PRUint32*)a_ov ), a_ov++;
00170             break;
00171         default:
00172             NS_ASSERTION(0, "bad type");
00173             break;
00174         }
00175     }
00176 
00177     result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
00178 
00179     NS_RELEASE(iface_info);
00180 
00181     if(dispatchParams != paramBuffer)
00182         delete [] dispatchParams;
00183 
00184     return result;
00185 }
00186 
00187 #define STUB_ENTRY(n) \
00188 nsresult nsXPTCStubBase::Stub##n() \
00189 {                             \
00190     PRUint32 a_gpr[4];        \
00191     PRUint64 a_fpr[2];        \
00192     PRUint32 *a_ov;           \
00193                               \
00194     __asm__ __volatile__      \
00195     (                         \
00196         "l     %0,0(15)\n\t"  \
00197         "ahi   %0,96\n\t"     \
00198         "stm   3,6,0(%3)\n\t" \
00199         "std   0,%1\n\t"      \
00200         "std   2,%2\n\t"      \
00201         : "=&a" (a_ov),       \
00202           "=m" (a_fpr[0]),    \
00203           "=m" (a_fpr[1])     \
00204         : "a" (a_gpr)         \
00205        : "memory", "cc",      \
00206          "3", "4", "5", "6"   \
00207     );                        \
00208                               \
00209     return PrepareAndDispatch(this, n, a_gpr, a_fpr, a_ov); \
00210 }
00211 
00212 #define SENTINEL_ENTRY(n) \
00213 nsresult nsXPTCStubBase::Sentinel##n() \
00214 { \
00215     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
00216     return NS_ERROR_NOT_IMPLEMENTED; \
00217 }
00218 
00219 #include "xptcstubsdef.inc"
00220