From bcdbb84f6e916d82dae91dcab38ffc01389d1dc4 Mon Sep 17 00:00:00 2001 From: schmidt Date: Sat, 30 Aug 1997 21:43:06 +0000 Subject: *** empty log message *** --- ace/ACE.h | 3 +++ ace/ACE.i | 10 ++++++++++ ace/Handle_Set.cpp | 13 ++++++++++--- ace/Handle_Set.h | 3 ++- ace/Handle_Set.i | 6 +++++- ace/Log_Msg.cpp | 4 +++- ace/Log_Priority.h | 2 +- ace/Log_Record.cpp | 14 ++++++++++++++ ace/Log_Record.h | 10 ++++++++++ ace/OS.cpp | 15 ++++----------- ace/OS.h | 2 +- ace/README | 1 + ace/Signal.cpp | 25 ++++++++++++++++++++++--- ace/Signal.h | 5 +++++ ace/Signal.i | 10 +++++++++- ace/Timer_Queue_T.cpp | 3 +-- ace/config-sco-5.0.0-fsu-pthread.h | 2 +- ace/config-sco-5.0.0-mit-pthread.h | 1 + ace/config-sco-5.0.0-nothread.h | 2 ++ 19 files changed, 105 insertions(+), 26 deletions(-) (limited to 'ace') diff --git a/ace/ACE.h b/ace/ACE.h index 33059209543..dfacd105a67 100644 --- a/ace/ACE.h +++ b/ace/ACE.h @@ -500,6 +500,9 @@ public: // the same process. The uniqueness of this name is therefore only // valid for the life of . + static u_long log2 (u_long num); + // Computes the base 2 logarithm of . + private: ACE (void); // Ensure we can't define an instance of this class... diff --git a/ace/ACE.i b/ace/ACE.i index 8d00aed2d7c..d6d3398a053 100644 --- a/ace/ACE.i +++ b/ace/ACE.i @@ -65,3 +65,13 @@ ACE::get_flags (ACE_HANDLE handle) return ACE_OS::fcntl (handle, F_GETFL, 0); } +inline u_long +ACE::log2 (u_long num) +{ + for (u_long log = 0; + num > 0; + log++) + num >>= 1; + + return log; +} diff --git a/ace/Handle_Set.cpp b/ace/Handle_Set.cpp index ce5ce1af3fa..b0000cce45f 100644 --- a/ace/Handle_Set.cpp +++ b/ace/Handle_Set.cpp @@ -80,8 +80,8 @@ ACE_Handle_Set::ACE_Handle_Set (const ACE_FD_SET_TYPE &fd_mask) // speed up the count. #if defined (ACE_HAS_LONG_FDMASK) -// If there are platforms where fd_mask isn't typedef'd to "int" we'll -// have to use the following code. +// If there are platforms where fd_mask isn't typedef'd to a 4 byte +// quantify we'll have to use the following code. int ACE_Handle_Set::count_bits (u_long n) const @@ -89,16 +89,23 @@ ACE_Handle_Set::count_bits (u_long n) const ACE_TRACE ("ACE_Handle_Set::count_bits"); int rval = 0; - for (int i = 0; n != 0; i++) + while (n > 0) { +#if defined (ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT) + rval++; + n &= n - 1; +#else rval += ACE_Handle_Set::nbits_[n & 0xff]; n >>= 8; +#endif /* ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT */ } return rval; } #else +// Otherwise we can use the following. + int ACE_Handle_Set::count_bits (u_long n) const { diff --git a/ace/Handle_Set.h b/ace/Handle_Set.h index b62cc4ca216..1024ba863c4 100644 --- a/ace/Handle_Set.h +++ b/ace/Handle_Set.h @@ -61,7 +61,8 @@ public: // Synchronize the underlying FD_SET with the MAX_FD and the SIZE. operator fd_set *(); - // Returns a pointer to the underlying fd_set. + // Returns a pointer to the underlying . Returns 0 if + // == 0. void dump (void) const; // Dump the state of an object. diff --git a/ace/Handle_Set.i b/ace/Handle_Set.i index 839e567ad2a..ef4de0115a8 100644 --- a/ace/Handle_Set.i +++ b/ace/Handle_Set.i @@ -90,7 +90,11 @@ ACE_INLINE ACE_Handle_Set::operator fd_set *() { ACE_TRACE ("ACE_Handle_Set::operator ACE_FD_SET_TYPE *"); - return (fd_set *) &this->mask_; + + if (this->size_ > 0) + return (fd_set*) &this->mask_; + else + return (fd_set*) NULL; } ACE_INLINE ACE_HANDLE diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index d456063cb73..50f1d89a479 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -932,7 +932,9 @@ ACE_Log_Msg::log (const char *format_str, ACE_Str_Buf log_msg ((void *) &log_record, int (log_record.length ())); #if defined (ACE_HAS_STREAM_PIPES) - result = message_queue_.send (int (log_record.type ()), + // Try to use the putpmsg() API if possible in order to + // ensure correct message queueing according to priority. + result = message_queue_.send (int (log_record.priority ()), &log_msg); #elif !defined (ACE_WIN32) result = message_queue_.send (log_msg); diff --git a/ace/Log_Priority.h b/ace/Log_Priority.h index 3f7e96a0211..dc05f6df1b3 100644 --- a/ace/Log_Priority.h +++ b/ace/Log_Priority.h @@ -24,7 +24,7 @@ enum ACE_Log_Priority // // = DESCRIPTION // These values are defined using powers of two so that it's - // possible to form a mask to turn the on or off dynamically. + // possible to form a mask to turn them on or off dynamically. { // = Note, this first argument *must* start at 1! diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp index bab66d2c50f..f6f4fea8794 100644 --- a/ace/Log_Record.cpp +++ b/ace/Log_Record.cpp @@ -12,6 +12,20 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Log_Record) +u_long +ACE_Log_Record::priority (void) const +{ + ACE_TRACE ("ACE_Log_Record::priority"); + return ACE::log2 (this->type_); +} + +void +ACE_Log_Record::priority (u_long p) +{ + ACE_TRACE ("ACE_Log_Record::priority"); + this->type_ = ACE::log2 (p); +} + void ACE_Log_Record::dump (void) const { diff --git a/ace/Log_Record.h b/ace/Log_Record.h index bc3844c48d4..ff9dc122d41 100644 --- a/ace/Log_Record.h +++ b/ace/Log_Record.h @@ -86,6 +86,16 @@ public: void type (long); // Set the type of the . + u_long priority (void) const; + // Get the priority of the . This is computed + // as the base 2 logarithm of (which must be a power of 2, + // as defined by the enums in ). + + void priority (u_long num); + // Set the priority of the (which must be a + // power of 2, as defined by the enums in ). This + // is stored as the base 2 logarithm of . + long length (void) const; // Get the length of the . diff --git a/ace/OS.cpp b/ace/OS.cpp index d5bb7ed9f3c..cce112dbf39 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -86,17 +86,10 @@ void ACE_Time_Value::dump (void) const { // ACE_TRACE ("ACE_Time_Value::dump"); -#if 0 - if (tv.usec () < 0 || tv.sec () < 0) - stream << "-"; - - stream << dec << abs (int (tv.sec ())) << "." -// << setw (6) << setfill ('0') - << dec << abs (int (tv.usec ())); -// I assume - inline int abs(int d) { return (d>0)?d:-d; } - is defined somewhere */ -#endif /* 0 */ + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "\ntv_sec_ = %d", this->tv_.tv_sec)); + ACE_DEBUG ((LM_DEBUG, "\ntv_usec_ = %d\n", this->tv_.tv_usec)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } void diff --git a/ace/OS.h b/ace/OS.h index d2c237aa3e8..209710a4332 100644 --- a/ace/OS.h +++ b/ace/OS.h @@ -303,7 +303,7 @@ private: // enabled or disabled. // Efficiently returns the least power of two >= X... -#define ACE_POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) +#define ACE_POW(X) (((X) == 0)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) #define ACE_EVEN(NUM) (((NUM) & 1) == 0) #define ACE_ODD(NUM) (((NUM) & 1) == 1) #define ACE_BIT_ENABLED(WORD, BIT) (((WORD) & (BIT)) != 0) diff --git a/ace/README b/ace/README index 06c9d8900a4..0fd5373f972 100644 --- a/ace/README +++ b/ace/README @@ -65,6 +65,7 @@ ACE_HAS_EXCEPTIONS Compiler supports C++ exception handling ACE_HAS_GETPAGESIZE Platform supports getpagesize() call (otherwise, ACE_PAGE_SIZE must be defined, except on Win32) ACE_HAS_GETRUSAGE Platform supports the getrusage() system call. ACE_HAS_GNU_CSTRING_H Denotes that GNU has cstring.h as standard which redefines memchr() +ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT Optimize ACE_Handle_Set::count_bits for select() operations (common case) ACE_HAS_HI_RES_TIMER Compiler/platform supports SunOS high resolution timers ACE_HAS_INLINED_OSCALLS Inline all the static class OS methods to remove call overhead ACE_HAS_IP_MULTICAST Platform supports IP multicast diff --git a/ace/Signal.cpp b/ace/Signal.cpp index 6b4d69a7af5..34235a124e0 100644 --- a/ace/Signal.cpp +++ b/ace/Signal.cpp @@ -145,6 +145,25 @@ ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, ACE_OS::sigaction (signum, &this->sa_, 0); } +ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, + int signum, + ACE_Sig_Set &sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + // Structure assignment... + this->sa_.sa_mask = sig_mask.sigset (); + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ + ACE_OS::sigaction (signum, &this->sa_, 0); +} + ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Handler) void @@ -246,7 +265,7 @@ ACE_Sig_Handler::remove_handler (int signum, if (ACE_Sig_Handler::in_range (signum)) { - ACE_Sig_Action sa (SIG_DFL, 0, -1); // Define the default disposition. + ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); // Define the default disposition. if (new_disp == 0) new_disp = &sa; @@ -284,7 +303,7 @@ ACE_Sig_Handler::dispatch (int signum, if (eh != 0 && eh->handle_signal (signum, siginfo, ucontext) == -1) { // Define the default disposition. - ACE_Sig_Action sa (SIG_DFL, 0, -1); + ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); ACE_Sig_Handler::signal_handlers_[signum] = 0; @@ -586,7 +605,7 @@ ACE_Sig_Handlers::remove_handler (int signum, // register the new disposition or restore the default // disposition. - ACE_Sig_Action sa (SIG_DFL, 0, -1); + ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); if (new_disp == 0) new_disp = &sa; diff --git a/ace/Signal.h b/ace/Signal.h index 164fbd4c39a..7c851869eea 100644 --- a/ace/Signal.h +++ b/ace/Signal.h @@ -87,6 +87,10 @@ public: int signum, sigset_t *sigmask = 0, int flags = 0); + ACE_Sig_Action (ACE_SignalHandler handler, + int signum, + ACE_Sig_Set &sigmask, + int flags = 0); ACE_Sig_Action (const ACE_Sig_Action &s); ACE_Sig_Action (struct sigaction *); @@ -113,6 +117,7 @@ public: // = Set/get current signal mask. void mask (sigset_t *); + void mask (ACE_Sig_Set &); sigset_t *mask (void); // = Set/get current signal handler (pointer to function). diff --git a/ace/Signal.i b/ace/Signal.i index 2dbcf710238..b14818db0ff 100644 --- a/ace/Signal.i +++ b/ace/Signal.i @@ -101,7 +101,15 @@ ACE_INLINE void ACE_Sig_Action::mask (sigset_t *ss) { ACE_TRACE ("ACE_Sig_Action::mask"); - this->sa_.sa_mask = *ss; // Structure assignment + if (ss != 0) + this->sa_.sa_mask = *ss; // Structure assignment +} + +ACE_INLINE void +ACE_Sig_Action::mask (ACE_Sig_Set &ss) +{ + ACE_TRACE ("ACE_Sig_Action::mask"); + this->sa_.sa_mask = ss.sigset (); // Structure assignment } ACE_INLINE ACE_SignalHandler diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 1d52d885ace..06d5a3c75f8 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -16,13 +16,12 @@ ACE_Timer_Node_T::dump (void) const { ACE_TRACE ("ACE_Timer_Node_T::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - // ACE_DEBUG ((LM_DEBUG, "\type_ = %x", this->type_)); ACE_DEBUG ((LM_DEBUG, "\nact_ = %x", this->act_)); this->timer_value_.dump (); this->interval_.dump (); ACE_DEBUG ((LM_DEBUG, "\nprev_ = %x", this->prev_)); ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); - ACE_DEBUG ((LM_DEBUG, "\ntimer_id_ = %d", this->timer_id_)); + ACE_DEBUG ((LM_DEBUG, "\ntimer_id_ = %d\n", this->timer_id_)); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } diff --git a/ace/config-sco-5.0.0-fsu-pthread.h b/ace/config-sco-5.0.0-fsu-pthread.h index 821bb9adb2f..b619e407d3c 100644 --- a/ace/config-sco-5.0.0-fsu-pthread.h +++ b/ace/config-sco-5.0.0-fsu-pthread.h @@ -21,7 +21,7 @@ #define ACE_TEMPLATES_REQUIRE_SOURCE #define ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION #define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES - +#define ACE_HAS_LONG_FDMASK #define ACE_LACKS_SYSCALL #define ACE_LACKS_STRRECVFD #define ACE_NEEDS_FTRUNCATE diff --git a/ace/config-sco-5.0.0-mit-pthread.h b/ace/config-sco-5.0.0-mit-pthread.h index 6ffb3cbcc7a..281bff9ab9a 100644 --- a/ace/config-sco-5.0.0-mit-pthread.h +++ b/ace/config-sco-5.0.0-mit-pthread.h @@ -22,6 +22,7 @@ #define ACE_LACKS_PWD_FUNCTIONS #define ACE_TEMPLATES_REQUIRE_SOURCE +#define ACE_HAS_LONG_FDMASK #define ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION #define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES diff --git a/ace/config-sco-5.0.0-nothread.h b/ace/config-sco-5.0.0-nothread.h index c4f40dd9ed4..2b6c38336d5 100644 --- a/ace/config-sco-5.0.0-nothread.h +++ b/ace/config-sco-5.0.0-nothread.h @@ -49,6 +49,8 @@ // Platform supports System V IPC (most versions of UNIX, but not Win32) #define ACE_HAS_SYSV_IPC +#define ACE_HAS_LONG_FDMASK + // Platform supports recvmsg and sendmsg. #define ACE_HAS_MSG -- cgit v1.2.1