summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ace/OS.h9
-rw-r--r--ace/OS.i76
-rw-r--r--ace/README6
-rw-r--r--ace/Thread.h2
-rw-r--r--ace/Timer_List_T.cpp10
-rw-r--r--ace/config-irix6.x-sgic++-nothreads.h1
-rw-r--r--ace/config-irix6.x-sgic++.h1
-rw-r--r--ace/config-linux-lxpthreads.h4
-rw-r--r--ace/config-sco-5.0.0-fsu-pthread.h2
-rw-r--r--ace/config-sco-5.0.0-mit-pthread.h2
-rw-r--r--ace/config-sunos4-sun3.x.h2
-rw-r--r--ace/config-sunos4-sun4.1.4.h2
-rw-r--r--ace/config-sunos4-sun4.x.h2
-rw-r--r--ace/config-sunos5.4-centerline-2.x.h2
-rw-r--r--ace/config-sunos5.4-g++.h2
-rw-r--r--ace/config-sunos5.4-sunc++-4.x-orbix.h2
-rw-r--r--ace/config-sunos5.4-sunc++-4.x.h2
-rw-r--r--ace/config-sunos5.5-g++.h2
-rw-r--r--ace/config-sunos5.5-sunc++-4.x.h2
-rw-r--r--ace/config-tandem.h4
-rw-r--r--tests/Async_Timer_Queue_Test.cpp206
21 files changed, 256 insertions, 85 deletions
diff --git a/ace/OS.h b/ace/OS.h
index a89ae3c23b4..baad4c5062b 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -943,6 +943,10 @@ struct sembuf
void herror (const char *str);
#endif /* ACE_HAS_H_ERRNO */
+#if defined (ACE_LACKS_UALARM_PROTOTYPE)
+extern "C" u_int ualarm (u_int usecs, u_int interval);
+#endif /* ACE_LACKS_UALARM_PROTOTYPE */
+
#if defined (ACE_LACKS_MSGBUF_T)
struct msgbuf {};
#endif /* ACE_LACKS_MSGBUF_T */
@@ -3123,7 +3127,10 @@ public:
// = A set of wrappers for timers and resource stats.
static u_int alarm (u_int secs);
- static u_int ualarm (u_int usecs, u_int interval);
+ static u_int ualarm (u_int usecs,
+ u_int interval = 0);
+ static u_int ualarm (const ACE_Time_Value &tv,
+ const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
static ACE_hrtime_t gethrtime (void);
#if defined (ACE_HAS_POWERPC) && defined (ghs)
static void readPPCTimeBase (u_long &most,
diff --git a/ace/OS.i b/ace/OS.i
index 7d9e5ef61bf..9318b1b575d 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -6,10 +6,10 @@
#define ACE_INLINE
#endif /* ACE_HAS_INLINED_OSCALLS */
-#if defined (ACE_LACKS_RLIMIT_PROTO)
+#if defined (ACE_LACKS_RLIMIT_PROTOTYPE)
int getrlimit (int resource, struct rlimit *rlp);
int setrlimit (int resource, const struct rlimit *rlp);
-#endif /* ACE_LACKS_RLIMIT_PROTO */
+#endif /* ACE_LACKS_RLIMIT_PROTOTYPE */
#if !defined (ACE_HAS_STRERROR)
#if defined (ACE_HAS_SYS_ERRLIST)
@@ -544,11 +544,11 @@ ACE_OS::getopt (int argc, char *const *argv, const char *optstring)
ACE_UNUSED_ARG (argv);
ACE_UNUSED_ARG (optstring);
ACE_NOTSUP_RETURN (-1);
-#elif defined (ACE_LACKS_POSIX_PROTO)
+#elif defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::getopt (argc, (const char* const *) argv, optstring), int, -1);
#else
ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
}
ACE_INLINE uid_t
@@ -3651,11 +3651,11 @@ ACE_OS::sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
{
// ACE_TRACE ("ACE_OS::sendmsg");
#if !defined (ACE_LACKS_SENDMSG)
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::sendmsg (handle, (struct msghdr *) msg, flags), int, -1);
#else
ACE_OSCALL_RETURN (::sendmsg (handle, (ACE_SENDMSG_TYPE *) msg, flags), int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#else
ACE_UNUSED_ARG (flags);
ACE_UNUSED_ARG (msg);
@@ -3697,22 +3697,22 @@ ACE_INLINE size_t
ACE_OS::fread (void *ptr, size_t size, size_t nelems, FILE *fp)
{
// ACE_TRACE ("ACE_OS::fread");
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::fread ((char *) ptr, size, nelems, fp), int, 0);
#else
ACE_OSCALL_RETURN (::fread (ptr, size, nelems, fp), int, 0);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
}
ACE_INLINE size_t
ACE_OS::fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
{
// ACE_TRACE ("ACE_OS::fwrite");
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::fwrite ((const char *) ptr, size, nitems, fp), int, 0);
#else
ACE_OSCALL_RETURN (::fwrite (ptr, size, nitems, fp), int, 0);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
}
// Accessors to PWD file.
@@ -5371,13 +5371,13 @@ ACE_OS::msgrcv (int int_id, void *buf, size_t len,
{
// ACE_TRACE ("ACE_OS::msgrcv");
#if defined (ACE_HAS_SYSV_IPC)
-#if defined (ACE_LACKS_POSIX_PROTO) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
ACE_OSCALL_RETURN (::msgrcv (int_id, (msgbuf *) buf, len, type, flags),
int, -1);
#else
ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags),
int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#else
ACE_UNUSED_ARG (int_id);
ACE_UNUSED_ARG (buf);
@@ -5394,11 +5394,11 @@ ACE_OS::msgsnd (int int_id, const void *buf, size_t len, int flags)
{
// ACE_TRACE ("ACE_OS::msgsnd");
#if defined (ACE_HAS_SYSV_IPC)
-#if defined (ACE_LACKS_POSIX_PROTO) || defined (ACE_HAS_NONCONST_MSGSND) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_HAS_NONCONST_MSGSND) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
ACE_OSCALL_RETURN (::msgsnd (int_id, (msgbuf *) buf, len, flags), int, -1);
#else
ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO || ACE_HAS_NONCONST_MSGSND */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES || ACE_HAS_NONCONST_MSGSND */
#else
ACE_UNUSED_ARG (int_id);
ACE_UNUSED_ARG (buf);
@@ -5438,6 +5438,24 @@ ACE_OS::ualarm (u_int usecs, u_int interval)
#endif /* ACE_HAS_UALARM */
}
+ACE_INLINE u_int
+ACE_OS::ualarm (const ACE_Time_Value &tv,
+ const ACE_Time_Value &tv_interval)
+{
+ // ACE_TRACE ("ACE_OS::ualarm");
+
+#if defined (ACE_HAS_UALARM)
+ u_int usecs = (tv.sec () * 1000000) + tv.usec ();
+ u_int interval = (tv_interval.sec () * 1000000) + tv_interval.usec ();
+ return ::ualarm (usecs, interval);
+#else
+ ACE_UNUSED_ARG (tv);
+ ACE_UNUSED_ARG (tv_interval);
+
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_HAS_UALARM */
+}
+
ACE_INLINE int
ACE_OS::dlclose (ACE_SHLIB_HANDLE handle)
{
@@ -5524,7 +5542,7 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, ACE_DL_TYPE symbolname)
{
// ACE_TRACE ("ACE_OS::dlsym");
#if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::dlsym (handle, (char*) symbolname), void *, 0);
#elif defined (ACE_USES_ASM_SYMBOL_IN_DLSYM)
char asm_symbolname [MAXPATHLEN] ;
@@ -5535,7 +5553,7 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, ACE_DL_TYPE symbolname)
ACE_OSCALL_RETURN (::dlsym (handle, asm_symbolname), void *, 0);
#else
ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#elif defined (ACE_WIN32)
ACE_OSCALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0);
#elif defined (__hpux)
@@ -5605,13 +5623,13 @@ ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte)
else
return -1;
#else
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::write (handle, (const char *) buf, nbyte), ssize_t, -1);
#elif defined (ACE_HAS_CHARPTR_SOCKOPT)
ACE_OSCALL_RETURN (::write (handle, (char *) buf, nbyte), ssize_t, -1);
#else
ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#endif /* ACE_WIN32 */
}
@@ -5641,11 +5659,11 @@ ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len)
DWORD ok_len;
return ::ReadFile (handle, buf, len, &ok_len, 0) ? (ssize_t) ok_len : -1;
#else
-#if defined (ACE_LACKS_POSIX_PROTO) || defined (ACE_HAS_CHARPTR_SOCKOPT)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_HAS_CHARPTR_SOCKOPT)
ACE_OSCALL_RETURN (::read (handle, (char *) buf, len), ssize_t, -1);
#else
ACE_OSCALL_RETURN (::read (handle, buf, len), ssize_t, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#endif /* ACE_WIN32 */
}
@@ -6009,11 +6027,11 @@ ACE_OS::shmat (int int_id, void *shmaddr, int shmflg)
{
// ACE_TRACE ("ACE_OS::shmat");
#if defined (ACE_HAS_SYSV_IPC)
-#if defined (ACE_LACKS_POSIX_PROTO) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
ACE_OSCALL_RETURN (::shmat (int_id, (char *)shmaddr, shmflg), void *, (void *) -1);
#else
ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#else
ACE_UNUSED_ARG (int_id);
ACE_UNUSED_ARG (shmaddr);
@@ -6474,7 +6492,7 @@ ACE_OS::execv (const char *path, char *const argv[])
ACE_UNUSED_ARG (argv);
ACE_NOTSUP_RETURN (-1);
-#elif defined (ACE_LACKS_POSIX_PROTO)
+#elif defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::execv (path, (const char **) argv), int, -1);
#else
ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
@@ -6491,7 +6509,7 @@ ACE_OS::execve (const char *path, char *const argv[], char *const envp[])
ACE_UNUSED_ARG (envp);
ACE_NOTSUP_RETURN (-1);
-#elif defined (ACE_LACKS_POSIX_PROTO)
+#elif defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::execve (path, (const char **) argv, (char **) envp), int, -1);
#else
ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
@@ -6507,7 +6525,7 @@ ACE_OS::execvp (const char *file, char *const argv[])
ACE_UNUSED_ARG (argv);
ACE_NOTSUP_RETURN (-1);
-#elif defined (ACE_LACKS_POSIX_PROTO)
+#elif defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::execvp (file, (const char **) argv), int, -1);
#else
ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
@@ -7016,11 +7034,11 @@ ACE_OS::sigaction (int signum,
return osa->sa_handler == SIG_ERR ? -1 : 0;
#elif defined (CHORUS)
ACE_NOTSUP_RETURN (-1);
-#elif defined (ACE_LACKS_POSIX_PROTO) || defined(ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
+#elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined(ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS)
ACE_OSCALL_RETURN (::sigaction (signum, (struct sigaction*) nsa, osa), int, -1);
#else
ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
}
ACE_INLINE char *
@@ -7572,11 +7590,11 @@ ACE_INLINE int
ACE_OS::sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
{
#if !defined (ACE_LACKS_SIGSET)
-#if defined (ACE_LACKS_POSIX_PROTO)
+#if defined (ACE_LACKS_POSIX_PROTOTYPES)
ACE_OSCALL_RETURN (::sigprocmask (how, (int*) nsp, osp), int, -1);
#else
ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
-#endif /* ACE_LACKS_POSIX_PROTO */
+#endif /* ACE_LACKS_POSIX_PROTOTYPES */
#else
ACE_UNUSED_ARG (how);
ACE_UNUSED_ARG (nsp);
diff --git a/ace/README b/ace/README
index a6b45510cc1..915a500ee18 100644
--- a/ace/README
+++ b/ace/README
@@ -209,8 +209,8 @@ ACE_LACKS_NETDB_REENTRANT_FUNCTIONS Platform does not support reentrant netdb fu
ACE_LACKS_RPC_H Platform lacks the ONC RPC header files.
ACE_LACKS_PARAM_H Platform lacks <sys/param.h> (e.g., MVS)
ACE_LACKS_NAMED_POSIX_SEM Platform lacks named POSIX semaphores (e.g., Chorus)
-ACE_LACKS_RLIMIT_PROTO Platform/compiler lacks {get,set}rlimit() prototypes (e.g., Tandem)
-ACE_LACKS_POSIX_PROTO Platform lacks POSIX prototypes for certain System V functions like shared memory and message queues.
+ACE_LACKS_RLIMIT_PROTOTYPE Platform/compiler lacks {get,set}rlimit() prototypes (e.g., Tandem)
+ACE_LACKS_POSIX_PROTOTYPES Platform lacks POSIX prototypes for certain System V functions like shared memory and message queues.
ACE_LACKS_PRI_T Platform lacks pri_t (e.g., Tandem NonStop UNIX).
ACE_LACKS_PTHREAD_CANCEL Platform lacks pthread_cancel().
ACE_LACKS_PTHREAD_THR_SIGSETMASK Platform lacks pthread_thr_sigsetmask (e.g., MVS, HP/UX, and OSF/1 3.2)
@@ -239,11 +239,11 @@ ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES Compiler doesn't support static data memb
ACE_LACKS_STRCASECMP Compiler/platform lacks strcasecmp() (e.g., DG/UX, UNIXWARE, VXWORKS)
ACE_LACKS_STRRECVFD Platform doesn't define struct strrecvfd.
ACE_LACKS_SYSCALL Platform doesn't have syscall() prototype
-ACE_LACKS_SYSV_MSQ_PROTOS Platform doesn't have prototypes for Sys V msg()* queues.
ACE_LACKS_T_ERRNO Header files lack t_errno for TLI
ACE_LACKS_TCP_H Platform doesn't have netinet/tcp.h
ACE_LACKS_THREAD_STACK_SIZE Platform lacks pthread_attr_setstacksize() (e.g., Linux pthreads)
ACE_LACKS_TIMEDWAIT_PROTOTYPES MIT pthreads platform lacks the timedwait prototypes
+ACE_LACKS_UALARM_PROTOTYPE Platform/compiler lacks the ualarm() prototype (e.g., Solaris)
ACE_LACKS_UCONTEXT_H Platform lacks the ucontext.h file
ACE_LACKS_UNIX_DOMAIN_SOCKETS ACE platform has no UNIX domain sockets
ACE_LACKS_UNIX_SIGNALS Platform lacks full signal support (e.g., Win32 and Chorus).
diff --git a/ace/Thread.h b/ace/Thread.h
index 7faae76df0d..a80396b0120 100644
--- a/ace/Thread.h
+++ b/ace/Thread.h
@@ -87,7 +87,7 @@ public:
void *stack[] = 0,
size_t stack_size[] = 0,
ACE_hthread_t thread_handles[] = 0);
- // Spawn N new threads, which execute <func> with argument <arg>.
+ // Spawn <n> new threads, which execute <func> with argument <arg>.
// The thread_ids of successfully spawned threads will be placed
// into the <thread_ids> buffer (which must be the same size as
// <n>). If <stack> != 0 it is assumed to be an array of <n>
diff --git a/ace/Timer_List_T.cpp b/ace/Timer_List_T.cpp
index 443bd024362..dc0d6c5cc26 100644
--- a/ace/Timer_List_T.cpp
+++ b/ace/Timer_List_T.cpp
@@ -10,14 +10,13 @@
// Default Constructor
template <class TYPE, class FUNCTOR, class LOCK>
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &listParm)
- : timer_list_ (listParm),
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &list)
+ : timer_list_ (list),
position_ (NULL)
{
// Nothing
}
-
// Positions the iterator at the node right after the dummy node
template <class TYPE, class FUNCTOR, class LOCK> void
@@ -26,7 +25,6 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::first (void)
this->position_ = this->timer_list_.head_->get_next ();
}
-
// Positions the iterator at the next node in the Timer Queue
template <class TYPE, class FUNCTOR, class LOCK> void
@@ -37,7 +35,6 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::next (void)
this->position_ = this->position_->get_next ();
}
-
// Returns true when we are at <head_>
template <class TYPE, class FUNCTOR, class LOCK> int
@@ -46,7 +43,6 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::isdone (void)
return this->position_ == this->timer_list_.head_;
}
-
// Returns the node at <position_> or NULL if we are at the end
template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE> *
@@ -57,7 +53,6 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::item (void)
return NULL;
}
-
// Return our instance of the iterator
template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> &
@@ -66,7 +61,6 @@ ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::iter (void)
return this->iterator_;
}
-
// Create an empty list.
template <class TYPE, class FUNCTOR, class LOCK>
diff --git a/ace/config-irix6.x-sgic++-nothreads.h b/ace/config-irix6.x-sgic++-nothreads.h
index 649e880ec8a..d599ebbb741 100644
--- a/ace/config-irix6.x-sgic++-nothreads.h
+++ b/ace/config-irix6.x-sgic++-nothreads.h
@@ -26,6 +26,7 @@
#define ACE_HAS_SETOWN
#define ACE_HAS_SYSENT_H
#define ACE_HAS_SYSINFO
+#define ACE_HAS_UALARM
// We need to setup a very high address or Naming_Test won't run.
#define ACE_DEFAULT_BASE_ADDR ((char *) (1024U * 1024 * 1024))
diff --git a/ace/config-irix6.x-sgic++.h b/ace/config-irix6.x-sgic++.h
index 50d3d61fef5..4e3ebe725eb 100644
--- a/ace/config-irix6.x-sgic++.h
+++ b/ace/config-irix6.x-sgic++.h
@@ -14,6 +14,7 @@
#define ACE_HAS_IRIX62_THREADS
#define ACE_HAS_PTHREAD_SIGMASK
+#define ACE_HAS_UALARM
// Needed for the threading stuff?
#include /**/ <sched.h>
diff --git a/ace/config-linux-lxpthreads.h b/ace/config-linux-lxpthreads.h
index 2373a194360..0f3d25adf9e 100644
--- a/ace/config-linux-lxpthreads.h
+++ b/ace/config-linux-lxpthreads.h
@@ -75,8 +75,8 @@
//#define ACE_LACKS_RECVMSG
#define ACE_LACKS_MSYNC
#define ACE_LACKS_MADVISE
-//#define ACE_LACKS_POSIX_PROTO
-#define ACE_LACKS_POSIX_PROTO_FOR_SOME_FUNCS
+//#define ACE_LACKS_POSIX_PROTOTYPES
+#define ACE_LACKS_POSIX_PROTOTYPES_FOR_SOME_FUNCS
// Compiler/platform has <alloca.h>
#define ACE_HAS_ALLOCA_H
diff --git a/ace/config-sco-5.0.0-fsu-pthread.h b/ace/config-sco-5.0.0-fsu-pthread.h
index a4f7aa013fe..ba3cfb22052 100644
--- a/ace/config-sco-5.0.0-fsu-pthread.h
+++ b/ace/config-sco-5.0.0-fsu-pthread.h
@@ -35,7 +35,7 @@
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
#define ACE_HAS_NONCONST_MSGSND
-// #define ACE_LACKS_POSIX_PROTO
+// #define ACE_LACKS_POSIX_PROTOTYPES
#define ACE_HAS_SVR4_DYNAMIC_LINKING
#define ACE_HAS_AUTOMATIC_INIT_FINI
diff --git a/ace/config-sco-5.0.0-mit-pthread.h b/ace/config-sco-5.0.0-mit-pthread.h
index a4e80cfa944..6ffb3cbcc7a 100644
--- a/ace/config-sco-5.0.0-mit-pthread.h
+++ b/ace/config-sco-5.0.0-mit-pthread.h
@@ -39,7 +39,7 @@
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
#define ACE_HAS_NONCONST_MSGSND
-// #define ACE_LACKS_POSIX_PROTO
+// #define ACE_LACKS_POSIX_PROTOTYPES
#define ACE_HAS_SVR4_DYNAMIC_LINKING
#define ACE_HAS_AUTOMATIC_INIT_FINI
diff --git a/ace/config-sunos4-sun3.x.h b/ace/config-sunos4-sun3.x.h
index 2841cf41ee6..5039823c901 100644
--- a/ace/config-sunos4-sun3.x.h
+++ b/ace/config-sunos4-sun3.x.h
@@ -8,7 +8,7 @@
#define ACE_LACKS_GETPGID
-#define ACE_LACKS_POSIX_PROTO
+#define ACE_LACKS_POSIX_PROTOTYPES
#define ACE_HAS_UNION_WAIT
#define ACE_HAS_SPARCWORKS_401_SIGNALS
#define ACE_HAS_SYSV_SPRINTF
diff --git a/ace/config-sunos4-sun4.1.4.h b/ace/config-sunos4-sun4.1.4.h
index 4e3f05e9aea..0c817a32ff7 100644
--- a/ace/config-sunos4-sun4.1.4.h
+++ b/ace/config-sunos4-sun4.1.4.h
@@ -15,7 +15,7 @@
// Special addition to handle sunOS 4.1 which is unable to
// handle POSIX Prototypes !
-#define ACE_LACKS_POSIX_PROTO
+#define ACE_LACKS_POSIX_PROTOTYPES
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
diff --git a/ace/config-sunos4-sun4.x.h b/ace/config-sunos4-sun4.x.h
index d7fa4e18c75..3148f3c6fdb 100644
--- a/ace/config-sunos4-sun4.x.h
+++ b/ace/config-sunos4-sun4.x.h
@@ -11,7 +11,7 @@
#define ACE_LACKS_GETPGID
#define ACE_HAS_CHARPTR_SPRINTF
-#define ACE_LACKS_POSIX_PROTO
+#define ACE_LACKS_POSIX_PROTOTYPES
// #define ACE_HAS_UNION_WAIT
// Platform supports System V IPC (most versions of UNIX, but not Win32)
diff --git a/ace/config-sunos5.4-centerline-2.x.h b/ace/config-sunos5.4-centerline-2.x.h
index 30132ba7a88..be82c2f4fd8 100644
--- a/ace/config-sunos5.4-centerline-2.x.h
+++ b/ace/config-sunos5.4-centerline-2.x.h
@@ -8,6 +8,8 @@
#define ACE_CONFIG_H
#define ACE_HAS_TEMPLATE_SPECIALIZATION
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
// Platform supports pread() and pwrite()
#define ACE_HAS_P_READ_WRITE
diff --git a/ace/config-sunos5.4-g++.h b/ace/config-sunos5.4-g++.h
index 9e56bd14528..66bb13a58de 100644
--- a/ace/config-sunos5.4-g++.h
+++ b/ace/config-sunos5.4-g++.h
@@ -18,6 +18,8 @@
#define ACE_HAS_P_READ_WRITE
#define ACE_HAS_UNICODE
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
#define ACE_HAS_TERM_IOCTLS
diff --git a/ace/config-sunos5.4-sunc++-4.x-orbix.h b/ace/config-sunos5.4-sunc++-4.x-orbix.h
index 4d8767b06b5..317383cbfad 100644
--- a/ace/config-sunos5.4-sunc++-4.x-orbix.h
+++ b/ace/config-sunos5.4-sunc++-4.x-orbix.h
@@ -27,6 +27,8 @@
// The SunOS 5.x version of rand_r is inconsistent with the header files...
#define ACE_HAS_BROKEN_RANDR
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
// Platform supports system configuration information.
#define ACE_HAS_SYSINFO
diff --git a/ace/config-sunos5.4-sunc++-4.x.h b/ace/config-sunos5.4-sunc++-4.x.h
index bd9f0124e92..e7e8e577cbc 100644
--- a/ace/config-sunos5.4-sunc++-4.x.h
+++ b/ace/config-sunos5.4-sunc++-4.x.h
@@ -23,6 +23,8 @@
// Sun has the wrong prototype for sendmsg.
#define ACE_HAS_BROKEN_SENDMSG
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
// The SunOS 5.x version of rand_r is inconsistent with the header files...
#define ACE_HAS_BROKEN_RANDR
diff --git a/ace/config-sunos5.5-g++.h b/ace/config-sunos5.5-g++.h
index 347205a1112..c7ec2a297dd 100644
--- a/ace/config-sunos5.5-g++.h
+++ b/ace/config-sunos5.5-g++.h
@@ -13,6 +13,8 @@
#define ACE_HAS_STRING_CLASS
#define ACE_HAS_TEMPLATE_SPECIALIZATION
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
// ACE_HAS_EXCEPTIONS requires -fhandle-exceptions, but that gives
// g++ 2.7.2 fits: it spits out all kinds of warnings that it doesn't
diff --git a/ace/config-sunos5.5-sunc++-4.x.h b/ace/config-sunos5.5-sunc++-4.x.h
index d605e9bbfff..58085c05d9a 100644
--- a/ace/config-sunos5.5-sunc++-4.x.h
+++ b/ace/config-sunos5.5-sunc++-4.x.h
@@ -46,6 +46,8 @@
#define ACE_HAS_P_READ_WRITE
#define ACE_HAS_UNICODE
+#define ACE_HAS_UALARM
+#define ACE_LACKS_UALARM_PROTOTYPE
// Platform supports System V IPC (most versions of UNIX, but not Win32)
#define ACE_HAS_SYSV_IPC
diff --git a/ace/config-tandem.h b/ace/config-tandem.h
index 191a2cc68b3..e8c49de792a 100644
--- a/ace/config-tandem.h
+++ b/ace/config-tandem.h
@@ -24,7 +24,7 @@
// Tandem doesn't include this although they are defined
// in sys/time.h and sys/resource.h
-#define ACE_LACKS_RLIMIT_PROTO // jjpp
+#define ACE_LACKS_RLIMIT_PROTOTYPE // jjpp
// Tandem has a function to set t_errno (set_t_errno)
#define ACE_HAS_SET_T_ERRNO // jjpp
@@ -410,7 +410,7 @@
// files.
//ACE_LACKS_PARAM_H Platform lacks <sys/param.h> (e.g.,
//MVS)
-//ACE_LACKS_POSIX_PROTO Platform lacks POSIX prototypes for
+//ACE_LACKS_POSIX_PROTOTYPES Platform lacks POSIX prototypes for
//certain System V functions like shared memory and message queues.
//ACE_LACKS_RECVMSG Platform lacks recvmsg() (e.g., Linux)
//ACE_LACKS_RWLOCK_T Platform lacks readers/writer locks.
diff --git a/tests/Async_Timer_Queue_Test.cpp b/tests/Async_Timer_Queue_Test.cpp
index 6a00e6869cc..05254dab693 100644
--- a/tests/Async_Timer_Queue_Test.cpp
+++ b/tests/Async_Timer_Queue_Test.cpp
@@ -17,57 +17,203 @@
//
// ============================================================================
-#include "ace/Profile_Timer.h"
+#include "ace/Signal.h"
#include "ace/Timer_List.h"
#include "test_config.h"
+// Number of lines of input read.
static int lines = 0;
+// Were we interrupted by a SIGINT?
+sig_atomic_t sigint = 0;
+
static ACE_Timer_List timer_list;
static void
handler (int signum)
{
+ ACE_DEBUG ((LM_DEBUG, "handling signal %S\n", signum));
+ sigint = signum == SIGINT;
+
switch (signum)
{
case SIGALRM:
- ACE_DEBUG ((LM_DEBUG, "you've entered %d lines, time = %d\n", lines, ACE_OS::time ()));
- break;
+ {
+ int expired_timers;
+
+ ACE_Sig_Set ss;
+ ss.sig_add (SIGINT);
+
+ // Prevent SIGINT from occurring while we're handling SIGALRM.
+ ACE_Sig_Guard sg (&ss);
+
+ // Expire the pending timers.
+ expired_timers = timer_list.expire ();
+
+ if (expired_timers > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "you've entered %d lines, time = %d, timers expired = %d\n",
+ lines,
+ ACE_OS::time (),
+ expired_timers));
+
+ // Only schedule a new timer if there is one in the list.
+ if (timer_list.is_empty () == 0)
+ ACE_OS::ualarm (timer_list.earliest_time () - timer_list.gettimeofday ());
+
+ break;
+ }
+ /* NOTREACHED */
case SIGINT:
- ACE_DEBUG ((LM_DEBUG, "dumping timer queue\n"));
{
+ ACE_DEBUG ((LM_DEBUG, "begin dumping timer queue\n"));
+
+ ACE_Sig_Set ss;
+ ss.sig_add (SIGALRM);
+
+ // Prevent SIGALRM from occurring while we're handling
+ // SIGINT.
+ ACE_Sig_Guard sg (&ss);
+
for (ACE_Timer_List_Iterator iter (timer_list);
- iter.isdone () == 0;
+ iter.item () != 0;
iter.next ())
iter.item ()->dump ();
+
+ ACE_DEBUG ((LM_DEBUG, "end dumping timer queue\n"));
+
+ break;
+ /* NOTREACHED */
}
+ case SIGQUIT:
+ ACE_DEBUG ((LM_DEBUG, "shutting down on SIGQUIT%a\n", 1));
+ /* NOTREACHED */
break;
}
}
-static char menu[] =
-"****\n"
-"1) schedule_timer usecs \n"
-"2) cancel_timer timer_id\n"
-"^C list_timers\n"
-"please enter your choice: ";
-
-static void
-parse_buf (char *buf)
+class Timer_Handler : public ACE_Event_Handler
+{
+public:
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg);
+ // Callback hook invoked by the <Timer_List>.
+
+ ~Timer_Handler (void);
+ // Destructor
+};
+
+int
+Timer_Handler::handle_timeout (const ACE_Time_Value &tv,
+ const void *arg)
{
- ACE_DEBUG ((LM_DEBUG, "===== %s", buf));
+ ACE_DEBUG ((LM_DEBUG,
+ "handle_timeout() = (%d, %d) %d\n",
+ tv.sec (),
+ tv.usec (),
+ arg));
+ delete this;
+ return 0;
}
-/* sigprocmask (SIG_BLOCK, &ss, 0);
- sigprocmask (SIG_UNBLOCK, &ss, 0); */
+Timer_Handler::~Timer_Handler (void)
+{
+ // ACE_DEBUG ((LM_DEBUG, "deleting %x\n", this));
+}
static int
-run (u_int delay)
+parse_commands (char *buf)
+{
+ u_int choice;
+ long value;
+
+ if (sscanf (buf, "%d %d", &choice, &value) != 2)
+ ACE_ERROR_RETURN ((LM_ERROR, "invalid input %s", buf), -1);
+
+ switch (choice)
+ {
+ case 1: // Schedule a timer.
+ {
+ ACE_Time_Value tv (0, value);
+ ACE_Event_Handler *eh;
+ ACE_NEW_RETURN (eh, Timer_Handler, -1);
+
+ ACE_Sig_Set ss;
+ ss.sig_add (SIGALRM);
+ ss.sig_add (SIGINT);
+
+ {
+ // Prevent SIGALRM and SIGINT from occurring while we're
+ // scheduling a timer.
+ ACE_Sig_Guard sg (&ss);
+
+ long tid = timer_list.schedule (eh, 0,
+ timer_list.gettimeofday () + tv);
+
+ if (tid == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1);
+
+ tv = timer_list.earliest_time () - timer_list.gettimeofday ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ "scheduling timer %d for (%d, %d)\n",
+ tid, tv.sec (), tv.usec ()));
+ }
+
+ // Beware of negative times and zero times (which cause
+ // problems for ualarm()).
+ if (tv < ACE_Time_Value::zero)
+ tv = ACE_Time_Value (0, 1);
+
+ // Schedule a new timer.
+ ACE_OS::ualarm (tv);
+
+ break;
+ /* NOTREACHED */
+ }
+ case 2: // Cancel a timer.
+ {
+ const void *act;
+
+ ACE_Sig_Set ss;
+ ss.sig_add (SIGALRM);
+ ss.sig_add (SIGINT);
+
+ // Prevent SIGALRM and SIGINT from occurring while we're
+ // scheduling a timer.
+ ACE_Sig_Guard sg (&ss);
+
+ if (timer_list.cancel (value, &act) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cancel_timer"), -1);
+
+ delete (ACE_Event_Handler *) act;
+
+ ACE_DEBUG ((LM_DEBUG, "canceling %d\n", value));
+ break;
+ /* NOTREACHED */
+ }
+ }
+}
+
+static char menu[] =
+"****\n"
+"1) schedule_timer <usecs> \n"
+"2) cancel_timer <timer_id>\n"
+"^C list_timers\n"
+"please enter your choice: ";
+
+int
+main (int argc, char *argv[])
{
- ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGALRM);
+ // ACE_START_TEST ("Timer_Queue_Test");
+#if defined (ACE_HAS_UALARM)
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler);
ACE_UNUSED_ARG (sa);
- ACE_OS::ualarm (delay, delay);
+ // Register the signal handlers.
+ sa.register_action (SIGINT);
+ sa.register_action (SIGALRM);
+ sa.register_action (SIGQUIT);
ACE_DEBUG ((LM_DEBUG, "%s", menu));
@@ -80,27 +226,19 @@ run (u_int delay)
{
if (errno != EINTR)
break;
+ else if (sigint)
+ ACE_DEBUG ((LM_DEBUG, "%s", menu));
}
else
{
lines++;
- parse_buf (buf);
+ parse_commands (buf);
ACE_DEBUG ((LM_DEBUG, "%s", menu));
}
}
-
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
- // ACE_START_TEST ("Timer_Queue_Test");
-
- u_int delay = argc > 1 ? atoi (argv[1]) : ACE_DEFAULT_USECS;
-
- run (delay);
-
+#else
+ ACE_ERROR_RETURN ((LM_ERROR, "platform doesn't support ualarm\n", -1));
+#endif /* ACE_HAS_UALARM */
// ACE_END_TEST;
return 0;
}