summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Instance.cpp16
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp7
-rw-r--r--cpp/src/IceUtil/IceAtomic.c110
-rw-r--r--cpp/src/IceUtil/Makefile8
-rw-r--r--cpp/src/icecpp/config.h4
5 files changed, 133 insertions, 12 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 89c7ccd9cb6..baabda38492 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -662,17 +662,11 @@ IceInternal::Instance::destroy()
{
assert(!_destroyed);
- if(_objectAdapterFactory)
- {
- _objectAdapterFactory->shutdown();
- _objectAdapterFactory->waitForShutdown();
- }
-
- if(_outgoingConnectionFactory)
- {
- _outgoingConnectionFactory->destroy();
- _outgoingConnectionFactory->waitUntilFinished();
- }
+ _objectAdapterFactory->shutdown();
+ _outgoingConnectionFactory->destroy();
+
+ _objectAdapterFactory->waitForShutdown();
+ _outgoingConnectionFactory->waitUntilFinished();
ThreadPoolPtr serverThreadPool;
ThreadPoolPtr clientThreadPool;
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index f4e8d5f5c17..dcb8162fc1a 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -385,6 +385,13 @@ IceBox::ServiceManagerI::stopAll()
info.communicator->shutdown();
info.communicator->waitForShutdown();
}
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ //
+ // Ignore, the service might have already destroyed
+ // the communicator for its own reasons.
+ //
+ }
catch(const Ice::Exception& ex)
{
Warning out(_logger);
diff --git a/cpp/src/IceUtil/IceAtomic.c b/cpp/src/IceUtil/IceAtomic.c
new file mode 100644
index 00000000000..0d1e94a4483
--- /dev/null
+++ b/cpp/src/IceUtil/IceAtomic.c
@@ -0,0 +1,110 @@
+/* ==Id: atomic.S,v 1.4 2001/11/18 00:12:56 davem Exp ==
+ * atomic.S: These things are too big to do inline.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ */
+
+/* Recreated as
+ * $Id$
+ * for use with -Ice-.
+ *
+ * Build with
+ * gcc -shared -o libIceAtomic.so -mcpu=v9 -mtune=v9 IceAtomic.c -fomit-frame-pointer -O2
+ * for standalone use, or, better perhaps, as part of libIceUtil.so by
+ * gcc -c -mcpu=v9 -mtune=v9 IceAtomic.c -fomit-frame-pointer -O2
+ * as part of the src/IceUtil build
+ *
+/* Narrative:
+ * This is the linux kernel code for atomic add, atomic subtract on sparc-v9. In fact,
+ * although the add/sub routines are typed -void- externally, they actually return
+ * the result of their operation.
+ *
+ * The exchange_and_add is like add, except that it returns the original
+ * value of the counter (instead of the new one), and for some reason, the
+ * order of its arguments is reversed.
+ *
+ * Here is how I think (all three) work.
+ * do {
+ * A. g5 <- value;
+ * B. g7 <- g5 [+/-] delta;
+ * C. if (value == g5) swap(g7, value);
+ * D. } while (g5 != g7); // g5 was original value, g7 is swapped from original value
+ * // if they are not the same, someone changed the memory
+ * // copy before the swap, so we start over with a new value
+ * E. Synchronize_memory_and_data_cache;
+ * F. return [value+delta | value - delta | value] depending on add/sub/exchange_add.
+ *
+ * Notice that step -C.- is an indivisible operation, so everything is good coming
+ * out. The entire operation can be retried of between -A.- and start of -C.- someone
+ * else changes the counter variable. The point is that you get a -coherent- result
+ * (which is to say, you don't operate on a stale counter value, and so replace it
+ * with something wrong for everyone). You might not be operating on the values
+ * at call. To do that, put global Mutex around the call itself.
+ *
+ * WARNINGS:
+ * Do NOT put these in a header file for inlining. You will get bus errors,
+ * or the results will be wrong if you don't.
+ *
+ * Do NOT use these on Sparc 2, 5, 10, 20 etc. The instructions are
+ * sparc-version 9.
+ *
+ * These are written for sparc(v9)-linux-gcc. I have no idea what they will do
+ * with Solaris or with other compilers.
+ *
+ * I do not know if these work in general; I am not a sparc architect.
+ *
+ * --
+ * Ferris McCormick <fmccor@inforead.com>
+ * 06.iii.03
+ */
+
+typedef struct {volatile int counter;} atomic_t;
+
+int __atomic_add(int i, atomic_t* v) {
+ __asm__ __volatile__ (
+"1: lduw [%o1], %g5\n"
+" add %g5, %o0, %g7\n"
+" cas [%o1], %g5, %g7\n"
+" cmp %g5, %g7\n"
+" bne,pn %icc, 1b\n"
+" membar #StoreLoad | #StoreStore\n"
+" retl\n"
+" add %g7, %o0, %o0\n"
+ );
+ return; /* Not Reached */
+}
+
+int __atomic_sub(int i, atomic_t *v) {
+ __asm__ __volatile__ (
+"1: lduw [%o1], %g5\n"
+" sub %g5, %o0, %g7\n"
+" cas [%o1], %g5, %g7\n"
+" cmp %g5, %g7\n"
+" bne,pn %icc, 1b\n"
+" membar #StoreLoad | #StoreStore\n"
+" retl\n"
+" sub %g7, %o0, %o0\n"
+ );
+ return; /* Not Reached */
+}
+int __atomic_exchange_and_add(atomic_t *v, int i) {
+#if 0
+ int t2;
+ t2 = v->counter;
+ __atomic_add(i,v);
+ return t2; /* Of course, this is wrong because counter might change
+ after the assignment to t2 but before the add */
+#else /* This is what we actually do */
+ __asm__ __volatile__ (
+"1: lduw [%o0], %g5\n"
+" add %g5, %o1, %g7\n"
+" cas [%o0], %g5, %g7\n"
+" cmp %g5, %g7\n"
+" bne,pn %icc, 1b\n"
+" membar #StoreLoad | #StoreStore\n"
+" retl\n"
+" mov %g7, %o0\n"
+ );
+ return; /* Not Reached */
+#endif
+}
diff --git a/cpp/src/IceUtil/Makefile b/cpp/src/IceUtil/Makefile
index 409d43d85fe..26b0155e4ae 100644
--- a/cpp/src/IceUtil/Makefile
+++ b/cpp/src/IceUtil/Makefile
@@ -37,6 +37,14 @@ OBJS = Exception.o \
SRCS = $(OBJS:.o=.cpp)
include $(top_srcdir)/config/Make.rules
+ifeq ($(USE_SPARC_ASM),yes)
+ASRC = IceAtomic.c
+AOBJ = IceAtomic.o
+SRCS := $(SRCS) $(ASRC)
+OBJS := $(OBJS) $(AOBJ)
+CFLAGS := $(CFLAGS) -fomit-frame-pointer
+endif
+
CPPFLAGS := $(CPPFLAGS) -DICE_UTIL_API_EXPORTS
diff --git a/cpp/src/icecpp/config.h b/cpp/src/icecpp/config.h
index cb8a4568706..324f2149d34 100644
--- a/cpp/src/icecpp/config.h
+++ b/cpp/src/icecpp/config.h
@@ -17,7 +17,7 @@
// configure script from the gcc-2.8.1 distribution.
//
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
+#if defined(__linux) || defined(__FreeBSD__) || defined(__sun)
# define HAVE_INTTYPES_H 1
# define TIME_WITH_SYS_TIME 1
# define HAVE_BCMP 1
@@ -60,6 +60,8 @@
#elif (defined(__linux) || defined(__FreeBSD__)) && (defined(__i386) || defined(__x86_64)) \
|| defined (__sun)
# define WCHAR_TYPE_SIZE 4
+#elif defined(__linux) && defined(__sparc__)
+# define WCHAR_TYPE_SIZE 4
#else
# error "unsupported operating system or platform"
#endif