diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-02-06 06:27:00 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-02-06 06:27:00 +0000 |
commit | 912cc4acf7410cc4d2e353dd12ed465058728bc2 (patch) | |
tree | 8cf6445938d7afd4ae2895ee28449d7e36d44ae2 | |
parent | 3152ea6d7cc3d068072ef24b17b2789f5ef7d41f (diff) | |
download | ATCD-912cc4acf7410cc4d2e353dd12ed465058728bc2.tar.gz |
fpp
-rw-r--r-- | ChangeLog-97a | 24 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | ace/IOStream.cpp | 10 | ||||
-rw-r--r-- | ace/IOStream.h | 4 | ||||
-rw-r--r-- | ace/OS.h | 7 | ||||
-rw-r--r-- | ace/OS.i | 135 | ||||
-rw-r--r-- | ace/README | 18 | ||||
-rw-r--r-- | ace/SOCK_Dgram.cpp | 12 | ||||
-rw-r--r-- | ace/config-dgux-4.11-epc.h | 4 | ||||
-rw-r--r-- | ace/config-osf1-4.0-g++.h | 9 | ||||
-rw-r--r-- | ace/config-osf1-4.0.h | 9 | ||||
-rw-r--r-- | examples/IOStream/Makefile | 4 | ||||
-rw-r--r-- | tests/Naming_Test.cpp | 43 |
13 files changed, 199 insertions, 82 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a index 95a7a49c470..5951ed334a2 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,6 +1,28 @@ Wed Feb 5 01:45:03 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> - * tests/Naming_Test.cpp: Cleaned up a few minor things. + * ace/OS.i: Changed the Win32 implementation of all methods that call + WaitForMultipleObjects() so that errno is set to + WAIT_ABANDONED if the mutex is abandoned. This makes it + possible for users to understand why ACE_OS methods that use + synchronization operations fail. Thanks to Ivan Murphy + <Ivan.Murphy@med.siemens.de> for reporting this problem. + + * ace/IOStream.cpp (ACE_Streambuf): Moved the const initialization + from the header file to the constructor since this is the only + portable way to do this. Thanks to Michael Maxie + <maxie@acm.org> for reporting this. + + * ace/OS.i: Updated the call to thr_setprio() for pthreads so that + it first determines the existing scheduling parameters and then + updates the priority. Thanks to Thilo Kielmann + <kielmann@informatik.uni-siegen.de> for help with this. + + * ace/config-osf1-4.0*.h: Updated ACE_NEEDS_HUGE_THREAD_STACKSIZE + to be 1 mega to minimize porting surprises. Thanks to Thilo + Kielmann <kielmann@informatik.uni-siegen.de> for help with this. + + * tests/Naming_Test.cpp: Cleaned up a few minor things related to + int i = 0 vs. size_t i = 0. * ace/SOCK_Dgram.cpp: Added a new macro called ACE_HAS_SOCKADDR_MSG_NAME, which is used on platforms (e.g., @@ -1,4 +1,4 @@ -This is ACE version 4.1.2, released Wed Feb 5 02:44:29 CST 1997. +This is ACE version 4.1.3, released Wed Feb 5 02:44:29 CST 1997. If you have any problems with ACE, please send email to Douglas C. Schmidt (schmidt@cs.wustl.edu). diff --git a/ace/IOStream.cpp b/ace/IOStream.cpp index 01b3a8d3e8d..947bbc76bcd 100644 --- a/ace/IOStream.cpp +++ b/ace/IOStream.cpp @@ -80,7 +80,7 @@ // a myiostream&, the second >> will be invoked as desired. */ template <class STREAM> int -ACE_Streambuf<STREAM>::underflow( void ) +ACE_Streambuf<STREAM>::underflow (void) { // If input mode is not set, any attempt to read from the stream is // a failure. @@ -344,8 +344,8 @@ ACE_Streambuf<STREAM>::flushbuf (void) return 0; } -template <class STREAM> -int ACE_Streambuf<STREAM>::get_one_byte (void) +template <class STREAM> int +ACE_Streambuf<STREAM>::get_one_byte (void) { char * p = base (); ssize_t i = peer_->recv_n (p, 1); @@ -405,7 +405,9 @@ ACE_Streambuf<STREAM>::fillbuf (void) template <class STREAM> ACE_Streambuf<STREAM>::ACE_Streambuf (STREAM *peer, int io_mode) : peer_ (peer), - mode_ (io_mode) + mode_ (io_mode), + get_mode_ (1), + put_mode_ (2) { // A streambuf allows for unbuffered IO where every character is // read as requested and written as provided. To me, this seems diff --git a/ace/IOStream.h b/ace/IOStream.h index 875e0e24750..5570f3370a4 100644 --- a/ace/IOStream.h +++ b/ace/IOStream.h @@ -140,8 +140,8 @@ private: // This helps us to optimize the underflow/overflow functions. u_char cur_mode_; - const u_char get_mode_ = 1; - const u_char put_mode_ = 2; + const u_char get_mode_; + const u_char put_mode_; int mode_; // mode tells us if we're working for an istream, ostream, or @@ -2241,7 +2241,10 @@ class ACE_Export ACE_OS // This class defines an operating system independent // programming API that shields developers from non-portable // aspects of writing efficient system programs on Win32, POSIX, - // and other versions of UNIX. + // and other versions of UNIX. If you are porting ACE to a new + // platform, this is the place to focus your attention. Please + // see the README file in this directory for complete + // information on the meaning of the various macros. // // = DESCRIPTION // This class encapsulates all the differences between various @@ -2250,7 +2253,7 @@ class ACE_Export ACE_OS // which makes it *much* easier to move ACE to a new platform. // The methods in this class also automatically restart when // interrupts occur during system calls (assuming that the - // ACE_Log_Msg::restart() flag is enabled). + // <ACE_Log_Msg::restart> flag is enabled). { public: struct ace_flock_t @@ -1005,11 +1005,19 @@ ACE_OS::mutex_lock (ACE_mutex_t *m) { case USYNC_PROCESS: // Timeout can't occur, so don't bother checking... - if (::WaitForSingleObject(m->proc_mutex_, INFINITE) == WAIT_OBJECT_0) - return 0; - else - // This is a hack, we need to find an appropriate mapping... - ACE_FAIL_RETURN (-1); + + switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + errno = WAIT_ABANDONED; + return -1; + default: + // This is a hack, we need to find an appropriate mapping... + errno = ::GetLastError (); + return -1; + } case USYNC_THREAD: return ACE_OS::thread_mutex_lock (&m->thr_mutex_); default: @@ -1040,14 +1048,18 @@ ACE_OS::mutex_trylock (ACE_mutex_t *m) case USYNC_PROCESS: { // Try for 0 milliseconds - i.e. nonblocking. - DWORD result = ::WaitForSingleObject(m->proc_mutex_, 0); - - if (result == WAIT_OBJECT_0) - return 0; - else + switch (::WaitForSingleObject (m->proc_mutex_, 0)) { - errno = result == WAIT_TIMEOUT ? ETIME : ::GetLastError (); - // This is a hack, we need to find an appropriate mapping... + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + errno = WAIT_ABANDONED; + return -1; + case WAIT_TIMEOUT: + errno = ETIME; + return -1; + default: + errno = ::GetLastError (); return -1; } } @@ -1499,9 +1511,18 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, if (result != WAIT_OBJECT_0) { - // This is a hack, we need to find an appropriate mapping... - error = result == WAIT_TIMEOUT ? ETIME : ::GetLastError (); - result = -1; + switch (result) + { + case WAIT_ABANDONED: + error = WAIT_ABANDONED; + break; + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } } else if (cv->was_broadcast_ && cv->waiters_ == 0) // Release the signaler/broadcaster if we're the last waiter. @@ -1599,9 +1620,18 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, if (result != WAIT_OBJECT_0) { - // This is a hack, we need to find an appropriate mapping... - error = result == WAIT_TIMEOUT ? ETIME : ::GetLastError (); - result = -1; + switch (result) + { + case WAIT_ABANDONED: + error = WAIT_ABANDONED; + break; + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } } else if (cv->was_broadcast_ && cv->waiters_ == 0) // Release the signaler/broadcaster if we're the last waiter. @@ -1651,9 +1681,18 @@ ACE_OS::cond_wait (ACE_cond_t *cv, if (result != WAIT_OBJECT_0) { - // This is a hack, we need to find an appropriate mapping... - error = ::GetLastError (); - result = -1; + switch (result) + { + case WAIT_ABANDONED: + error = WAIT_ABANDONED; + break; + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } } else if (cv->was_broadcast_ && cv->waiters_ == 0) // Release the signaler/broadcaster if we're the last waiter. @@ -1991,10 +2030,15 @@ ACE_INLINE int ACE_OS::event_wait (ACE_event_t *event) { #if defined (ACE_WIN32) - if (::WaitForSingleObject (*event, INFINITE) == WAIT_OBJECT_0) - return 0; - else - ACE_FAIL_RETURN (-1); + switch (::WaitForSingleObject (*event, INFINITE)) + { + case WAIT_ABANDONED: + errno = WAIT_ABANDONED; + return -1; + default: + errno = ::GetLastError (); + return -1; + } #elif defined (ACE_HAS_THREADS) int result = 0; int error = 0; @@ -2060,12 +2104,17 @@ ACE_OS::event_timedwait (ACE_event_t *event, ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); result = ::WaitForSingleObject (*event, relative_time.msec ()); } - if (result == WAIT_OBJECT_0) - return 0; - else + + switch (result) { - errno = result == WAIT_TIMEOUT ? ETIME : ::GetLastError (); + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + errno = WAIT_ABANDONED; + return -1; + default: // This is a hack, we need to find an appropriate mapping... + errno = ::GetLastError (); return -1; } #elif defined (ACE_HAS_THREADS) @@ -3253,10 +3302,18 @@ ACE_OS::sema_wait (ACE_sema_t *s) return result; #elif defined (ACE_HAS_WTHREADS) - if (::WaitForSingleObject (*s, INFINITE) == WAIT_OBJECT_0) - return 0; - else - ACE_FAIL_RETURN (-1); + switch (::WaitForSingleObject (*s_, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + errno = WAIT_ABANDONED; + return -1; + default: + // This is a hack, we need to find an appropriate mapping... + errno = ::GetLastError (); + return -1; + } /* NOTREACHED */ #endif /* ACE_HAS_STHREADS */ #else @@ -3853,11 +3910,17 @@ ACE_OS::thr_setprio (ACE_hthread_t thr_id, int prio) #elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_LACKS_SETSCHED) struct sched_param param; int policy = 0; + int result; + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_id, &policy, ¶m), + ace_result_), + int, -1, retval); + if (result == -1) + return result; // error in pthread_getschedparam param.sched_priority = prio; - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, &policy, ¶m), - ace_result_), - int, -1); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, policy, ¶m), + result), + int, -1, result); #elif defined (ACE_HAS_WTHREADS) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (thr_id, prio), ace_result_), diff --git a/ace/README b/ace/README index 6dacd6e36fb..b05075a2696 100644 --- a/ace/README +++ b/ace/README @@ -1,11 +1,16 @@ -ACE DEFINES ------------------------------------------------------------------------------ +ACE Portability Macros + +---------------------------------------- The following describes the meaning of the C++ compiler macros that -may be set in the DEFFLAGS Makefile macro. When you port ACE to a new -platform and/or C++ compiler, make sure that you check to see which of -these need to be defined. Eventually, most of this information should -be auto-discovered via GNU autoconf or Larry Wall's metaconfig... +can be set in the config*.h file. When you port ACE to a new platform +and/or C++ compiler, make sure that you check to see which of these +need to be defined. It's helpful to check the various config*.h files +in this directory to see what's already been defined. If you need to +add new macros, please send them to me and I'll add them to this file. + +Eventually, most of this information should be auto-discovered via GNU +autoconf or Larry Wall's metaconfig... Macro Description ----- ----------- @@ -84,6 +89,7 @@ ACE_HAS_SIG_ATOMIC_T Compiler/platform defines the sig_atomic_t typedef ACE_HAS_SIG_C_FUNC Compiler requires extern "C" functions for signals. ACE_HAS_SIN_LEN Platform supports new BSD inet_addr len field. ACE_HAS_SIZET_SOCKET_LEN OS/compiler uses size_t * rather than int * for socket lengths +ACE_HAS_SOCKADDR_MSG_NAME Platform requires (struct sockaddr *) for msg_name field of struct msghdr. ACE_HAS_SOCKIO_H Compiler/platform provides the sockio.h file ACE_HAS_SPARCWORKS_401_SIGNALS Compiler has brain-damaged SPARCwork SunOS 4.x signal prototype... ACE_HAS_SSIZE_T Compiler supports the ssize_t typedef diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index b0c96326370..94238b50ca5 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -122,7 +122,11 @@ ACE_SOCK_Dgram::send (const iovec iov[], send_msg.msg_iov = (iovec *) iov; send_msg.msg_iovlen = n; - send_msg.msg_name = (caddr_t) addr.get_addr (); // caddr_t is POSIX for char * +#if defined (ACE_HAS_SOCKADDR_MSG_NAME) + send_msg.msg_name = (struct sockaddr *) addr.get_addr (); +#else + send_msg.msg_name = (char *) addr.get_addr (); +#endif /* ACE_HAS_SOCKADDR_MSG_NAME */ send_msg.msg_namelen = addr.get_size (); send_msg.msg_accrights = 0; send_msg.msg_accrightslen = 0; @@ -143,7 +147,11 @@ ACE_SOCK_Dgram::recv (iovec iov[], recv_msg.msg_iov = (iovec *) iov; recv_msg.msg_iovlen = n; - recv_msg.msg_name = (caddr_t) addr.get_addr (); // caddr_t is POSIX for char * +#if defined (ACE_HAS_SOCKADDR_MSG_NAME) + recv_msg.msg_name = (struct sockaddr *) addr.get_addr (); +#else + recv_msg.msg_name = (char *) addr.get_addr (); +#endif /* ACE_HAS_SOCKADDR_MSG_NAME */ recv_msg.msg_namelen = addr.get_size (); recv_msg.msg_accrights = 0; recv_msg.msg_accrightslen = 0; diff --git a/ace/config-dgux-4.11-epc.h b/ace/config-dgux-4.11-epc.h index af1f4872866..e746dba526d 100644 --- a/ace/config-dgux-4.11-epc.h +++ b/ace/config-dgux-4.11-epc.h @@ -4,6 +4,10 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H +// Platform requires (struct sockaddr *) for msg_name field of struct +// msghdr. +#define ACE_HAS_SOCKADDR_MSG_NAME + // Platform lacks strcasecmp(). #define ACE_LACKS_STRCASECMP diff --git a/ace/config-osf1-4.0-g++.h b/ace/config-osf1-4.0-g++.h index 9c4f5bd498e..f26ae5d5f3d 100644 --- a/ace/config-osf1-4.0-g++.h +++ b/ace/config-osf1-4.0-g++.h @@ -208,7 +208,10 @@ #define ACE_HAS_BROKEN_T_ERRNO #define ACE_HAS_BROKEN_R_ROUTINES -// We need a larger per-thread stack size in order to run ACE_Log_Msg::log -// TK, 11 Nov 96 -#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +// As 1MB thread-stack size seems to become standard (at least Solaris and +// NT have it), we should raise the minimum stack size to this level for +// avoiding unpleasant surprises when porting ACE software to Digital UNIX. +// Do not define this smaller than 64KB, because ACE_Log_Msg::log needs that! +// TK, 05 Feb 97 +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE (1024 * 1024) #endif /* ACE_CONFIG_H */ diff --git a/ace/config-osf1-4.0.h b/ace/config-osf1-4.0.h index cb01661c20b..612dba99cd6 100644 --- a/ace/config-osf1-4.0.h +++ b/ace/config-osf1-4.0.h @@ -187,7 +187,10 @@ #define ACE_LACKS_T_ERRNO #define ACE_HAS_BROKEN_T_ERRNO #define ACE_HAS_BROKEN_R_ROUTINES -// We need a larger per-thread stack size in order to run ACE_Log_Msg::log -// TK, 11 Nov 96 -#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +// As 1MB thread-stack size seems to become standard (at least Solaris and +// NT have it), we should raise the minimum stack size to this level for +// avoiding unpleasant surprises when porting ACE software to Digital UNIX. +// Do not define this smaller than 64KB, because ACE_Log_Msg::log needs that! +// TK, 05 Feb 97 +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE (1024 * 1024) #endif /* ACE_CONFIG_H */ diff --git a/examples/IOStream/Makefile b/examples/IOStream/Makefile index 699113be687..0e6290736b9 100644 --- a/examples/IOStream/Makefile +++ b/examples/IOStream/Makefile @@ -10,8 +10,8 @@ INFO = README -DIRS = client \ - server +DIRS = # client \ + # server #---------------------------------------------------------------------------- # Include macros and targets diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp index 47bfc830db2..86bdc127cf3 100644 --- a/tests/Naming_Test.cpp +++ b/tests/Naming_Test.cpp @@ -14,7 +14,7 @@ // the local naming context. // // = AUTHOR -// Prashant Jain +// Prashant Jain and Irfan Pyarali // // ============================================================================ @@ -30,14 +30,16 @@ static char type[BUFSIZ]; static void randomize (int array[], int size) { - int i; + size_t i; for (i = 0; i < size; i++) array [i] = i; ACE_OS::srand (ACE_OS::time (0L)); - for (i = 0; i < size; i++, size) + // Generate an array of random numbers from 0 .. size - 1. + + for (i = 0; i < size; i++) { int index = ACE_OS::rand() % size--; int temp = array [index]; @@ -46,10 +48,9 @@ randomize (int array[], int size) } } - static void print_time (ACE_Profile_Timer &timer, - const char *test) + const char *test) { ACE_Profile_Timer::ACE_Elapsed_Time et; timer.stop (); @@ -62,7 +63,6 @@ print_time (ACE_Profile_Timer &timer, (et.real_time / double (ACE_NS_MAX_ENTRIES)) * 1000000)); } - static void test_bind (ACE_Naming_Context &ns_context) { @@ -70,7 +70,7 @@ test_bind (ACE_Naming_Context &ns_context) randomize (array, sizeof array / sizeof (int)); // do the binds - for (int i = 0; i < ACE_NS_MAX_ENTRIES; i++) + for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { sprintf (name, "%s%d", "name", array[i]); ACE_WString w_name (name); @@ -89,13 +89,11 @@ test_find_failure (ACE_Naming_Context &ns_context) sprintf (name, "%s", "foo-bar"); ACE_WString w_name (name); ACE_WString w_value; - char *type = 0; + char *l_type = 0; - // do the finds - for (int i = 0; i < ACE_NS_MAX_ENTRIES; i++) - { - ACE_ASSERT (ns_context.resolve (w_name, w_value, type) == -1); - } + // Do the finds. + for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) + ACE_ASSERT (ns_context.resolve (w_name, w_value, l_type) == -1); } static void @@ -105,12 +103,14 @@ test_rebind (ACE_Naming_Context &ns_context) randomize (array, sizeof array / sizeof (int)); // do the rebinds - for (int i = 0; i < ACE_NS_MAX_ENTRIES; i++) + for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { sprintf (name, "%s%d", "name", array[i]); ACE_WString w_name (name); + sprintf (value, "%s%d", "value", -array[i]); ACE_WString w_value (value); + sprintf (type, "%s%d", "type", -array[i]); ACE_ASSERT (ns_context.rebind (w_name, w_value, type) != -1); } @@ -123,7 +123,7 @@ test_unbind (ACE_Naming_Context &ns_context) randomize (array, sizeof array / sizeof (int)); // do the unbinds - for (int i = 0; i < ACE_NS_MAX_ENTRIES; i++) + for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { sprintf (name, "%s%d", "name", array[i]); ACE_WString w_name (name); @@ -141,7 +141,7 @@ test_find (ACE_Naming_Context &ns_context, int sign, int result) randomize (array, sizeof array / sizeof (int)); // do the finds - for (int i = 0; i < ACE_NS_MAX_ENTRIES; i++) + for (size_t i = 0; i < ACE_NS_MAX_ENTRIES; i++) { if (sign == 1) { @@ -163,25 +163,28 @@ test_find (ACE_Naming_Context &ns_context, int sign, int result) ACE_ASSERT (ns_context.resolve (w_name, w_value, type_out) == result); - char *value = w_value.char_rep (); - if (value) + char *l_value = w_value.char_rep (); + + if (l_value) { ACE_ASSERT (w_value == val); if (ns_context.name_options ()->debug ()) { if (type_out) ACE_DEBUG ((LM_DEBUG, "Name: %s\tValue: %s\tType: %s\n", - name, value, type_out)); + name, l_value, type_out)); else ACE_DEBUG ((LM_DEBUG, "Name: %s\tValue: %s\n", - name, value)); + name, l_value)); } + if (type_out) { ACE_ASSERT (ACE_OS::strcmp (type_out, temp_type) == 0); delete[] type_out; } } + delete[] value; } } |