summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-09-01 21:07:37 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-09-01 21:07:37 +0000
commitcb24396bcc30f69f1314cb695c8bd5a48908063c (patch)
treef07bdcdbacdbdb97452166659baabcb9a9717919
parent06bdf7583baa87668223157b5b5eef210ecf1fcc (diff)
downloadATCD-cb24396bcc30f69f1314cb695c8bd5a48908063c.tar.gz
ChangeLogTag:Wed Sep 1 15:51:41 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-rw-r--r--ChangeLog-99b14
-rw-r--r--THANKS1
-rw-r--r--ace/OS.cpp34
-rw-r--r--ace/OS.i24
-rw-r--r--ace/SV_Semaphore_Complex.cpp21
-rw-r--r--ace/SV_Semaphore_Complex.h40
-rw-r--r--ace/SV_Semaphore_Simple.cpp9
7 files changed, 87 insertions, 56 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index cd8769b4c33..8edb2cf8455 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,17 @@
+Wed Sep 1 15:51:41 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * ace/OS.i: Ensure that ACE_OS::localtime_r() does the "Right
+ Thing"[TM], i.e., returns the pointer in the buffer provided by
+ the user, even if there's no native support for localtime_r() on
+ the OS platform. In addition, added an ACE_OS_GUARD for this
+ use-case so that we don't have race conditions in MT programs.
+ This necessitated moving the localtime_r() wrapper facade into
+ the OS.cpp file. Thanks to Jody Hagins <jody@atdesk.com> for
+ these suggestions.
+
+ * ace/SV_Semaphore_Complex: Improved the documentation a bit
+ based on comments from Herbert <herbert@shym.com>.
+
Wed Sep 1 15:15:00 1999 Luther Baker <ljb1@cs.wustl.edu>
* ace/Arg_Shifter.h: Added function (get_current_parameter(offset)
diff --git a/THANKS b/THANKS
index 087dbd62236..6d9fd0b353f 100644
--- a/THANKS
+++ b/THANKS
@@ -743,6 +743,7 @@ Skye Sweeney <ssweeney@sanders.com>
Lars Immisch <lars@ibp.de>
Adrian Mercieca <adrian@anvil.co.uk>
Stefan Wendt <wendts@stud.fh-luebeck.de>
+Herbert <herbert@shym.com>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson. Paul devised the recursive Makefile scheme that
diff --git a/ace/OS.cpp b/ace/OS.cpp
index c2183f8dc44..b5ef202511b 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -4728,6 +4728,40 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
}
}
+struct tm *
+ACE_OS::localtime_r (const time_t *t, struct tm *res)
+{
+ ACE_TRACE ("ACE_OS::localtime_r");
+#if defined (ACE_HAS_REENTRANT_FUNCTIONS)
+# if defined (DIGITAL_UNIX)
+ ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0);
+# elif defined (HPUX_10)
+ return (::localtime_r (t, res) == 0 ? res : (struct tm *)0);
+# else
+ ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0);
+# endif /* DIGITAL_UNIX */
+#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
+ ACE_OS_GUARD
+
+ ACE_UNUSED_ARG (res);
+ struct tm * res_ptr;
+ ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr);
+ if (res_ptr == 0)
+ return 0;
+ else
+ {
+ *res = *res_ptr;
+ return res;
+ }
+#else
+ // @@ Same as ACE_OS::localtime (), you need to implement it
+ // yourself.
+ ACE_UNUSED_ARG (t);
+ ACE_UNUSED_ARG (res);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_HAS_REENTRANT_FUNCTIONS */
+}
+
ssize_t
ACE_OS::pread (ACE_HANDLE handle,
void *buf,
diff --git a/ace/OS.i b/ace/OS.i
index 10ee95db86f..15e4db8d171 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -9068,30 +9068,6 @@ ACE_OS::localtime (const time_t *t)
}
ACE_INLINE struct tm *
-ACE_OS::localtime_r (const time_t *t, struct tm *res)
-{
- ACE_TRACE ("ACE_OS::localtime_r");
-#if defined (ACE_HAS_REENTRANT_FUNCTIONS)
-# if defined (DIGITAL_UNIX)
- ACE_OSCALL_RETURN (::_Plocaltime_r(t, res), struct tm *, 0);
-# elif defined (HPUX_10)
- return (::localtime_r(t, res) == 0 ? res : (struct tm *)0);
-# else
- ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0);
-# endif /* DIGITAL_UNIX */
-#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
- ACE_UNUSED_ARG (res);
- ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0);
-#else
- // @@ Same as ACE_OS::localtime (), you need to implement it
- // yourself.
- ACE_UNUSED_ARG (t);
- ACE_UNUSED_ARG (res);
- ACE_NOTSUP_RETURN (0);
-#endif /* ACE_HAS_REENTRANT_FUNCTIONS */
-}
-
-ACE_INLINE struct tm *
ACE_OS::gmtime (const time_t *t)
{
#if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
diff --git a/ace/SV_Semaphore_Complex.cpp b/ace/SV_Semaphore_Complex.cpp
index a269c5319c5..9b062b466a2 100644
--- a/ace/SV_Semaphore_Complex.cpp
+++ b/ace/SV_Semaphore_Complex.cpp
@@ -85,23 +85,24 @@ ACE_SV_Semaphore_Complex::open (key_t k,
{
this->internal_id_ = ACE_OS::semget
(this->key_,
- (u_short) 2 + nsems, perms | ACE_SV_Semaphore_Complex::ACE_CREATE);
+ (u_short) 2 + nsems,
+ perms | ACE_SV_Semaphore_Complex::ACE_CREATE);
if (this->internal_id_ == -1)
return -1; // permission problem or tables full
- // When the ACE_SV_Semaphore is created, we know that the
- // value of all 3 members is 0. Get a lock on the
- // ACE_SV_Semaphore by waiting for [0] to equal 0, then
- // increment it.
+ // When the <ACE_SV_Semaphore_Complex> is created, we know
+ // that the value of all 3 members is 0. Get a lock on the
+ // <ACE_SV_Semaphore_Complex> by waiting for [0] to equal 0,
+ // then increment it.
// There is a race condition here. There is the possibility
- // that between the semget() above and the semop() below,
- // another process can call out close() function which can
- // remove the ACE_SV_Semaphore if that process is the last
+ // that between the <semget> above and the <semop> below,
+ // another process can call out <close> function which can
+ // remove the <ACE_SV_Semaphore> if that process is the last
// one using it. Therefor we handle the error condition of
- // an invalid ACE_SV_Semaphore ID specifically below, and if
- // it does happen, we just go back and create it again.
+ // an invalid <ACE_SV_Semaphore> ID specifically below, and
+ // if it does happen, we just go back and create it again.
result = ACE_OS::semop (this->internal_id_,
&ACE_SV_Semaphore_Complex::op_lock_[0],
2);
diff --git a/ace/SV_Semaphore_Complex.h b/ace/SV_Semaphore_Complex.h
index a72c96d33bf..b9e36484f0a 100644
--- a/ace/SV_Semaphore_Complex.h
+++ b/ace/SV_Semaphore_Complex.h
@@ -32,28 +32,28 @@ class ACE_Export ACE_SV_Semaphore_Complex : private ACE_SV_Semaphore_Simple
// = DESCRIPTION
// This code is a port to C++, inspired by: W. Richard Stevens
// from his book: UNIX Network Programming (Prentice Hall, ISBN
- // 0-13-949876-1 - 1990) ACE_SV_Semaphore Interface: we provide
- // a simpler and easier to understand interface to the System V
- // ACE_SV_Semaphore calls. We create and use a 2 + n-member
- // set for the requested ACE_SV_Semaphore. The first member,
- // [0], is a counter used to know when all processes have
- // finished with the ACE_SV_Semaphore. The counter is
- // initialized to a large number, decremented on every create
- // or open and incremented on every close. This way we can use
- // the "adjust" feature provided by System V so that any
- // process that exit's without calling <close> is accounted
- // for. It doesn't help us if the last process does this (as we
- // have no way of getting control to remove the
- // ACE_SV_Semaphore) but it will work if any process other than
- // the last does an exit (intentional or unintentional).
+ // 0-13-949876-1 - 1990). We provide a simpler and easier to
+ // understand interface to the System V Semaphore system calls.
+ // We create and use a 2 + n-member set for the requested
+ // <ACE_SV_Semaphore_Complex>. The first member, [0], is a
+ // counter used to know when all processes have finished with
+ // the <ACE_SV_Semaphore_Complex>. The counter is initialized
+ // to a large number, decremented on every create or open and
+ // incremented on every close. This way we can use the "adjust"
+ // feature provided by System V so that any process that exit's
+ // without calling <close> is accounted for. It doesn't help us
+ // if the last process does this (as we have no way of getting
+ // control to remove the <ACE_SV_Semaphore_Complex>) but it
+ // will work if any process other than the last does an exit
+ // (intentional or unintentional).
//
- // The second member, [1], of the ACE_SV_Semaphore is used as a
- // lock variable to avoid any race conditions in the <create>
- // and <close> functions.
+ // The second member, [1], of the semaphore is used as a lock
+ // variable to avoid any race conditions in the <create> and
+ // <close> functions.
//
- // The members beyond [1] are actual ACE_SV_Semaphore values in
- // the array of SV_Semaphores (which may be sized by the user
- // in the constructor).
+ // The members beyond [1] are actual semaphore values in the
+ // array of semaphores, which may be sized by the user in the
+ // constructor.
public:
enum
{
diff --git a/ace/SV_Semaphore_Simple.cpp b/ace/SV_Semaphore_Simple.cpp
index 66a9d70627c..a8fb066487c 100644
--- a/ace/SV_Semaphore_Simple.cpp
+++ b/ace/SV_Semaphore_Simple.cpp
@@ -166,8 +166,13 @@ ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const char *name,
int perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
- if (this->open (name, flags, initial_value, n, perms) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"),
+ if (this->open (name,
+ flags,
+ initial_value,
+ n,
+ perms) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("%p\n"),
ASYS_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple")));
}