Kaydet (Commit) 3cb45765 authored tarafından James Clarke's avatar James Clarke Kaydeden (comit) Rene Engelhard

(initial) sparc64 port

Change-Id: I8ec9bb5415a9e6b9083ba89a7790872d67625de1
üst 9dd8a0dc
......@@ -159,6 +159,13 @@ bridge_noopt_objects := cpp2uno uno2cpp
bridge_exception_objects := except
endif
else ifeq ($(OS)-$(CPUNAME),LINUX-SPARC64)
bridges_SELECTED_BRIDGE := gcc3_linux_sparc64
bridge_asm_objects := call
bridge_noopt_objects := cpp2uno uno2cpp
bridge_exception_objects := except
else ifeq ($(CPUNAME),X86_64)
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
......
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
.global doFlushCode
doFlushCode:
.L: flush %o0
deccc %o1
bne .L
add %o0, 8, %o0
retl
nop
.size doFlushCode,(.-doFlushCode)
.align 8
// %{o->i}0: index
// %{o->i}1: pCallStack = %{s->f}p+2047
// %{o->i}2: vtableOffset
// %{o->i}3: cpp_vtable_call
// %{o->i}4: frameSize (negative)
// [%{s->f}p+2047+128]: param 0 ...
.file "call.s"
.text
.align 4
.global privateSnippetExecutor
.type privateSnippetExecutor, #function
privateSnippetExecutor:
.LFB0:
//// Already done by codeSnippet
.cfi_startproc
save %sp, -176, %sp
.cfi_window_save
// Register 8 (%o0) saved to register 24 (%i0)
.cfi_register 8, 24
// Register 9 (%o1) saved to register 25 (%i1)
.cfi_register 9, 25
// Register 10 (%o2) saved to register 26 (%i2)
.cfi_register 10, 26
// Register 11 (%o3) saved to register 27 (%i3)
.cfi_register 11, 27
// Register 12 (%o4) saved to register 28 (%i4)
.cfi_register 12, 28
// Register 15 (%o7) saved to register 31 (%i7)
.cfi_register 15, 31
// Use register 30 (%i6 - saved stack pointer) for Call Frame Address
.cfi_def_cfa_register 30
mov %i0, %o0
mov %i1, %o1
mov %i2, %o2
jmpl %i3, %o7
nop
mov %o0, %i0
mov %o1, %i1
mov %o2, %i2
mov %o3, %i3
ret
restore
.cfi_endproc
.LFE0:
.size privateSnippetExecutor,(.-privateSnippetExecutor)
.section .note.GNU-stack,"",@progbits
.align 8
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <cxxabi.h>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <osl/mutex.hxx>
#include <com/sun/star/uno/genfunc.hxx>
#include <typelib/typedescription.hxx>
#include <uno/any2.h>
#include <unordered_map>
#include "share.hxx"
using namespace ::std;
using namespace ::osl;
using namespace ::com::sun::star::uno;
using namespace ::__cxxabiv1;
namespace CPPU_CURRENT_NAMESPACE
{
void dummy_can_throw_anything( char const * )
{
}
static OUString toUNOname( char const * p )
{
#if defined BRIDGES_DEBUG
char const * start = p;
#endif
// example: N3com3sun4star4lang24IllegalArgumentExceptionE
OUStringBuffer buf( 64 );
assert( 'N' == *p );
++p; // skip N
while ('E' != *p)
{
// read chars count
long n = (*p++ - '0');
while ('0' <= *p && '9' >= *p)
{
n *= 10;
n += (*p++ - '0');
}
buf.appendAscii( p, n );
p += n;
if ('E' != *p)
buf.append( '.' );
}
#if defined BRIDGES_DEBUG
OUString ret( buf.makeStringAndClear() );
OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
return ret;
#else
return buf.makeStringAndClear();
#endif
}
class RTTI
{
typedef std::unordered_map< OUString, type_info *, OUStringHash > t_rtti_map;
Mutex m_mutex;
t_rtti_map m_rttis;
t_rtti_map m_generatedRttis;
void * m_hApp;
public:
RTTI();
~RTTI();
type_info * getRTTI( typelib_CompoundTypeDescription * );
};
RTTI::RTTI()
: m_hApp( dlopen( 0, RTLD_LAZY ) )
{
}
RTTI::~RTTI()
{
dlclose( m_hApp );
}
type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr )
{
type_info * rtti;
OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
MutexGuard guard( m_mutex );
t_rtti_map::const_iterator iFind( m_rttis.find( unoName ) );
if (iFind == m_rttis.end())
{
// RTTI symbol
OStringBuffer buf( 64 );
buf.append( "_ZTIN" );
sal_Int32 index = 0;
do
{
OUString token( unoName.getToken( 0, '.', index ) );
buf.append( token.getLength() );
OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
buf.append( c_token );
}
while (index >= 0);
buf.append( 'E' );
OString symName( buf.makeStringAndClear() );
rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
if (rtti)
{
pair< t_rtti_map::iterator, bool > insertion(
m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
assert(insertion.second);
}
else
{
// try to lookup the symbol in the generated rtti map
t_rtti_map::const_iterator iiFind( m_generatedRttis.find( unoName ) );
if (iiFind == m_generatedRttis.end())
{
// we must generate it !
// symbol and rtti-name is nearly identical,
// the symbol is prefixed with _ZTI
char const * rttiName = symName.getStr() +4;
#if defined BRIDGES_DEBUG
fprintf( stderr,"generated rtti for %s\n", rttiName );
#endif
if (pTypeDescr->pBaseTypeDescription)
{
// ensure availability of base
type_info * base_rtti = getRTTI(
(typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
rtti = new __si_class_type_info(
strdup( rttiName ), (__class_type_info *)base_rtti );
}
else
{
// this class has no base class
rtti = new __class_type_info( strdup( rttiName ) );
}
pair< t_rtti_map::iterator, bool > insertion(
m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
assert(insertion.second);
}
else // taking already generated rtti
{
rtti = iiFind->second;
}
}
}
else
{
rtti = iFind->second;
}
return rtti;
}
static void deleteException( void * pExc )
{
__cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
typelib_TypeDescription * pTD = 0;
OUString unoName( toUNOname( header->exceptionType->name() ) );
::typelib_typedescription_getByName( &pTD, unoName.pData );
assert(pTD && "### unknown exception type! leaving out destruction => leaking!!!");
if (pTD)
{
::uno_destructData( pExc, pTD, cpp_release );
::typelib_typedescription_release( pTD );
}
}
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
{
#if defined BRIDGES_DEBUG
OString cstr(
OUStringToOString(
OUString::unacquired( &pUnoExc->pType->pTypeName ),
RTL_TEXTENCODING_ASCII_US ) );
fprintf( stderr, "> uno exception occurred: %s\n", cstr.getStr() );
#endif
void * pCppExc;
type_info * rtti;
{
// construct cpp exception object
typelib_TypeDescription * pTypeDescr = 0;
TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
assert(pTypeDescr);
if (! pTypeDescr)
{
throw RuntimeException(
OUString("cannot get typedescription for type ") +
OUString::unacquired( &pUnoExc->pType->pTypeName ) );
}
pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
// destruct uno exception
::uno_any_destruct( pUnoExc, 0 );
// avoiding locked counts
static RTTI * s_rtti = 0;
if (! s_rtti)
{
MutexGuard guard( Mutex::getGlobalMutex() );
if (! s_rtti)
{
#ifdef LEAK_STATIC_DATA
s_rtti = new RTTI();
#else
static RTTI rtti_data;
s_rtti = &rtti_data;
#endif
}
}
rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
TYPELIB_DANGER_RELEASE( pTypeDescr );
assert(rtti);
if (! rtti)
{
throw RuntimeException(
OUString("no rtti for type ") +
OUString::unacquired( &pUnoExc->pType->pTypeName )
);
}
}
__cxa_throw( pCppExc, rtti, deleteException );
}
void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno )
{
if (! header)
{
RuntimeException aRE( "no exception header!" );
Type const & rType = cppu::UnoType<decltype(aRE)>::get();
uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
SAL_WARN("bridges", aRE.Message);
return;
}
typelib_TypeDescription * pExcTypeDescr = 0;
OUString unoName( toUNOname( header->exceptionType->name() ) );
#if defined BRIDGES_DEBUG
OString cstr_unoName( OUStringToOString( unoName, RTL_TEXTENCODING_ASCII_US ) );
fprintf( stderr, "> c++ exception occurred: %s\n", cstr_unoName.getStr() );
#endif
typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
if (0 == pExcTypeDescr)
{
RuntimeException aRE( OUString("exception type not found: ") + unoName );
Type const & rType = cppu::UnoType<decltype(aRE)>::get();
uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
SAL_WARN("bridges", aRE.Message);
}
else
{
// construct uno exception any
uno_any_constructAndConvert( pUnoExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
typelib_typedescription_release( pExcTypeDescr );
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_LINUX_SPARC64_SHARE_HXX
#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_LINUX_SPARC64_SHARE_HXX
#include "uno/mapping.h"
#include <typeinfo>
#include <exception>
#include <cstddef>
namespace CPPU_CURRENT_NAMESPACE
{
void dummy_can_throw_anything( char const * );
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
struct _Unwind_Exception
{
unsigned exception_class __attribute__((__mode__(__DI__)));
void * exception_cleanup;
unsigned private_1 __attribute__((__mode__(__word__)));
unsigned private_2 __attribute__((__mode__(__word__)));
} __attribute__((__aligned__));
struct __cxa_exception
{
::std::type_info *exceptionType;
void (*exceptionDestructor)(void *);
::std::unexpected_handler unexpectedHandler;
::std::terminate_handler terminateHandler;
__cxa_exception *nextException;
int handlerCount;
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
void *catchTemp;
void *adjustedPtr;
_Unwind_Exception unwindHeader;
};
extern "C" void *__cxa_allocate_exception(
std::size_t thrown_size ) throw();
extern "C" void __cxa_throw (
void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
struct __cxa_eh_globals
{
__cxa_exception *caughtExceptions;
unsigned int uncaughtExceptions;
};
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
void raiseException(
uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
void fillUnoException(
__cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef );
inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
{
switch( pType->nSize )
{
case 1: return pIn + 7;
case 2: return pIn + 6;
case 3: return pIn + 5;
case 4: return pIn + 4;
case 5: return pIn + 3;
case 6: return pIn + 2;
case 7: return pIn + 1;
// Huh ? perhaps a char[3] ? Though that would be a pointer
// well, we have it anyway for symmetry
}
return pIn;
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -4389,6 +4389,11 @@ linux-gnu*)
RTL_ARCH=SPARC
PLATFORMID=linux_sparc
;;
sparc64)
CPUNAME=SPARC64
RTL_ARCH=SPARC64
PLATFORMID=linux_sparc64
;;
s390)
CPUNAME=S390
RTL_ARCH=S390
......@@ -7268,6 +7273,9 @@ then
AS_IF([test -e "$JAVA_HOME/jre/lib/ppc64le/libjawt.so"], [my_java_arch=ppc64le], [my_java_arch=ppc64])
JAVA_ARCH=$my_java_arch
;;
sparc64)
my_java_arch=sparcv9
;;
x86_64)
my_java_arch=amd64
;;
......
......@@ -94,6 +94,8 @@ namespace
ret = checkOSandCPU("Linux", "X86_64");
else if (token == "linux_sparc")
ret = checkOSandCPU("Linux", "SPARC");
else if (token == "linux_sparc64")
ret = checkOSandCPU("Linux", "SPARC64");
else if (token == "linux_powerpc")
ret = checkOSandCPU("Linux", "PowerPC");
else if (token == "linux_powerpc64")
......
......@@ -162,6 +162,8 @@
||defined(__ia64__)\
||defined(__ppc64__)\
||defined(__s390x__)\
||(defined(__sparc_v9__) && defined(__arch64__))\
||defined(__sparcv9)\
||defined(__x86_64__)
#define TWH_64BIT
#else
......
......@@ -35,7 +35,7 @@ namespace jfw_plugin
//Used by subclasses of VendorBase to build paths to Java runtime
#if defined(JAVA_ARCH)
#define JFW_PLUGIN_ARCH JAVA_ARCH
#elif defined(__sparcv9)
#elif defined SPARC64
#define JFW_PLUGIN_ARCH "sparcv9"
#elif defined SPARC
#define JFW_PLUGIN_ARCH "sparc"
......
......@@ -271,6 +271,11 @@ ifeq "$(PROCTYPE)" "powerpc64"
JAVA_PROC_TYPE=ppc64
endif
ifeq "$(PROCTYPE)" "sparc64"
UNOPKG_PLATFORM=Linux_SPARC64
JAVA_PROC_TYPE=sparcv9
endif
OS=LINUX
PS=/
ICL=\$$
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#please make generic modifications to unxgcc.mk or linux.mk
gb_COMPILEROPTFLAGS := -Os
include $(GBUILDDIR)/platform/linux.mk
# vim: set noet sw=4:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment