[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 7 commits - bridges/source sal/inc sal/rtl sal/util sc/source set_soenv.in shell/source solenv/gbuild solenv/inc

Pedro Giffuni pfg at apache.org
Thu Mar 26 17:12:43 PDT 2015


 bridges/source/cpp_uno/gcc3_freebsd_intel/cpp2uno.cxx     |    5 +
 bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx      |   12 +++
 bridges/source/cpp_uno/gcc3_freebsd_intel/share.hxx       |   12 ++-
 bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx     |   11 +++
 bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx    |    7 +-
 bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx     |   12 +++
 bridges/source/cpp_uno/gcc3_freebsd_x86-64/share.hxx      |   12 ++-
 bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx    |   12 ++-
 sal/inc/rtl/math.h                                        |   15 ++++
 sal/inc/rtl/math.hxx                                      |    7 ++
 sal/inc/rtl/string.hxx                                    |    3 
 sal/rtl/source/math.cxx                                   |   13 ++++
 sal/util/sal.map                                          |    2 
 sc/source/core/tool/interpr1.cxx                          |   44 +++++++++++---
 set_soenv.in                                              |   27 ++++++--
 shell/source/unix/sysshell/recently_used_file_handler.cxx |    1 
 solenv/gbuild/platform/freebsd.mk                         |    3 
 solenv/inc/unxfbsd.mk                                     |   16 ++---
 18 files changed, 169 insertions(+), 45 deletions(-)

New commits:
commit 775929fdc096ef7224919dffddae722cf7ce4558
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:31:35 2015 +0000

    FreeBSD build structure changes
    
    Part of
    Code Review:	https://reviews.freebsd.org/D2108
    
    Author:		Don Lewis (truckman at FreeBSD)

diff --git a/set_soenv.in b/set_soenv.in
index 7d0ffe3..2b96d28 100644
--- a/set_soenv.in
+++ b/set_soenv.in
@@ -359,7 +359,7 @@ elsif ( $platform =~ m/kfreebsd/ )
 elsif ( $platform =~ m/freebsd/ ) 
 {     $BIG_SVX        = "TRUE";
       $COM            = "GCC";
-      $COMPATH        = '@COMPATH@'; 
+      $COMPATH        = '@COMPATH@' . '/bin'; 
       $CVER           = "C300";
       $GUI            = "UNX";
       $GUIBASE        = "unx";
@@ -2617,26 +2617,37 @@ sub GetCorrectPath
 	my @originalPairs = @_;
 	my @pairs = @originalPairs;
 	my @Path = split /$ps/, $oldPath;
+	my @buildPath;
+	my @sysPath;
+	my $elem;
+
+	for $elem (@Path) {
+	    if ($elem eq '.' || $elem =~ m'^$SOLARENV/' ||
+		$elem =~ m'/solenv/') {
+		    push @buildPath, $elem;
+	    } else {
+		    push @sysPath, $elem;
+	    }
+	}
 
 	while (@pairs) {
 	    my $path = shift @pairs;
 	    my $cmd = shift @pairs;
 	    my $to_append = 1;
-	    my $elem;
 
 	    if (! -x "$path/$cmd") {
 		AddWarning ("Missing executable $path/$cmd\n");
 	    }
 
-	    for $elem (@Path) {
+	    for $elem (@sysPath) {
 		if ($elem eq $path) {
 #		    print "Hit duplicate path in path; break\n";
 		    $to_append = 0;
 		    last;
 		}
-		if (-f "$elem/$cmd") {
+		if (-f "$elem/$cmd" && ! -l "$elem/$cmd") {
 #		    print "Element already in path ...\n";
-		    unshift @Path, $path;
+		    unshift @sysPath, $path;
 		    $to_append = 0;
 		    last;
 		} else {
@@ -2644,7 +2655,7 @@ sub GetCorrectPath
 		}
 	    }
 	    if ($to_append) {
-		push @Path, $path;
+		push @sysPath, $path;
 	    }
 	}
 
@@ -2654,14 +2665,14 @@ sub GetCorrectPath
 	    my $cmd = shift @pairs;
 	    my $realpath;
 
-	    $realpath = PathLookup ($cmd, @Path);
+	    $realpath = PathLookup ($cmd, @sysPath);
 	    if (!($realpath eq $path)) {
 		AddWarning ("Path conflict for executables " .
                             "$path/$cmd against $realpath");
 	    }
 	}
 
-	return join $ps, CleanupPath (@Path);
+	return join $ps, @buildPath, CleanupPath (@sysPath);
 }
 
 #------------------------------------------------------------
diff --git a/solenv/gbuild/platform/freebsd.mk b/solenv/gbuild/platform/freebsd.mk
index 868786a..b816f44 100644
--- a/solenv/gbuild/platform/freebsd.mk
+++ b/solenv/gbuild/platform/freebsd.mk
@@ -96,6 +96,7 @@ gb_CXXFLAGS := \
 	-fvisibility-inlines-hidden \
 	-fvisibility=hidden \
 	-pipe \
+	-DHAVE_STL_INCLUDE_PATH \
 
 ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
 gb_CFLAGS_WERROR := -Werror
@@ -110,7 +111,6 @@ endif
 gb_LinkTarget_EXCEPTIONFLAGS := \
 	-DEXCEPTIONS_ON \
 	-fexceptions \
-	-fno-enforce-eh-specs \
 
 gb_LinkTarget_NOEXCEPTIONFLAGS := \
 	-DEXCEPTIONS_OFF \
@@ -121,6 +121,7 @@ gb_LinkTarget_LDFLAGS += \
 	-Wl,-z,combreloc \
 	-Wl,-z,defs \
 	$(subst -L../lib , ,$(SOLARLIB)) \
+	${FBSD_LDFLAGS} \
 	 \
 
 ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
diff --git a/solenv/inc/unxfbsd.mk b/solenv/inc/unxfbsd.mk
index c771282..a9d946b 100644
--- a/solenv/inc/unxfbsd.mk
+++ b/solenv/inc/unxfbsd.mk
@@ -27,7 +27,7 @@ ASM=
 AFLAGS=
 
 SOLAR_JAVA*=
-PICSWITCH*:=-fpic
+PICSWITCH*:=-fPIC
 JAVAFLAGSDEBUG=-g
 
 # Include arch specific makefile.
@@ -49,7 +49,7 @@ JAVAFLAGSDEBUG=-g
 #LINKOUTPUT_FILTER=" |& $(SOLARENV)/bin/msg_filter"
 
 # _PTHREADS is needed for the stl
-CDEFS+=$(PTHREAD_CFLAGS) -D_PTHREADS -D_REENTRANT -DNEW_SOLAR -D_USE_NAMESPACE=1 -DSTLPORT_VERSION=450
+CDEFS+=$(PTHREAD_CFLAGS) -D_PTHREADS -D_REENTRANT -DNEW_SOLAR -D_USE_NAMESPACE=1 -DSTLPORT_VERSION=450 -DHAVE_STL_INCLUDE_PATH
 
 # enable visibility define in "sal/types.h"
 .IF "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
@@ -88,7 +88,7 @@ CFLAGSENABLESYMBOLS=-g # was temporarily commented out, reenabled before Beta
 # flags for the C++ Compiler
 CFLAGSCC= -pipe $(ARCH_FLAGS) 
 # Flags for enabling exception handling
-CFLAGSEXCEPTIONS=-fexceptions -fno-enforce-eh-specs
+CFLAGSEXCEPTIONS=-fexceptions
 # Flags for disabling exception handling
 CFLAGS_NO_EXCEPTIONS=-fno-exceptions
 
@@ -156,7 +156,7 @@ LINKFLAGSRUNPATH_OXT=
 LINKFLAGSRUNPATH_BOXT=-Wl,-z,origin -Wl,-rpath,\''$$ORIGIN'\'
 #LINKFLAGSRUNPATH_BOXT=-Wl,-z,origin -Wl,-rpath,\''$$ORIGIN/../../../basis-link/program'\'
 LINKFLAGSRUNPATH_NONE=
-LINKFLAGS=-Wl,-z,combreloc  $(LINKFLAGSDEFS) $(LINKFLAGS_SYSBASE)
+LINKFLAGS=-Wl,-z,combreloc $(LDFLAGS) $(LINKFLAGSDEFS) $(LINKFLAGS_SYSBASE)
 
 # linker flags for linking applications
 LINKFLAGSAPPGUI= -Wl,-export-dynamic -Wl,--noinhibit-exec \
@@ -199,11 +199,11 @@ STDSHLCUIMT+=-ltcmalloc
 .ENDIF
 
 # libraries for linking applications
-STDLIBGUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed
-STDLIBCUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed
+STDLIBGUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed ${FBSD_LDFLAGS}
+STDLIBCUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed ${FBSD_LDFLAGS}
 # libraries for linking shared libraries
-STDSHLGUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed
-STDSHLCUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed
+STDSHLGUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed ${FBSD_LDFLAGS}
+STDSHLCUIMT+=-Wl,--as-needed $(PTHREAD_LIBS) -lm -Wl,--no-as-needed ${FBSD_LDFLAGS}
 
 X11LINK_DYNAMIC = -Wl,--as-needed -lXext -lX11 -Wl,--no-as-needed
 
commit b6bfecc5b622e7af89515ad9e669c6f939d3b917
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:21:14 2015 +0000

    Move operator to the public section.
    
    This solves visibility issues with modern gcc.
    
    Author:		Don Lewis (truckman at FreeBSD)

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 8c98a36..c3ce09b 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -234,8 +234,9 @@ private:
       @return a pointer to a (not necessarily null-terminated) byte string
       representing the characters of this string object.
     */
-    operator const sal_Char *() const SAL_THROW(()) { return pData->buffer; }
+
 public:
+    operator const sal_Char *() const SAL_THROW(()) { return pData->buffer; }
     /** Returns a reference to a character of this string. */
     sal_Char& operator[]( int n ) { return pData->buffer[n]; }
     /** Returns a const reference to a character of this string. */
commit ecebe457c968bfd30a99a435210b0bdbb117faef
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:16:10 2015 +0000

    Small fix for BSD.
    
    Part of Code Review:
    https://reviews.freebsd.org/D2055
    
    Author:		Don Lewis (truckman at FreeBSD)

diff --git a/shell/source/unix/sysshell/recently_used_file_handler.cxx b/shell/source/unix/sysshell/recently_used_file_handler.cxx
index 93161ed..e432182 100644
--- a/shell/source/unix/sysshell/recently_used_file_handler.cxx
+++ b/shell/source/unix/sysshell/recently_used_file_handler.cxx
@@ -40,6 +40,7 @@
 #include <algorithm>
 #include <functional>
 #include <string.h>
+#include <time.h>
 
 namespace /* private */ {
     //########################################
commit 8d290f41e2b1176c7abd5d202542748938243856
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:08:17 2015 +0000

    Huge update to the FreeBSD port (amd64 part).
    
    Starting with FreeBSD 10, the FreeBSD project has moved from using
    gcc/libstdc++ to using a complete C++ stack based on clang/llvm
    libc++ and libcxxrt. This new stack has better standards compliance
    and has huge similarities with MacOSX but it brought subtle low
    level problems for our outdated bridges code.
    
    Don Lewis has done a brave effort to update this code and
    has done extensive testing within FreeBSD port. Support
    for older versions of gcc has been dropped.
    
    Code Review:
    https://reviews.freebsd.org/D2108
    https://reviews.freebsd.org/D2055
    
    Author:		Don Lewis (truckman at FreeBSD)

diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
index 632529b..c67e37e 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
@@ -24,9 +24,10 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <hash_map>
+#include <typeinfo>
+#include <exception>
+#include <cstddef>
+#include <cxxabi.h>
 
 #include <rtl/alloc.h>
 #include <osl/mutex.hxx>
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx
index 24e6ada..b76bb7d 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx
@@ -24,9 +24,9 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
-#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
+#include <cstddef>
 #include <exception>
-#endif
+#include <typeinfo>
 
 #include <stdio.h>
 #include <string.h>
@@ -182,7 +182,12 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
                 char const * rttiName = symName.getStr() +4;
 #if OSL_DEBUG_LEVEL > 1
                 fprintf( stderr,"generated rtti for %s\n", rttiName );
+#ifndef __GLIBCXX__ /* #i124421# */
+                const OString aCUnoName = OUStringToOString( unoName, RTL_TEXTENCODING_UTF8);
+                OSL_TRACE( "TypeInfo for \"%s\" not found and cannot be generated.\n", aCUnoName.getStr());
+#endif /* __GLIBCXX__ */
 #endif
+#ifdef __GLIBCXX__ /* #i124421# */
                 if (pTypeDescr->pBaseTypeDescription)
                 {
                     // ensure availability of base
@@ -196,6 +201,9 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
                     // this class has no base class
                     rtti = new __class_type_info( strdup( rttiName ) );
                 }
+#else /* __GLIBCXX__ */
+                rtti = NULL;
+#endif /* __GLIBCXX__ */
 
                 pair< t_rtti_map::iterator, bool > insertion(
                     m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/share.hxx
index de9f7dd..aaffe86 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/share.hxx
@@ -23,10 +23,6 @@
 
 #include "uno/mapping.h"
 
-#include <typeinfo>
-#include <exception>
-#include <cstddef>
-
 namespace CPPU_CURRENT_NAMESPACE
 {
 
@@ -34,6 +30,7 @@ void dummy_can_throw_anything( char const * );
 
 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
 
+#ifdef __GLIBCXX__
 struct _Unwind_Exception
 {
     unsigned exception_class __attribute__((__mode__(__DI__)));
@@ -62,18 +59,21 @@ struct __cxa_exception
 
     _Unwind_Exception unwindHeader;
 };
+#endif /* __GLIBCXX__ */
 
 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));
 
+#ifdef __GLIBCXX__
 struct __cxa_eh_globals
 {
     __cxa_exception *caughtExceptions;
     unsigned int uncaughtExceptions;
 };
 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
+#endif /* __GLIBCXX__ */
 
 // -----
 
@@ -81,6 +81,10 @@ extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
 void raiseException(
     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
 //==================================================================================================
+#ifndef __GLIBCXX__
+using __cxxabiv1:: __cxa_exception;
+#endif /* __GLIBCXX__ */
+
 void fillUnoException(
     __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
 }
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
index cc3d83d..c0f619f 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
@@ -24,9 +24,10 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
-#include <exception>
 #include <typeinfo>
-#include <stdio.h>
+#include <exception>
+#include <cstddef>
+#include <cxxabi.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -47,6 +48,11 @@
 
 using namespace ::rtl;
 using namespace ::com::sun::star::uno;
+#ifdef __GLIBCXX__
+using CPPU_CURRENT_NAMESPACE::__cxa_get_globals;
+#else
+using __cxxabiv1::__cxa_get_globals;
+#endif
 
 //==================================================================================================
 static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
@@ -446,7 +452,7 @@ static void cpp_call(
      catch (...)
      {
           // fill uno exception
-        fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
+        CPPU_CURRENT_NAMESPACE::fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
 
         // temporary params
         for ( ; nTempIndizes--; )
commit 5bffd35f5bc0a58773f838bb420d434c449f6c6a
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:07:21 2015 +0000

    Huge update to the FreeBSD port (i386 part).
    
    Starting with FreeBSD 10, the FreeBSD project has moved from using
    gcc/libstdc++ to using a complete C++ stack based on clang/llvm
    libc++ and libcxxrt. This new stack has better standards compliance
    and has huge similarities with MacOSX but it brought subtle low
    level problems for our outdated bridges code.
    
    Don Lewis has done a brave effort to update this code and
    has done extensive testing within FreeBSD port. Support
    for older versions of gcc has been dropped.
    
    Code Review:
    https://reviews.freebsd.org/D2108
    https://reviews.freebsd.org/D2055
    
    Author:		Don Lewis (truckman at FreeBSD)

diff --git a/bridges/source/cpp_uno/gcc3_freebsd_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_freebsd_intel/cpp2uno.cxx
index 03103e6..1ad2e61 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_intel/cpp2uno.cxx
@@ -24,6 +24,11 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
+#include <typeinfo>
+#include <exception>
+#include <cstddef>
+#include <cxxabi.h>
+
 #include <com/sun/star/uno/genfunc.hxx>
 #include "com/sun/star/uno/RuntimeException.hpp"
 #include <uno/data.h>
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx b/bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx
index 307185f..525a65a 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx
@@ -24,9 +24,9 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
-#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
+#include <cstddef>
 #include <exception>
-#endif
+#include <typeinfo>
 
 #include <stdio.h>
 #include <string.h>
@@ -182,7 +182,12 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
                 char const * rttiName = symName.getStr() +4;
 #if OSL_DEBUG_LEVEL > 1
                 fprintf( stderr,"generated rtti for %s\n", rttiName );
+#ifndef __GLIBCXX__ /* #i124421# */
+                const OString aCUnoName = OUStringToOString( unoName, RTL_TEXTENCODING_UTF8);
+                OSL_TRACE( "TypeInfo for \"%s\" not found and cannot be generated.\n", aCUnoName.getStr());
+#endif /* __GLIBCXX__ */
 #endif
+#ifdef __GLIBCXX__ /* #i124421# */
                 if (pTypeDescr->pBaseTypeDescription)
                 {
                     // ensure availability of base
@@ -196,6 +201,9 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
                     // this class has no base class
                     rtti = new __class_type_info( strdup( rttiName ) );
                 }
+#else /* __GLIBCXX__ */
+                rtti = NULL;
+#endif /* __GLIBCXX__ */
 
                 pair< t_rtti_map::iterator, bool > insertion(
                     m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_intel/share.hxx b/bridges/source/cpp_uno/gcc3_freebsd_intel/share.hxx
index de9f7dd..aaffe86 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_intel/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_intel/share.hxx
@@ -23,10 +23,6 @@
 
 #include "uno/mapping.h"
 
-#include <typeinfo>
-#include <exception>
-#include <cstddef>
-
 namespace CPPU_CURRENT_NAMESPACE
 {
 
@@ -34,6 +30,7 @@ void dummy_can_throw_anything( char const * );
 
 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
 
+#ifdef __GLIBCXX__
 struct _Unwind_Exception
 {
     unsigned exception_class __attribute__((__mode__(__DI__)));
@@ -62,18 +59,21 @@ struct __cxa_exception
 
     _Unwind_Exception unwindHeader;
 };
+#endif /* __GLIBCXX__ */
 
 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));
 
+#ifdef __GLIBCXX__
 struct __cxa_eh_globals
 {
     __cxa_exception *caughtExceptions;
     unsigned int uncaughtExceptions;
 };
 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
+#endif /* __GLIBCXX__ */
 
 // -----
 
@@ -81,6 +81,10 @@ extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
 void raiseException(
     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
 //==================================================================================================
+#ifndef __GLIBCXX__
+using __cxxabiv1:: __cxa_exception;
+#endif /* __GLIBCXX__ */
+
 void fillUnoException(
     __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
 }
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx
index a365133..964d4c5 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx
@@ -24,6 +24,10 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
+#include <typeinfo>
+#include <exception>
+#include <cstddef>
+#include <cxxabi.h>
 #include <stdlib.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
@@ -39,6 +43,11 @@
 
 using namespace ::rtl;
 using namespace ::com::sun::star::uno;
+#ifdef __GLIBCXX__
+using CPPU_CURRENT_NAMESPACE::__cxa_get_globals;
+#else
+using __cxxabiv1::__cxa_get_globals;
+#endif
 
 namespace
 {
@@ -305,7 +314,7 @@ static void cpp_call(
      catch (...)
      {
           // fill uno exception
-        fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
+        CPPU_CURRENT_NAMESPACE::fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
 
         // temporary params
         for ( ; nTempIndizes--; )
commit 50952ff25ac37ae9ba03039767bf33fd51b1b039
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:06:29 2015 +0000

    Bring to SAL a wrapper implementation of the powr() IEEE 754 math function.
    
    This function was originally brought in r1444110 and is useful for
    OOXML compatibility. At this time it is not being used to fix the
    original issue it was meant to address but it is convenient for
    future use.
    
    It also reduces the differences from FreeBSD's port which will
    be receiving updates.

diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h
index 11696258..ad51712 100644
--- a/sal/inc/rtl/math.h
+++ b/sal/inc/rtl/math.h
@@ -396,6 +396,21 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
  */
 double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
 
+/** Similar to pow() with stricter exception handling for indeterminate values.
+
+    powr is specified in the IEEE 754 - 2008 Floating Point Standard.
+
+    @param fValue
+    The value to be raised.
+
+    @param fExp
+    The exponent.
+
+    @return
+    powr(fValue, fExp)
+ */
+double SAL_CALL rtl_math_powr(double fValue, double fExp) SAL_THROW_EXTERN_C();
+
 /** Rounds value to 15 significant decimal digits.
 
     @param fValue
diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
index 8d87c73..658120d 100644
--- a/sal/inc/rtl/math.hxx
+++ b/sal/inc/rtl/math.hxx
@@ -186,6 +186,13 @@ inline double pow10Exp(double fValue, int nExp)
     return rtl_math_pow10Exp(fValue, nExp);
 }
 
+/** A wrapper around rtl_math_powr.
+ */
+inline double powr(double fValue, double fExp)
+{
+    return rtl_math_powr(fValue, fExp);
+}
+
 /** A wrapper around rtl_math_approxValue.
  */
 inline double approxValue(double fValue)
diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx
index f5eaa44..ae2b045 100644
--- a/sal/rtl/source/math.cxx
+++ b/sal/rtl/source/math.cxx
@@ -1113,6 +1113,19 @@ double SAL_CALL rtl_math_expm1( double fValue ) SAL_THROW_EXTERN_C()
     return (fe-1.0) * fValue / log(fe);
 }
 
+double SAL_CALL rtl_math_powr( double fValue,  double fExp ) SAL_THROW_EXTERN_C()
+{
+    if ((fValue == 0.0  && fExp == 0.0) ||
+    (rtl::math::isInf( fExp ) && !rtl::math::isSignBitSet( fExp )) ||
+    (rtl::math::isInf( fValue ) && !rtl::math::isSignBitSet( fValue )))
+    {
+        double fResult;
+        ::rtl::math::setNan( &fResult );
+        return fResult;
+    }
+    return pow(fValue, fExp);
+}
+
 
 double SAL_CALL rtl_math_log1p( double fValue ) SAL_THROW_EXTERN_C()
 {
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 5a86333..997190c 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -629,6 +629,8 @@ UDK_3.12 { # AOO 3.5
     global:
         osl_loadAsciiModule;
         osl_loadAsciiModuleRelative;
+
+        rtl_math_powr;
 } UDK_3.11;
 
 PRIVATE_1.0 {
commit af2e55beb5474caf1640d98cc55b06b7c21c5c33
Author: Pedro Giffuni <pfg at apache.org>
Date:   Thu Mar 26 22:05:42 2015 +0000

    Re-implement Calc's RAND() function using a variant of KISS PRNG.
    
    George Marsaglia's KISS algorithm is a rather simple implementation
    of a random number generator but it has interesting properties with
    respect ot the traditional Mersenne Twister.
    
    I used the 2011 32 bit Multiply-with-carry variant, with an
    undetermined  period which is known to be not less than 10^40000000;
    it is known to pass all the statistical tests.
    
    The Apache OpenOffice implementation uses an aggressive seeding
    scheme based on the internal rtl_random functions, rendering the
    function basically unpredictable. As a side effect it is also not
    possible to specify a seed for repeatability. No claims are made
    concerning crypto-safeness.
    
    The specific adaption for Apache OpenOffice is:
    
    Copyright 2015 Pedro Giffuni
    All rights reserved.
    
    Huge thanks to Steve Kargl for pointing me to the algorithm and
    the late George Marsaglia for creating it in the first place.

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 70afc97..da0c9a0 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -40,6 +40,7 @@
 #include <unotools/transliterationwrapper.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/logfile.hxx>
+#include <rtl/random.h>
 #include <unicode/uchar.h>
 
 #include "interpre.hxx"
@@ -71,9 +72,6 @@
 #include "doubleref.hxx"
 #include "queryparam.hxx"
 
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_01.hpp>
-
 #include <boost/math/special_functions/acosh.hpp>
 #include <boost/math/special_functions/asinh.hpp>
 #include <boost/math/special_functions/atanh.hpp>
@@ -1545,18 +1543,48 @@ void ScInterpreter::ScPi()
     PushDouble(F_PI);
 }
 
+#define SCRANDOMQ_SIZE 4194304
+static sal_uInt32 nScRandomQ[SCRANDOMQ_SIZE], nScCarry = 0;
+
+// Multiply with Carry
+sal_uInt32
+b32MWC(void)
+{
+        sal_uInt32 t, x;
+    static int j = (SCRANDOMQ_SIZE - 1);
+
+    j = (j + 1) & (SCRANDOMQ_SIZE - 1);
+    x = nScRandomQ[j];
+    t = (x << 28) + nScCarry;
+    nScCarry = (x >> 4) - (t < x);
+    return (nScRandomQ[j] = t - x);
+}
+
+// Congruential
+#define CNG ( cng = 69069 * cng + 13579 )
+// Xorshift
+#define XS ( xs ^= (xs << 13), xs ^= (xs >> 17), xs ^= (xs << 5) )
+
+#define KISS (b32MWC() + CNG + XS)
 
 void ScInterpreter::ScRandom()
 {
-    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "bst", "ScInterpreter::ScRandom" );
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "pfg", "ScInterpreter::ScRandom" );
 
-    boost::random::mt19937 ScGen(static_cast<unsigned int>(std::time(0)));
-    static boost::uniform_01<boost::mt19937> ScZeroOne(ScGen);
+    static rtlRandomPool aPool = rtl_random_createPool();
+    static sal_Bool SqSeeded = sal_False;
+    static sal_uInt32 i, x, cng, xs = 362436069;
 
-    PushDouble(ScZeroOne());
+    // Seeding for the PRNG
+    if (SqSeeded == sal_False) {
+        rtl_random_getBytes(aPool, &cng, sizeof(cng));
+        rtl_random_getBytes(aPool, &nScRandomQ,
+                            sizeof(nScRandomQ[0]) * SCRANDOMQ_SIZE);
+        SqSeeded = sal_True;
+        }
+    PushDouble(static_cast<double>(KISS) / SAL_MAX_UINT32);
 }
 
-
 void ScInterpreter::ScTrue()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScTrue" );


More information about the Libreoffice-commits mailing list