Back to index

lightning-sunbird  0.9+nobinonly
xptcinvoke_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 #include "xptcprivate.h"
00041 
00042 #include <iostream.h>
00043 
00044 // "This code is for IA64 only"
00045 
00046 
00047 /* invoke_copy_to_stack() will copy from variant array 's' to
00048  * the stack argument area 'mloc', the integer register area 'iloc', and
00049  * the float register area 'floc'.
00050  *
00051  */
00052 extern "C" void
00053 invoke_copy_to_stack(uint64_t* mloc, uint64_t* iloc, uint64_t* floc,
00054   const PRUint32 paramCount, nsXPTCVariant* s)
00055 {
00056   uint64_t* dest = mloc;
00057   PRUint32 len = paramCount;
00058   nsXPTCVariant* source = s;
00059 
00060   PRUint32 indx;
00061   PRUint32 endlen;
00062   endlen = (len > 7) ? 7 : len;
00063   /* handle the memory arguments */
00064   for (indx = 7; indx < len; ++indx)
00065   {
00066     if (source[indx].IsPtrData())
00067     {
00068 #ifdef __LP64__
00069       /* 64 bit pointer mode */
00070       *((void**) dest) = source[indx].ptr;
00071 #else
00072       /* 32 bit pointer mode */
00073       uint32_t* adr = (uint32_t*) dest;
00074       *(adr) = 0;
00075       *(adr+1) = (uint32_t) source[indx].ptr;
00076 #endif
00077     }
00078     else
00079     switch (source[indx].type)
00080     {
00081     case nsXPTType::T_I8    : *(dest) = source[indx].val.i8;  break;
00082     case nsXPTType::T_I16   : *(dest) = source[indx].val.i16; break;
00083     case nsXPTType::T_I32   : *(dest) = source[indx].val.i32; break;
00084     case nsXPTType::T_I64   : *(dest) = source[indx].val.i64; break;
00085     case nsXPTType::T_U8    : *(dest) = source[indx].val.u8;  break;
00086     case nsXPTType::T_U16   : *(dest) = source[indx].val.u16; break;
00087     case nsXPTType::T_U32   : *(dest) = source[indx].val.u32; break;
00088     case nsXPTType::T_U64   : *(dest) = source[indx].val.u64; break;
00089     case nsXPTType::T_FLOAT : *(dest) = source[indx].val.u32; break;
00090     case nsXPTType::T_DOUBLE: *(dest) = source[indx].val.u64; break;
00091     case nsXPTType::T_BOOL  : *(dest) = source[indx].val.b; break;
00092     case nsXPTType::T_CHAR  : *(dest) = source[indx].val.c; break;
00093     case nsXPTType::T_WCHAR : *(dest) = source[indx].val.wc; break;
00094     default:
00095     // all the others are plain pointer types
00096 #ifdef __LP64__
00097       /* 64 bit pointer mode */
00098       *((void**) dest) = source[indx].val.p;
00099 #else
00100       {
00101       /* 32 bit pointer mode */
00102       uint32_t* adr = (uint32_t*) dest;
00103       *(adr) = 0;
00104       *(adr+1) = (uint32_t) source[indx].val.p;
00105       }
00106 #endif
00107     }
00108     ++dest;
00109   }
00110   /* process register arguments */
00111   dest = iloc;
00112   for (indx = 0; indx < endlen; ++indx)
00113   {
00114     if (source[indx].IsPtrData())
00115     {
00116 #ifdef __LP64__
00117       /* 64 bit pointer mode */
00118       *((void**) dest) = source[indx].ptr;
00119 #else
00120       /* 32 bit pointer mode */
00121       uint32_t* adr = (uint32_t*) dest;
00122       *(adr) = 0;
00123       *(adr+1) = (uint32_t) source[indx].ptr;
00124 #endif
00125     }
00126     else
00127     switch (source[indx].type)
00128     {
00129     case nsXPTType::T_I8    : *(dest) = source[indx].val.i8; break;
00130     case nsXPTType::T_I16   : *(dest) = source[indx].val.i16; break;
00131     case nsXPTType::T_I32   : *(dest) = source[indx].val.i32; break;
00132     case nsXPTType::T_I64   : *(dest) = source[indx].val.i64; break;
00133     case nsXPTType::T_U8    : *(dest) = source[indx].val.u8; break;
00134     case nsXPTType::T_U16   : *(dest) = source[indx].val.u16; break;
00135     case nsXPTType::T_U32   : *(dest) = source[indx].val.u32; break;
00136     case nsXPTType::T_U64   : *(dest) = source[indx].val.u64; break;
00137     case nsXPTType::T_FLOAT :
00138       *((double*) (floc++)) = (double) source[indx].val.f;
00139       break;
00140     case nsXPTType::T_DOUBLE:
00141       *((double*) (floc++)) = source[indx].val.d;
00142       break;
00143     case nsXPTType::T_BOOL  : *(dest) = source[indx].val.b; break;
00144     case nsXPTType::T_CHAR  : *(dest) = source[indx].val.c; break;
00145     case nsXPTType::T_WCHAR : *(dest) = source[indx].val.wc; break;
00146     default:
00147     // all the others are plain pointer types
00148 #ifdef __LP64__
00149       /* 64 bit pointer mode */
00150       *((void**) dest) = source[indx].val.p;
00151 #else
00152       {
00153       /* 32 bit pointer mode */
00154       uint32_t* adr = (uint32_t*) dest;
00155       *(adr) = 0;
00156       *(adr+1) = (uint32_t) source[indx].val.p;
00157       }
00158 #endif
00159     }
00160     ++dest;
00161   }
00162 
00163 }
00164