summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES5
-rw-r--r--cpp/config/Make.rules.Linux30
-rw-r--r--cpp/demo/IceBox/hello/Makefile2
-rw-r--r--cpp/demo/IcePack/hello/Makefile2
-rw-r--r--cpp/include/IceUtil/Config.h9
-rw-r--r--cpp/include/IceUtil/Shared.h21
-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
11 files changed, 195 insertions, 19 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index f5a7380470e..a0a1ab3fb56 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -6,6 +6,11 @@ Changes since version 1.1.0
- Added menu with several options to throughput demo.
+- Added Linux/SPARC port from Ferris McCormick
+
+- Fixed a bug where daemonized Ice::Application wouldn't shutdown
+ properly.
+
- Major Freeze update:
- Removed the lowest Freeze layer. You should use instead Berkeley
diff --git a/cpp/config/Make.rules.Linux b/cpp/config/Make.rules.Linux
index e3275f70d96..11b9544c1fb 100644
--- a/cpp/config/Make.rules.Linux
+++ b/cpp/config/Make.rules.Linux
@@ -16,9 +16,28 @@
# This file is included by Make.rules when uname is Linux.
#
+USE_SPARC_ASM = irrelevant
MACHINE = $(shell uname -m)
-CXX = c++
+CXX = c++
+
+ifeq ($(MACHINE),sparc64)
+#
+# We are an ultra, at least, and so have the atomic instructions
+#
+USE_SPARC_ASM = yes
+CXXARCHFLAGS := -mcpu=ultrasparc -pipe -Wno-deprecated -DUSE_SPARC_ASM
+endif
+
+ifeq ($(MACHINE),sparc)
+#
+# We are a sun4m or sun4c
+# On sun4m, there is a bug in some CPU/kernel/gcc configurations which
+# prevent us from using '-mcpu=v8'
+#
+USE_SPARC_ASM = no
+CXXARCHFLAGS := -mtune=v8 -pipe -Wno-deprecated -DICE_USE_MUTEX_SHARED
+endif
ifeq ($(MACHINE),x86_64)
@@ -37,6 +56,13 @@ else
CXXFLAGS := -g $(CXXFLAGS)
endif
+ifeq ($(USE_SPARC_ASM),yes)
+CFLAGS := -O3 -mcpu=ultrasparc -pipe -DNDEBUG -fPIC -DUSE_SPARC_ASM
+endif
+ifeq ($(USE_SPARC_ASM),no)
+CFLAGS := -O3 -mcpu=v8 -pipe -DNDEBUG -fPIC -DICE_USE_MUTEX_SHARED
+endif
+
mkshlib = $(CXX) -shared $(LDFLAGS) -o $(1) -Wl,-h,$(2) $(3) $(4)
BASELIBS = -lIceUtil $(STLPORT_LIBS) -lpthread
@@ -45,6 +71,6 @@ LIBS = -lIce $(BASELIBS)
ICEUTIL_OS_LIBS = -lpthread
ICE_OS_LIBS = -ldl
-PLATFORM_HAS_READLINE := yes
+PLATFORM_HAS_READLINE := yes
export LD_LIBRARY_PATH := $(libdir):$(LD_LIBRARY_PATH)
diff --git a/cpp/demo/IceBox/hello/Makefile b/cpp/demo/IceBox/hello/Makefile
index 25502f8b41e..23d9803ee09 100644
--- a/cpp/demo/IceBox/hello/Makefile
+++ b/cpp/demo/IceBox/hello/Makefile
@@ -20,7 +20,7 @@ LIBFILENAME = $(call mklibfilename,HelloService,$(VERSION))
SONAME = $(call mksoname,HelloService,$(SOVERSION))
LIBNAME = $(call mklibname,HelloService)
-TARGETS = $(CLIENT) $(NAME) $(LIBFILENAME) $(SONAME) $(LIBNAME)
+TARGETS = $(CLIENT) $(LIBFILENAME) $(SONAME) $(LIBNAME)
OBJS = Hello.o
diff --git a/cpp/demo/IcePack/hello/Makefile b/cpp/demo/IcePack/hello/Makefile
index f3a34f8b0f6..ecb0ef264d1 100644
--- a/cpp/demo/IcePack/hello/Makefile
+++ b/cpp/demo/IcePack/hello/Makefile
@@ -21,7 +21,7 @@ LIBFILENAME = $(call mklibfilename,HelloService,$(VERSION))
SONAME = $(call mksoname,HelloService,$(SOVERSION))
LIBNAME = $(call mklibname,HelloService)
-TARGETS = $(CLIENT) $(NAME) $(LIBFILENAME) $(SONAME) $(LIBNAME) $(SERVER)
+TARGETS = $(CLIENT) $(LIBFILENAME) $(SONAME) $(LIBNAME) $(SERVER)
OBJS = Hello.o
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index f4965502ca9..cc10af379aa 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -23,7 +23,7 @@
//
#if defined(__i386) || defined(_M_IX86) || defined (__x86_64)
# define ICE_LITTLE_ENDIAN
-#elif defined(__sparc)
+#elif defined(__sparc) || defined(__sparc__)
# define ICE_BIG_ENDIAN
#else
# error "Unknown architecture"
@@ -32,7 +32,12 @@
//
// 32 or 64 bit mode?
//
-#if (defined(__sun) && defined(__sparcv9)) || (defined(__linux) && defined(__x86_64))
+#if defined(__linux) && defined(__sparc__)
+//
+// We are a linux sparc, which forces 32 bit usr land, no matter the architecture
+//
+# define ICE_32
+#elif (defined(__sun) && defined(__sparcv9)) || (defined(__linux) && defined(__x86_64))
# define ICE_64
#else
# define ICE_32
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h
index 7666f999dbd..a6a7aff8895 100644
--- a/cpp/include/IceUtil/Shared.h
+++ b/cpp/include/IceUtil/Shared.h
@@ -17,7 +17,26 @@
#include <IceUtil/Config.h>
-#if (defined(__linux) || defined(__FreeBSD__)) && defined(__i386) && !defined(__ICC)
+//
+// Here are the sparc64+linux atomic functions, if you wish them.
+//
+#if defined(__linux) && defined(__sparc__) && defined(USE_SPARC_ASM) && !defined(ICE_USE_MUTEX_SHARED)
+# define ICE_HAS_ATOMIC_FUNCTIONS
+extern "C"
+{
+#include <asm-sparc64/atomic.h>
+int __atomic_exchange_and_add(atomic_t *v, int i);
+}
+#define ice_atomic_t atomic_t
+#define ice_atomic_set(v,i) atomic_set(v,i)
+#define ice_atomic_inc(v) atomic_inc(v)
+#define ice_atomic_dec_and_test(v) atomic_dec_and_test(v)
+#define ice_atomic_exchange_add(i,v) (__atomic_exchange_and_add(v,i))
+
+#elif defined(ICE_USE_MUTEX_SHARED)
+# include <IceUtil/Mutex.h>
+
+#elif (defined(__linux) || defined(__FreeBSD__)) && defined(__i386) && !defined(__ICC)
# define ICE_HAS_ATOMIC_FUNCTIONS
// __ICC: The inline assembler causes problems with shared libraries.
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