summaryrefslogtreecommitdiff
path: root/ace/OS.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/OS.cpp')
-rw-r--r--ace/OS.cpp90
1 files changed, 49 insertions, 41 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 61a72dff9ea..afaad3ef5a6 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -244,11 +244,13 @@ const ACE_Time_Value ACE_Time_Value::max_time (LONG_MAX,
ACE_ALLOC_HOOK_DEFINE(ACE_Time_Value)
+// Initializes the ACE_Time_Value object from a timeval.
+
#if defined (ACE_WIN32)
+// Initializes the ACE_Time_Value object from a Win32 FILETIME
+
// Static constant to remove time skew between FILETIME and POSIX
-// time. POSIX and Win32 use different epochs (Jan. 1, 1970 v.s.
-// Jan. 1, 1601). The following constant defines the difference
-// in 100ns ticks.
+// time.
//
// In the beginning (Jan. 1, 1601), there was no time and no computer.
// And Bill said: "Let there be time," and there was time....
@@ -260,8 +262,6 @@ const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew =
ACE_INT64_LITERAL (0x19db1ded53e8000);
# endif
-// Initializes the ACE_Time_Value object from a Win32 FILETIME
-
ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
{
// ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
@@ -967,7 +967,7 @@ void
ACE_OS::mutex_lock_cleanup (void *mutex)
{
ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
-#if defined (ACE_HAS_PACE) && !defined (ACE_WIN32)
+#if defined (ACE_HAS_PACE) && !defined (ACE_WIN32)
pace_pthread_mutex_t *p_lock = (pace_pthread_mutex_t *) mutex;
pace_pthread_mutex_unlock (p_lock);
# elif defined (ACE_HAS_THREADS)
@@ -979,7 +979,7 @@ ACE_OS::mutex_lock_cleanup (void *mutex)
# endif /* ACE_HAS_PTHREADS */
# else
ACE_UNUSED_ARG (mutex);
-# endif /* ACE_HAS_PACE && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
#if defined (ACE_HAS_WINCE)
@@ -1402,9 +1402,9 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params,
else if (sched_params.scope () == ACE_SCOPE_THREAD)
{
ACE_thread_t thr_id = ACE_OS::thr_self ();
- return pace_pthread_setschedparam (thr_id,
- sched_params.policy (),
- &param);
+ return pthread_setschedparam (thr_id,
+ sched_params.policy (),
+ &param);
}
#if defined (sun)
// We need to be able to set LWP priorities on Suns, even without
@@ -1555,7 +1555,7 @@ ACE_OS::sched_params (const ACE_Sched_Params &sched_params,
ACE_UNUSED_ARG (sched_params);
ACE_UNUSED_ARG (id);
ACE_NOTSUP_RETURN (-1);
-#endif /* ACE_HAS_PACE && !ACE_WIN32 */
+#endif /* ACE_HAS_PACE */
}
// = Static initialization.
@@ -2554,7 +2554,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
if (thr_handle == 0)
thr_handle = &tmp_handle;
- int result = 0;
+ int result;
pace_pthread_attr_t attr;
if (::pace_pthread_attr_init (&attr) != 0)
return -1;
@@ -2678,7 +2678,19 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
{
pace_sched_param sparam;
ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
- sparam.sched_priority = priority;
+ // The following code forces priority into range.
+ if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_FIFO_MAX,
+ ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
+ else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_RR_MAX,
+ ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
+ else // Default policy, whether set or not
+ sparam.sched_priority =
+ ACE_MIN (ACE_THR_PRI_OTHER_MAX,
+ ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER)
// SunOS, through 5.6, POSIX only allows priorities > 0 to
// ::pthread_attr_setschedparam. If a priority of 0 was
@@ -2765,7 +2777,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
ACE_OSCALL (ACE_ADAPT_RETVAL (::pace_pthread_create (thr_id,
&attr,
- PACE_THR_ENTRY_CAST (void * (*)(void *)) thread_args->entry_point (),
+ thread_args->entry_point (),
thread_args),
result),
int, -1, result);
@@ -2828,7 +2840,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
return result;
-#else /* ACE_HAS_PACE && !ACE_WIN32 */
+#else /* ACE_HAS_PACE */
ACE_Base_Thread_Adapter *thread_args;
if (thread_adapter == 0)
@@ -3654,7 +3666,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
ACE_UNUSED_ARG (stacksize);
ACE_NOTSUP_RETURN (-1);
# endif /* ACE_HAS_THREADS */
-#endif /* ACE_HAS_PACE && !ACE_WIN32 */
+#endif /* ACE_HAS_PACE */
}
void
@@ -3731,7 +3743,7 @@ ACE_OS::thr_exit (void *status)
# endif /* ACE_HAS_PTHREADS */
# else
ACE_UNUSED_ARG (status);
-# endif /* ACE_HAS_PACE && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
int
@@ -3906,7 +3918,7 @@ ACE_OS::thr_setspecific (ACE_thread_key_t key, void *data)
ACE_UNUSED_ARG (key);
ACE_UNUSED_ARG (data);
ACE_NOTSUP_RETURN (-1);
-# endif /* ACE_HAS_PACE && !ACE_HAS_TSS_EMULATION && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
int
@@ -3947,7 +3959,7 @@ ACE_OS::thr_keyfree (ACE_thread_key_t key)
# else
ACE_UNUSED_ARG (key);
ACE_NOTSUP_RETURN (-1);
-# endif /* ACE_HAS_PACE && !ACE_HAS_TSS_EMULATION && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
@@ -4007,7 +4019,7 @@ ACE_OS::thr_keycreate (ACE_OS_thread_key_t *key,
ACE_UNUSED_ARG (dest);
ACE_UNUSED_ARG (inst);
ACE_NOTSUP_RETURN (-1);
-# endif /* ACE_HAS_PACE && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */
@@ -4107,7 +4119,7 @@ ACE_OS::thr_keycreate (ACE_thread_key_t *key,
ACE_UNUSED_ARG (dest);
ACE_UNUSED_ARG (inst);
ACE_NOTSUP_RETURN (-1);
-# endif /* ACE_HAS_PACE && !ACE_HAS_TSS_EMULATION && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
}
int
@@ -4818,7 +4830,7 @@ siginfo_t::siginfo_t (ACE_HANDLE *handles)
si_handles_ (handles)
{
}
-# endif /* ! ACE_HAS_PACE || ! ACE_WIN32 */
+# endif /* ! (ACE_HAS_PACE && ACE_WIN32) */
# endif /* ACE_HAS_SIGINFO_T */
pid_t
@@ -5730,7 +5742,7 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw,
}
# endif /* ! ACE_HAS_THREADS || ACE_LACKS_RWLOCK_T */
-#if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS) && ! (defined (ACE_HAS_PACE) && ! defined (ACE_HAS_WIN32))
+#if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS)
// NOTE: The ACE_OS::cond_* functions for some non-Unix platforms are
// defined here either because they're too big to be inlined, or
// to avoid use before definition if they were inline.
@@ -5924,9 +5936,7 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
ACE_mutex_t *external_mutex)
{
ACE_OS_TRACE ("ACE_OS::cond_wait");
-# if defined (ACE_HAS_PACE) && !defined (ACE_WIN32)
- return (::pace_pthread_cond_wait(cv, external_mutex);
-# elif defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_THREADS)
// Prevent race conditions on the <waiters_> count.
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
cv->waiters_++;
@@ -5947,7 +5957,7 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
cv->sema_, INFINITE, FALSE),
result),
int, -1, result);
-# endif /* ACE_HAS_PACE && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
else
# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
{
@@ -6028,9 +6038,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
ACE_Time_Value *timeout)
{
ACE_OS_TRACE ("ACE_OS::cond_timedwait");
-# if defined (ACE_HAS_PACE) && !defined (ACE_WIN32)
- return (::pace_pthread_cond_timedwait(cv, external_mutex, timeout);
-# elif defined (ACE_HAS_THREADS)
+# if defined (ACE_HAS_THREADS)
// Handle the easy case first.
if (timeout == 0)
return ACE_OS::cond_wait (cv, external_mutex);
@@ -6076,7 +6084,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
cv->sema_,
msec_timeout,
FALSE);
-# endif /* ACE_HAS_PACE && !ACE_WIN32 */
+# endif /* ACE_HAS_PACE */
else
# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
{
@@ -6786,21 +6794,21 @@ ACE_OS_Object_Manager::init (void)
ACE_CE_Errno::init ();
# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t, ACE_OS_MONITOR_LOCK)
- if (ACE_OS::thread_mutex_init
+ if (ACE_OS::thread_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_LIB_TEXT ("ACE_OS_MONITOR_LOCK"));
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_CLEANUP_LOCK)
- if (ACE_OS::recursive_mutex_init
+ if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_LIB_TEXT ("ACE_TSS_CLEANUP_LOCK"));
ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t,
ACE_LOG_MSG_INSTANCE_LOCK)
- if (ACE_OS::thread_mutex_init
+ if (ACE_OS::thread_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6808,7 +6816,7 @@ ACE_OS_Object_Manager::init (void)
# if defined (ACE_HAS_TSS_EMULATION)
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_KEY_LOCK)
- if (ACE_OS::recursive_mutex_init
+ if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6816,7 +6824,7 @@ ACE_OS_Object_Manager::init (void)
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_BASE_LOCK)
- if (ACE_OS::recursive_mutex_init
+ if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6893,7 +6901,7 @@ ACE_OS_Object_Manager::fini (void)
// Cleanup the dynamically preallocated objects.
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
- if (ACE_OS::thread_mutex_destroy
+ if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6902,7 +6910,7 @@ ACE_OS_Object_Manager::fini (void)
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t,
ACE_OS_MONITOR_LOCK)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
- if (ACE_OS::recursive_mutex_destroy
+ if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6911,7 +6919,7 @@ ACE_OS_Object_Manager::fini (void)
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_CLEANUP_LOCK)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
- if (ACE_OS::thread_mutex_destroy
+ if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6921,7 +6929,7 @@ ACE_OS_Object_Manager::fini (void)
ACE_LOG_MSG_INSTANCE_LOCK)
# if defined (ACE_HAS_TSS_EMULATION)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
- if (ACE_OS::recursive_mutex_destroy
+ if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
@@ -6931,7 +6939,7 @@ ACE_OS_Object_Manager::fini (void)
ACE_TSS_KEY_LOCK)
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
- if (ACE_OS::recursive_mutex_destroy
+ if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (