Index: libstdc++-v3/libsupc++/eh_terminate.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc,v
retrieving revision 1.4
retrieving revision 1.4.78.1
diff -u -p -u -p -r1.4 -r1.4.78.1
--- libstdc++-v3/libsupc++/eh_terminate.cc 24 May 2003 16:22:03 -0000 1.4
+++ libstdc++-v3/libsupc++/eh_terminate.cc 21 Feb 2005 21:21:30 -0000 1.4.78.1
@@ -34,6 +34,12 @@
#include "unwind-cxx.h"
#include "exception_defines.h"
+/* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+#include "bits/os_defines.h"
+#endif
+/* APPLE LOCAL end keymgr */
+
using namespace __cxxabiv1;
void
@@ -50,6 +56,18 @@ __cxxabiv1::__terminate (std::terminate_
void
std::terminate ()
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ /*
+ * If the Key Manager has a terminate function assigned to this thread, invoke that fn.
+ * If not (KeyMgr has 0), use whatever is initialized into my local static pointer (above).
+ */
+ std::terminate_handler __keymgr_terminate_func = (std::terminate_handler)
+ _keymgr_get_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY);
+ if (__keymgr_terminate_func)
+ __terminate_handler = __keymgr_terminate_func;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
__terminate (__terminate_handler);
}
@@ -63,13 +81,32 @@ __cxxabiv1::__unexpected (std::unexpecte
void
std::unexpected ()
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ /* Similar to terminate case above. */
+ std::unexpected_handler __keymgr_unexpected_func = (std::unexpected_handler)
+ _keymgr_get_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY);
+ if (__keymgr_unexpected_func)
+ __unexpected_handler = __keymgr_unexpected_func;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
__unexpected (__unexpected_handler);
}
std::terminate_handler
std::set_terminate (std::terminate_handler func) throw()
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ std::terminate_handler old =
+ (std::terminate_handler) _keymgr_get_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY);
+ _keymgr_set_per_thread_data (KEYMGR_TERMINATE_HANDLER_KEY, (void *) func) ;
+ if ( ! old)
+ old = __terminate_handler;
+#else
std::terminate_handler old = __terminate_handler;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
__terminate_handler = func;
return old;
}
@@ -77,7 +114,17 @@ std::set_terminate (std::terminate_handl
std::unexpected_handler
std::set_unexpected (std::unexpected_handler func) throw()
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ std::unexpected_handler old =
+ (std::unexpected_handler) _keymgr_get_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY);
+ _keymgr_set_per_thread_data (KEYMGR_UNEXPECTED_HANDLER_KEY, (void *) func);
+ if ( ! old)
+ old = __unexpected_handler;
+#else
std::unexpected_handler old = __unexpected_handler;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
__unexpected_handler = func;
return old;
}
Index: libstdc++-v3/libsupc++/new_handler.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_handler.cc,v
retrieving revision 1.7
retrieving revision 1.7.78.1
diff -u -p -u -p -r1.7 -r1.7.78.1
--- new_handler.cc.orig 2003-05-24 09:22:03.000000000 -0700
+++ libstdc++-v3/libsupc++/new_handler.cc 2005-07-11 18:16:26.000000000 -0700
@@ -32,6 +32,12 @@
#include "new"
+/* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+#include "bits/os_defines.h"
+#endif
+/* APPLE LOCAL end keymgr */
+
const std::nothrow_t std::nothrow = { };
using std::new_handler;
@@ -40,7 +46,17 @@ new_handler __new_handler;
new_handler
std::set_new_handler (new_handler handler) throw()
{
+/* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ new_handler prev_handler =
+ (new_handler) _keymgr_get_per_thread_data (KEYMGR_NEW_HANDLER_KEY);
+ if ( ! prev_handler)
+ prev_handler = __new_handler;
+ _keymgr_set_per_thread_data (KEYMGR_NEW_HANDLER_KEY, (void *) handler);
+#else /* __APPLE__ etc. */
new_handler prev_handler = __new_handler;
+#endif /* __APPLE__ etc. */
+/* APPLE LOCAL end keymgr */
__new_handler = handler;
return prev_handler;
}
Index: libstdc++-v3/libsupc++/new_op.cc
--- new_op.cc.orig 2004-11-02 20:07:22.000000000 -0800
+++ libstdc++-v3/libsupc++/new_op.cc 2005-07-11 18:03:27.000000000 -0700
@@ -57,7 +57,15 @@ operator new (std::size_t sz) throw (std
p = (void *) malloc (sz);
while (p == 0)
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ /* Ask Key Manager for new_handler; if provided (!=0), use it, else use local version. */
+ new_handler handler =
+ (new_handler) _keymgr_get_per_thread_data (KEYMGR_NEW_HANDLER_KEY);
+#else /* __APPLE__ etc. */
new_handler handler = __new_handler;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
if (! handler)
#ifdef __EXCEPTIONS
throw bad_alloc();
Index: libstdc++-v3/libsupc++/new_opnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opnt.cc,v
retrieving revision 1.7
retrieving revision 1.7.14.1
diff -u -p -u -p -r1.7 -r1.7.14.1
--- libstdc++-v3/libsupc++/new_opnt.cc 3 Nov 2004 04:07:22 -0000 1.7
+++ libstdc++-v3/libsupc++/new_opnt.cc 21 Feb 2005 21:21:30 -0000 1.7.14.1
@@ -31,6 +31,12 @@
#include <exception_defines.h>
#include "new"
+/* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+#include "bits/os_defines.h"
+#endif /* __APPLE__ etc. */
+/* APPLE LOCAL end keymgr */
+
using std::new_handler;
using std::bad_alloc;
@@ -48,7 +54,14 @@ operator new (std::size_t sz, const std:
p = (void *) malloc (sz);
while (p == 0)
{
+ /* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+ new_handler handler =
+ (new_handler) _keymgr_get_per_thread_data (KEYMGR_NEW_HANDLER_KEY);
+#else /* __APPLE__ etc. */
new_handler handler = __new_handler;
+#endif /* __APPLE__ etc. */
+ /* APPLE LOCAL end keymgr */
if (! handler)
return 0;
try
Index: libstdc++-v3/config/os/bsd/darwin/os_defines.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/os/bsd/darwin/os_defines.h,v
retrieving revision 1.3
retrieving revision 1.3.22.1
diff -u -p -u -p -r1.3 -r1.3.22.1
--- libstdc++-v3/config/os/bsd/darwin/os_defines.h 3 Nov 2004 02:59:59 -0000 1.3
+++ libstdc++-v3/config/os/bsd/darwin/os_defines.h 28 Feb 2005 22:25:55 -0000 1.3.22.1
@@ -44,4 +44,144 @@
// -flat_namespace to work around the way that it doesn't.
#define _GLIBCXX_WEAK_DEFINITION __attribute__ ((weak))
+/* APPLE LOCAL begin keymgr */
+#if defined(__APPLE__) && defined(__ppc__) && defined(PIC)
+/* Copyright (C) 1989, 92-97, 1998, Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/*
+ * This file added by Apple Computer Inc. for its OS X
+ * environment.
+ */
+
+#ifndef __KEYMGR_H
+#define __KEYMGR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/*
+ * keymgr - Create and maintain process-wide global data known to
+ * all threads across all dynamic libraries.
+ *
+ */
+
+typedef enum node_kinds {
+ NODE_THREAD_SPECIFIC_DATA=1,
+ NODE_PROCESSWIDE_PTR=2,
+ NODE_LAST_KIND
+ } TnodeKind ;
+
+/*
+ * These enum members are bits or combination of bits.
+ */
+
+typedef enum node_mode {
+ NM_ALLOW_RECURSION=1,
+ NM_RECURSION_ILLEGAL=2,
+ NM_ENHANCED_LOCKING=3,
+ NM_LOCKED=4
+ } TnodeMode ;
+
+/* WARNING: the return value of _keymgr_set_per_thread_data is
+ not meaningful on Tiger and above. Use the macro
+ KEYMGR_SET_PER_THREAD_DATA (below) to handle this properly. */
+extern void * _keymgr_get_per_thread_data(unsigned int key) ;
+extern int _keymgr_set_per_thread_data(unsigned int key, void *keydata) ;
+extern void *_keymgr_get_and_lock_processwide_ptr(unsigned int key) ;
+extern void _keymgr_set_and_unlock_processwide_ptr(unsigned int key, void *ptr) ;
+extern void _keymgr_unlock_processwide_ptr(unsigned int key) ;
+extern void _keymgr_set_lockmode_processwide_ptr(unsigned int key, unsigned int mode) ;
+extern unsigned int _keymgr_get_lockmode_processwide_ptr(unsigned int key) ;
+extern int _keymgr_get_lock_count_processwide_ptr(unsigned int key) ;
+
+extern void *__keymgr_global[];
+typedef struct _Sinfo_Node {
+ unsigned int size ; /*size of this node*/
+ unsigned short major_version ; /*API major version.*/
+ unsigned short minor_version ; /*API minor version.*/
+ } _Tinfo_Node ;
+
+#define KEYMGR_VERSION \
+ (__keymgr_global[2] ? ((_Tinfo_Node *)__keymgr_global[2])->major_version : 0)
+
+#define KEYMGR_SET_PER_THREAD_DATA(key, keydata) \
+ (KEYMGR_VERSION >= 4 \
+ ? _keymgr_set_per_thread_data((key), (keydata)) \
+ : (_keymgr_set_per_thread_data((key), (keydata)), 0))
+
+#ifndef NULL
+#ifdef __GNUG__
+#define NULL __null
+#else
+#define NULL 0
+#endif
+#endif
+
+/*
+ * Keys currently in use:
+ */
+
+#define KEYMGR_EH_CONTEXT_KEY 1 /*stores handle for root pointer of exception context node.*/
+
+#define KEYMGR_NEW_HANDLER_KEY 2 /*store handle for new handler pointer.*/
+
+#define KEYMGR_UNEXPECTED_HANDLER_KEY 3 /*store handle for unexpected exception pointer.*/
+
+#define KEYMGR_TERMINATE_HANDLER_KEY 4 /*store handle for terminate handler pointer. */
+
+#define KEYMGR_MODE_BITS 5 /*stores handle for runtime mode bits.*/
+
+#define KEYMGR_IO_LIST 6 /*Root pointer to the list of open streams.*/
+
+#define KEYMGR_IO_STDIN 7 /*GNU stdin.*/
+
+#define KEYMGR_IO_STDOUT 8 /*GNU stdout.*/
+
+#define KEYMGR_IO_STDERR 9 /*GNU stderr.*/
+
+#define KEYMGR_IO_REFCNT 10 /*How many plugins/main program currently using streams.*/
+
+#define KEYMGR_IO_MODE_BITS 11 /*Flags controlling the behavior of C++ I/O.*/
+
+#define KEYMGR_ZOE_IMAGE_LIST 12 /*Head pointer for list of per image dwarf2 unwind sections.*/
+
+#define KEYMGR_EH_GLOBALS_KEY 13 /* Variable used in eh_globals.cc */
+
+/*
+ * Other important data.
+ */
+
+#define KEYMGR_API_REV_MAJOR 2 /*Major revision number of the keymgr API.*/
+#define KEYMGR_API_REV_MINOR 1 /*Minor revision number of the keymgr API.*/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __KEYMGR_H */
+#endif /* __APPLE__ etc. */
+/* APPLE LOCAL end keymgr */
#endif
--- libstdc++-v3/libsupc++/eh_globals.cc-orig 2005-08-23 12:35:39.000000000 -0700
+++ libstdc++-v3/libsupc++/eh_globals.cc 2005-08-23 12:36:19.000000000 -0700
@@ -70,6 +70,7 @@ __cxxabiv1::__cxa_get_globals() throw()
#else
+#if ! defined(__APPLE__) || ! defined (__ppc__) || ! defined (PIC)
// Single-threaded fallback buffer.
static __cxa_eh_globals eh_globals;
@@ -159,4 +160,37 @@ __cxxabiv1::__cxa_get_globals() throw()
#endif
+#else
+// defined(__APPLE__) && defined (__ppc__) && defined (PIC)
+
+extern "C" __cxa_eh_globals *
+__cxxabiv1::__cxa_get_globals_fast () throw()
+{
+ /* APPLE LOCAL begin radar 3373515 */
+ return (__cxa_eh_globals *) _keymgr_get_per_thread_data (KEYMGR_EH_GLOBALS_KEY);
+ /* APPLE LOCAL end radar 3373515 */
+}
+
+extern "C" __cxa_eh_globals *
+__cxxabiv1::__cxa_get_globals () throw()
+{
+ __cxa_eh_globals *g;
+ g = (__cxa_eh_globals *) _keymgr_get_per_thread_data (KEYMGR_EH_GLOBALS_KEY);
+ if (! g)
+ {
+ if ((g = (__cxa_eh_globals *)
+ std::malloc (sizeof (__cxa_eh_globals))) == 0
+ /* APPLE LOCAL begin radar 3373515 */
+ || KEYMGR_SET_PER_THREAD_DATA (KEYMGR_EH_GLOBALS_KEY, (void *) g) != 0)
+ /* APPLE LOCAL end radar 3373515 */
+ std::terminate ();
+ g->caughtExceptions = 0;
+ g->uncaughtExceptions = 0;
+ }
+
+ return g;
+}
+
+#endif
+
#endif