summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2003-12-15 15:34:27 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2003-12-15 15:34:27 +0000
commita0035d0d6934f6d8622c518d0193c2e18035d2f1 (patch)
treeae3fad714fc7289a050fbf581026a4bf40eddb5a
parentd6c754f0717ff66bdcc03bb7dd729fe0f451671b (diff)
downloadATCD-a0035d0d6934f6d8622c518d0193c2e18035d2f1.tar.gz
ChangeLogTag:Mon Dec 15 10:06:17 2003 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog14
-rw-r--r--ace/Process_Semaphore.cpp14
-rw-r--r--ace/Process_Semaphore.h10
-rw-r--r--ace/Thread_Semaphore.cpp8
-rw-r--r--ace/Thread_Semaphore.h6
-rw-r--r--tests/Sigset_Ops_Test.cpp79
6 files changed, 91 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 04461aa2cc0..9d8f749a777 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,20 @@ Mon Dec 15 11:35:12 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl>
ACE_OS::strcasecmp. This fixes a compile error when ACE_NTRACE has
been defined to 0
+Sun Dec 14 15:26:46 2003 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
+
+ * ace/Thread_Semaphore.{h,cpp}: Added support for an ACE_Thread_Semaphore
+ that takes a first param that's an ACE_TCHAR * so that things
+ will work properly if ACE_Thread_Semaphore is used with
+ ACE_Malloc<>. Thanks to John Glynn <jglynn@bjc.org> for
+ motivating this.
+
+ * ace/Process_Semaphore.{h,cpp}: Added support for an ACE_Process_Semaphore
+ that takes a first param that's an ACE_TCHAR * so that things
+ will work properly if ACE_Process_Semaphore is used with
+ ACE_Malloc<>. Thanks to John Glynn <jglynn@bjc.org> for
+ motivating this.
+
Sat Dec 13 23:29:05 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
* bin/tao_orb_tests.lst:
diff --git a/ace/Process_Semaphore.cpp b/ace/Process_Semaphore.cpp
index 81a3fd1d07f..fbdf6052f06 100644
--- a/ace/Process_Semaphore.cpp
+++ b/ace/Process_Semaphore.cpp
@@ -35,6 +35,20 @@ ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count,
// ACE_TRACE ("ACE_Process_Semaphore::ACE_Process_Semaphore");
}
+ACE_Process_Semaphore::ACE_Process_Semaphore (const ACE_TCHAR *name,
+ void *arg,
+ int max)
+#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS)
+ : lock_ (1, USYNC_PROCESS, name, arg, max)
+#else
+ : lock_ (name, ACE_SV_Semaphore_Complex::ACE_CREATE, 1)
+#endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS */
+{
+ arg = arg;
+ max = max;
+// ACE_TRACE ("ACE_Process_Semaphore::ACE_Process_Semaphore");
+}
+
ACE_Process_Semaphore::~ACE_Process_Semaphore (void)
{
// ACE_TRACE ("ACE_Process_Semaphore::~ACE_Process_Semaphore");
diff --git a/ace/Process_Semaphore.h b/ace/Process_Semaphore.h
index a9ae74a92cd..51c632b61d6 100644
--- a/ace/Process_Semaphore.h
+++ b/ace/Process_Semaphore.h
@@ -9,12 +9,10 @@
* Wrapper for Dijkstra style general semaphores that work
* across processes.
*
- *
- * @author Doug Schmidt
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
*/
//=============================================================================
-
#ifndef ACE_PROCESS_SEMAPHORE_H
#define ACE_PROCESS_SEMAPHORE_H
#include /**/ "ace/pre.h"
@@ -47,6 +45,12 @@ public:
void * = 0,
int max = 0x7FFFFFFF);
+ /// Initialize the semaphore, with an initial value of 1 and a
+ /// maximum value of <max>.
+ ACE_Process_Semaphore (const ACE_TCHAR *name,
+ void * = 0,
+ int max = 0x7FFFFFFF);
+
/**
* This method is a no-op, i.e., it doesn't remove the semaphore.
* If you want to remove the semaphore, you must call the <remove>
diff --git a/ace/Thread_Semaphore.cpp b/ace/Thread_Semaphore.cpp
index f5efb30d27a..22b25cc2920 100644
--- a/ace/Thread_Semaphore.cpp
+++ b/ace/Thread_Semaphore.cpp
@@ -38,4 +38,12 @@ ACE_Thread_Semaphore::ACE_Thread_Semaphore (u_int count,
{
// ACE_TRACE ("ACE_Thread_Semaphore::ACE_Thread_Semaphore");
}
+
+ACE_Thread_Semaphore::ACE_Thread_Semaphore (const ACE_TCHAR *name,
+ void *arg,
+ int max)
+ : ACE_Semaphore (1, USYNC_THREAD, name, arg, max)
+{
+// ACE_TRACE ("ACE_Thread_Semaphore::ACE_Thread_Semaphore");
+}
#endif /* ACE_HAS_THREADS */
diff --git a/ace/Thread_Semaphore.h b/ace/Thread_Semaphore.h
index e39ec55ad14..2c4b23c7578 100644
--- a/ace/Thread_Semaphore.h
+++ b/ace/Thread_Semaphore.h
@@ -45,6 +45,12 @@ public:
void * = 0,
int max = 0x7FFFFFFF);
+ /// Initialize the semaphore, with an initial value of 1,
+ /// maximum value of <max>, and unlocked by default.
+ ACE_Thread_Semaphore (const ACE_TCHAR *name = 0,
+ void * = 0,
+ int max = 0x7FFFFFFF);
+
/// Default dtor.
~ACE_Thread_Semaphore (void);
diff --git a/tests/Sigset_Ops_Test.cpp b/tests/Sigset_Ops_Test.cpp
index 3c6f4439fc0..0d1e5a66913 100644
--- a/tests/Sigset_Ops_Test.cpp
+++ b/tests/Sigset_Ops_Test.cpp
@@ -25,25 +25,30 @@
ACE_RCSID(tests, Sigset_Ops_Test, "$Id$")
void
-siglistset(sigset_t x, int *sigset)
+siglistset (sigset_t x, int *sigset)
{
int empty = 1 ;
- int retv = 0 ;
+ int result = 0 ;
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Signal(s) in the set = %08x:\n "), x)) ;
- for (int i = 1; i < ACE_NSIG; i++) {
- if ((retv = ACE_OS::sigismember (&x, i)) > 0) {
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %d"), i)) ;
- empty = 0 ;
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Signal (s) in the set = %08x:\n "), x)) ;
+
+ for (int i = 1; i < ACE_NSIG; i++)
+ {
+ result = ACE_OS::sigismember (&x, i);
+
+ if (result > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %d"), i)) ;
+ empty = 0 ;
+ }
+
+ ACE_ASSERT ((sigset [i] ? result > 0 : result <= 0)) ;
}
- ACE_ASSERT ((sigset [i] ? retv > 0 : retv <= 0)) ;
- }
- if (empty) {
+
+ if (empty)
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Empty!!\n\n"))) ;
- }
- else {
+ else
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\n"))) ;
- }
}
int
@@ -52,9 +57,9 @@ run_main (int, ACE_TCHAR *[])
ACE_START_TEST (ACE_TEXT ("Sigset_Ops_Test"));
#if defined (ACE_LACKS_SIGSET)
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%n uses ACE implementation of sigset*() functions.\n\n"))) ;
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%n uses ACE implementation of sigset* () functions.\n\n"))) ;
#else
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%n uses platform's native sigset*() functions.\n\n"))) ;
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%n uses platform's native sigset* () functions.\n\n"))) ;
#endif
sigset_t x ; // examined sigset
@@ -67,23 +72,22 @@ run_main (int, ACE_TCHAR *[])
const int tsig1 = 5 ;
const int tsig2 = 8 ;
-
// Testing sigfillset
ACE_OS::sigfillset (&x) ;
// fill the comparison set
- for (i = 0 ; i < ACE_NSIG ; i++) {
+ for (i = 0 ; i < ACE_NSIG ; i++)
sigset [i] = 1 ;
- }
+
siglistset (x, sigset) ;
// testing sigemptyset
ACE_OS::sigemptyset (&x) ;
// empty the comparison set
- for (i = 0 ; i < ACE_NSIG ; i++) {
+ for (i = 0 ; i < ACE_NSIG ; i++)
sigset [i] = 0 ;
- }
+
siglistset (x, sigset) ;
// add the first signal into set
@@ -97,33 +101,34 @@ run_main (int, ACE_TCHAR *[])
siglistset (x, sigset) ;
// then remove it
- ACE_OS::sigdelset(&x, tsig1) ;
+ ACE_OS::sigdelset (&x, tsig1) ;
sigset [tsig1] = 0 ;
- siglistset(x, sigset) ;
+ siglistset (x, sigset) ;
// remove the second one
- ACE_OS::sigdelset(&x, tsig2) ;
+ ACE_OS::sigdelset (&x, tsig2) ;
sigset [tsig2] = 0 ;
- siglistset(x, sigset) ;
+ siglistset (x, sigset) ;
// Now testing out of bound signal
- if (ACE_OS::sigismember (&x, ACE_NSIG) >= 0) {
- ACE_ERROR((LM_ERROR, ACE_TEXT ("Platform doesn't check for valid signal number.\n")));
- status = 1;
- }
- else if (ACE_OS::last_error() != EINVAL) {
- ACE_ERROR((LM_ERROR, ACE_TEXT ("%p.\n"), ACE_TEXT ("Expected status EINVAL; got")));
- status = 1;
- }
+ if (ACE_OS::sigismember (&x, ACE_NSIG) >= 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Platform doesn't check for valid signal number.\n")));
+ status = 1;
+ }
+ else if (ACE_OS::last_error () != EINVAL)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p.\n"), ACE_TEXT ("Expected status EINVAL; got")));
+ status = 1;
+ }
/* Skip this test at this moment
- // Test if platform can catch invalid sigset error
- // Currently, I can only think of passing a NULL ptr
- // If you know other situations that fall into this
- // catagory, please let me know. Thanks.
+ // Test if platform can catch invalid sigset error Currently, I can
+ // only think of passing a NULL ptr If you know other situations
+ // that fall into this catagory, please let me know. Thanks.
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Now testing invalid sigset. If your platform gets a \nsegmentation fault, then it doesn't check the error properly.\n"))) ;
- ACE_ASSERT (ACE_OS::sigfillset (NULL) < 0 && ACE_OS::last_error() == EFAULT) ;
+ ACE_ASSERT (ACE_OS::sigfillset (NULL) < 0 && ACE_OS::last_error () == EFAULT) ;
*/
ACE_END_TEST;