diff options
-rw-r--r-- | ChangeLog-98b | 35 | ||||
-rw-r--r-- | ace/Malloc_T.i | 3 | ||||
-rw-r--r-- | ace/OS.h | 4 | ||||
-rw-r--r-- | ace/OS.i | 7 | ||||
-rw-r--r-- | ace/README | 2 | ||||
-rw-r--r-- | ace/SOCK_Dgram_Bcast.cpp | 67 | ||||
-rw-r--r-- | ace/Typed_SV_Message_Queue.i | 16 | ||||
-rw-r--r-- | ace/config-hpux11.h | 3 | ||||
-rw-r--r-- | examples/Threads/thread_specific.cpp | 149 |
9 files changed, 214 insertions, 72 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index f66940462e6..f5637a542f6 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,5 +1,40 @@ Fri Jul 24 23:14:09 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * examples/Threads/thread_specific.cpp (cleanup): Added an + ACE_reinterpret_cast(). Thanks to John Mulhern + <9107@mn3.lawson.lawson.com> for this. + + * ace/Typed_SV_Message_Queue.i: Added some necessary + ACE_reinterpret_cast()s. Thanks to John Mulhern + <9107@mn3.lawson.lawson.com> for this. + + * ace/Malloc_T.i (addr): Changed (T *) cast to + ACE_reinterpret_cast(). Thanks to John Mulhern + <9107@mn3.lawson.lawson.com> for this. + + * ace/SOCK_Dgram_Bcast.cpp: Added an ACE_reinterpret_cast() macro + to make the HP/UX 11 C++ compiler happy. Thanks to John Mulhern + <9107@mn3.lawson.lawson.com> for this. + + * ace/config-hpux11.h: Added ACE_HAS_BROKEN_XTI_MACROS and + ACE_HAS_SIGISMEMBER_BUG. + + * ace/OS.i (sigismember): Sigismember works correctly in most + respects but the Sigset_Ops_Test tests the sigismember function + with an out-of-range signal number expecting it to fail with a + minus one result. On HPUX 11.0 it doesn't fail; it correctly + reports that the signal is not in the sigset. This happens + because HP, bless their hearts, thought that it should only + return out of range when the signal value was greater than the + capacity of the sigset; if ACE_NSIG is forced to 257 then the + test works as expected. But the real maximum signal is 45. + Added a fix for this courtesy of John Mulhern + <9107@mn3.lawson.lawson.com>. + + * ace/OS.h: Added a workaround for broken XTI header files on + HP/UX. Thanks to John Mulhern <9107@mn3.lawson.lawson.com> for + reporting this. + * tests/Dynamic_Priority_Test.cpp: Reformatted this just a bit. Fri Jul 24 21:42:39 1998 David L. Levine <levine@cs.wustl.edu> diff --git a/ace/Malloc_T.i b/ace/Malloc_T.i index e3a7add47d0..defbafe0948 100644 --- a/ace/Malloc_T.i +++ b/ace/Malloc_T.i @@ -6,7 +6,8 @@ template <class T> ACE_INLINE T * ACE_Cached_Mem_Pool_Node<T>::addr (void) { - return (T *) this; + return ACE_reinterpret_cast (T *, + this); } template <class T> ACE_INLINE ACE_Cached_Mem_Pool_Node<T> * @@ -3200,6 +3200,10 @@ extern "C" { # if defined (ACE_HAS_TIUSER_H) # include /**/ <tiuser.h> # else +# if defined (ACE_HAS_BROKEN_XTI_MACROS) +# undef TCP_NODELAY +# undef TCP_MAXSEG +# endif /* ACE_HAS_BROKEN_XTI_MACROS */ # include /**/ <xti.h> # endif /* ACE_HAS_TIUSER_H */ # if defined (ACE_HAS_TIUSER_H_BROKEN_EXTERN_C) @@ -9566,6 +9566,13 @@ ACE_INLINE int ACE_OS::sigismember (sigset_t *s, int signum) { #if !defined (ACE_LACKS_SIGSET) +#if defined (ACE_HAS_SIGISMEMBER_BUG) + if (signum < 1 || signum >= ACE_NSIG) + { + errno = EINVAL ; + return -1 ; // Invalid signum, return error + } +#endif /* ACE_HAS_SIGISMEMBER_BUG */ ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1); #else if (s == NULL) { diff --git a/ace/README b/ace/README index 1af2e049c46..c54f6dee817 100644 --- a/ace/README +++ b/ace/README @@ -63,6 +63,7 @@ ACE_HAS_BROKEN_SENDMSG OS/compiler omits the const from the sen ACE_HAS_BROKEN_SETRLIMIT OS/compiler omits the const from the rlimit parameter in the setrlimit() prototype. ACE_HAS_BROKEN_TIMESPEC_MEMBERS platform define struct timespec members as ts_sec and ts_nsec instead of tv_sec and tv_nsec. This is highly non-portable. Currently only FreeBSD 2.1.x uses it. ACE_HAS_BROKEN_WRITEV OS/compiler omits the const from the iovec parameter in the writev() prototype. +ACE_HAS_BROKEN_XTI_MACROS OS header files have some problems with XTI (HP/UX 11). ACE_HAS_BSTRING Platform has <bstring.h> (which contains bzero() prototype) ACE_HAS_BYTESEX_H Platform has <bytesex.h>. ACE_HAS_CANCEL_IO Platform supports the Win32 CancelIO() function (WinNT 4.0 and beyond). @@ -152,6 +153,7 @@ ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL For Win32: Use Select_Reactor as default ACE_HAS_SEMUN Compiler/platform defines a union semun for SysV shared memory ACE_HAS_SET_T_ERRNO Platform has a function to set t_errno (e.g., Tandem). ACE_HAS_SIGINFO_T Platform supports SVR4 extended signals +ACE_HAS_SIGISMEMBER_BUG Platform has bug with sigismember() (HP/UX 11). ACE_HAS_SIG_MACROS Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and FreeBSD) ACE_HAS_SIGNAL_OBJECT_AND_WAIT Platform supports the Win32 SignalObjectAndWait() function (WinNT 4.0 and beyond). ACE_HAS_SIGNAL_SAFE_OS_CALLS Automatically restart OS system calls when EINTR occurs diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp index 72042852b80..f5648c9e31c 100644 --- a/ace/SOCK_Dgram_Bcast.cpp +++ b/ace/SOCK_Dgram_Bcast.cpp @@ -37,6 +37,7 @@ ACE_SOCK_Dgram_Bcast::close (void) ACE_Bcast_Node *temp = this->if_list_; // Release the dynamically allocated memory. + while (temp != 0) { ACE_Bcast_Node *hold = temp->next_; @@ -70,7 +71,9 @@ ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (const ACE_Addr &local, ACE_TRACE ("ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast"); if (this->mk_broadcast (host_name) == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_SOCK_Dgram_Bcast"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_SOCK_Dgram_Bcast"))); } // Here's the general-purpose open routine. @@ -83,6 +86,7 @@ ACE_SOCK_Dgram_Bcast::open (const ACE_Addr &local, const ASYS_TCHAR *host_name) { ACE_TRACE ("ACE_SOCK_Dgram_Bcast::open"); + if (this->ACE_SOCK_Dgram::open (local, protocol_family, protocol, reuse_addr) == -1) return -1; @@ -99,11 +103,14 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ASYS_TCHAR *host_name) int one = 1; - if (ACE_OS::setsockopt (this->get_handle (), SOL_SOCKET, SO_BROADCAST, - (char *) &one, sizeof one) == -1) + if (ACE_OS::setsockopt (this->get_handle (), + SOL_SOCKET, + SO_BROADCAST, + (char *) &one, + sizeof one) == -1) return -1; -#if !defined(ACE_WIN32) +#if !defined (ACE_WIN32) ACE_HANDLE s = this->get_handle (); char buf[BUFSIZ]; @@ -114,7 +121,9 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ASYS_TCHAR *host_name) // Get interface structure and initialize the addresses using UNIX // techniques. - if (ACE_OS::ioctl (s, SIOCGIFCONF, (char *) &ifc) == -1) + if (ACE_OS::ioctl (s, + SIOCGIFCONF, + (char *) &ifc) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface configuration)"), ACE_INVALID_HANDLE); @@ -143,7 +152,9 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ASYS_TCHAR *host_name) { struct sockaddr_in if_addr; - ACE_OS::memcpy (&if_addr, &ifr->ifr_addr, sizeof if_addr); + ACE_OS::memcpy (&if_addr, + &ifr->ifr_addr, + sizeof if_addr); if (host_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) continue; @@ -159,33 +170,44 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ASYS_TCHAR *host_name) struct ifreq flags = *ifr; struct ifreq if_req = *ifr; - if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) + if (ACE_OS::ioctl (s, + SIOCGIFFLAGS, + (char *) &flags) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface flags)")); continue; } - if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_UP) == 0) + if (ACE_BIT_ENABLED (flags.ifr_flags, + IFF_UP) == 0) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: Network interface is not up")); continue; } - if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) + if (ACE_BIT_ENABLED (flags.ifr_flags, + IFF_LOOPBACK)) continue; - if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) + if (ACE_BIT_ENABLED (flags.ifr_flags, + IFF_BROADCAST)) { - if (ACE_OS::ioctl (s, SIOCGIFBRDADDR, (char *) &if_req) == -1) + if (ACE_OS::ioctl (s, + SIOCGIFBRDADDR, + (char *) &if_req) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get broadaddr)")); else { - ACE_INET_Addr addr ((sockaddr_in *) &if_req.ifr_broadaddr, - sizeof if_req.ifr_broadaddr); - ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); + ACE_INET_Addr addr (ACE_reinterpret_cast (sockaddr_in *, + &if_req.ifr_broadaddr), + sizeof if_req.ifr_broadaddr); + ACE_NEW_RETURN (this->if_list_, + ACE_Bcast_Node (addr, + this->if_list_), + -1); } } else @@ -195,8 +217,12 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ASYS_TCHAR *host_name) #else ACE_UNUSED_ARG (host_name); - ACE_INET_Addr addr (u_short (0), ACE_UINT32 (INADDR_BROADCAST)); - ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); + ACE_INET_Addr addr (u_short (0), + ACE_UINT32 (INADDR_BROADCAST)); + ACE_NEW_RETURN (this->if_list_, + ACE_Bcast_Node (addr, + this->if_list_), + -1); #endif /* !ACE_WIN32 */ return this->if_list_ == 0 ? -1 : 0; } @@ -254,8 +280,13 @@ ACE_SOCK_Dgram_Bcast::send (const iovec iov[], // Send the message to every interface. - for (ACE_Bcast_Node *temp = this->if_list_; temp != 0; temp++) - if (ACE_SOCK_Dgram::send (iov, n, temp->bcast_addr_, flags) == -1) + for (ACE_Bcast_Node *temp = this->if_list_; + temp != 0; + temp++) + if (ACE_SOCK_Dgram::send (iov, + n, + temp->bcast_addr_, + flags) == -1) return -1; return 0; diff --git a/ace/Typed_SV_Message_Queue.i b/ace/Typed_SV_Message_Queue.i index 9c38d6622b5..92052715ab5 100644 --- a/ace/Typed_SV_Message_Queue.i +++ b/ace/Typed_SV_Message_Queue.i @@ -14,7 +14,7 @@ ACE_Typed_SV_Message_Queue<T>::open (key_t external_id, return this->message_queue_.open (external_id, create, perms); } -/* What does it mean to close a message queue?! */ +// What does it mean to close a message queue?! template <class T> ACE_INLINE int ACE_Typed_SV_Message_Queue<T>::close (void) @@ -28,9 +28,12 @@ ACE_Typed_SV_Message_Queue<T>::recv (ACE_Typed_SV_Message<T> &mb, int mflags) { ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::recv"); - int length = this->message_queue_.recv ((ACE_SV_Message &) mb, - mb.max_size (), mb.type (), mflags); + int length = this->message_queue_.recv (ACE_reinterpret_cast (ACE_SV_Message &, + mb), + mb.max_size (), + mb.type (), + mflags); if (length != -1) mb.length (length); @@ -42,14 +45,16 @@ ACE_Typed_SV_Message_Queue<T>::send (const ACE_Typed_SV_Message<T> &mb, int mflags) { ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::send"); - return this->message_queue_.send ((ACE_SV_Message &) mb, - mb.length (), mflags); + return this->message_queue_.send ((ACE_SV_Message &) mb), + mb.length (), + mflags); } template <class T> ACE_INLINE int ACE_Typed_SV_Message_Queue<T>::remove (void) { ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::remove"); + return this->message_queue_.remove (); } @@ -58,5 +63,6 @@ ACE_Typed_SV_Message_Queue<T>::control (int option, void *arg) { ACE_TRACE ("ACE_Typed_SV_Message_Queue<T>::control"); + return this->message_queue_.control (option, arg); } diff --git a/ace/config-hpux11.h b/ace/config-hpux11.h index 206c33d977d..44cc0ef8b83 100644 --- a/ace/config-hpux11.h +++ b/ace/config-hpux11.h @@ -216,4 +216,7 @@ #define ACE_NTRACE 1 #endif /* ACE_NTRACE */ +#define ACE_HAS_SIGISMEMBER_BUG +#define ACE_HAS_BROKEN_XTI_MACROS + #define ACE_HAS_UALARM diff --git a/examples/Threads/thread_specific.cpp b/examples/Threads/thread_specific.cpp index a99a045b1b7..cc99a535937 100644 --- a/examples/Threads/thread_specific.cpp +++ b/examples/Threads/thread_specific.cpp @@ -27,9 +27,11 @@ typedef ACE_Guard<ACE_Null_Mutex> GUARD; extern "C" void cleanup (void *ptr) { - ACE_DEBUG ((LM_DEBUG, "(%t) in cleanup, ptr = %x\n", ptr)); + ACE_DEBUG ((LM_DEBUG, + "(%t) in cleanup, ptr = %x\n", + ptr)); - delete ptr; + delete ACE_reinterpret_cast (char *, ptr); } // This worker function is the entry point for each thread. @@ -37,8 +39,8 @@ cleanup (void *ptr) static void * worker (void *c) { - // Cast the arg to a long, first, because a pointer is the same - // size as a long on all current ACE platforms. + // Cast the arg to a long, first, because a pointer is the same size + // as a long on all current ACE platforms. int count = (int) (long) c; ACE_thread_key_t key = ACE_OS::NULL_key; @@ -47,36 +49,62 @@ worker (void *c) // Make one key that will be available when the thread exits so that // we'll have something to cleanup! - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); + if (ACE_OS::thr_keycreate (&key, + cleanup) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_keycreate")); - ACE_NEW_RETURN (ip, int, 0); + ACE_NEW_RETURN (ip, + int, + 0); - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); + if (ACE_OS::thr_setspecific (key, + (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); for (int i = 0; i < count; i++) { - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); - - ACE_NEW_RETURN (ip, int, 0); - - ACE_DEBUG ((LM_DEBUG, "(%t) in worker 1, key = %d, ip = %x\n", key, ip)); - - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - + if (ACE_OS::thr_keycreate (&key, + cleanup) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_keycreate")); + + ACE_NEW_RETURN (ip, + int, + 0); + + ACE_DEBUG ((LM_DEBUG, + "(%t) in worker 1, key = %d, ip = %x\n", + key, + ip)); + + if (ACE_OS::thr_setspecific (key, + (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_getspecific (key, + (void **) &ip) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_setspecific (key, + (void *) 0) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); delete ip; if (ACE_OS::thr_keyfree (key) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_keyfree")); // Cause an error. ACE_OS::read (ACE_INVALID_HANDLE, 0, 0); @@ -97,41 +125,63 @@ worker (void *c) ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, printf_lock, 0); ACE_OS::printf ("(%u) errno = %d, lineno = %d, flags = %d\n", - handle, tss_error->error (), tss_error->line (), - tss_error->flags () ); + handle, + tss_error->error (), + tss_error->line (), + tss_error->flags ()); } key = ACE_OS::NULL_key; - if (ACE_OS::thr_keycreate (&key, cleanup) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate")); - - ACE_NEW_RETURN (ip, int, 0); - - ACE_DEBUG ((LM_DEBUG, "(%t) in worker 2, key = %d, ip = %x\n", key, ip)); - - if (ACE_OS::thr_setspecific (key, (void *) ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_getspecific (key, (void **) &ip) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - - if (ACE_OS::thr_setspecific (key, (void *) 0) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific")); - + if (ACE_OS::thr_keycreate (&key, + cleanup) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_keycreate")); + + ACE_NEW_RETURN (ip, + int, + 0); + + ACE_DEBUG ((LM_DEBUG, + "(%t) in worker 2, key = %d, ip = %x\n", + key, + ip)); + + if (ACE_OS::thr_setspecific (key, + (void *) ip) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_getspecific (key, + (void **) &ip) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); + + if (ACE_OS::thr_setspecific (key, + (void *) 0) == -1) + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_setspecific")); delete ip; if (ACE_OS::thr_keyfree (key) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keyfree")); + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "ACE_OS::thr_keyfree")); } - ACE_DEBUG ((LM_DEBUG, "(%t) exiting\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) exiting\n")); return 0; } extern "C" void handler (int signum) { - ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); + ACE_DEBUG ((LM_DEBUG, + "signal = %S\n", signum)); ACE_Thread_Manager::instance ()->exit (0); } @@ -153,7 +203,10 @@ main (int argc, char *argv[]) ACE_THR_FUNC (&worker), (void *) count, THR_BOUND | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Thread_Manager::spawn_n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "ACE_Thread_Manager::spawn_n"), + -1); ACE_Thread_Manager::instance ()->wait (); #else |