diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-25 08:21:01 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-25 08:21:01 +0000 |
commit | 16ae5e4bba62c9c43a6f9162a15e339854cd285f (patch) | |
tree | 7376043e9e545101ba507bf08685bf726e03e7d2 | |
parent | ae3742d1d6afe6974dfb95acab3b7b99776f30a4 (diff) | |
download | ATCD-16ae5e4bba62c9c43a6f9162a15e339854cd285f.tar.gz |
Later
-rw-r--r-- | ChangeLog-96b | 27 | ||||
-rw-r--r-- | ace/OS.cpp | 104 | ||||
-rw-r--r-- | ace/OS.h | 24 | ||||
-rw-r--r-- | ace/OS.i | 56 | ||||
-rw-r--r-- | ace/Profile_Timer.cpp | 2 | ||||
-rw-r--r-- | ace/README | 4 | ||||
-rw-r--r-- | ace/Task.cpp | 8 | ||||
-rw-r--r-- | ace/Task.h | 6 | ||||
-rw-r--r-- | ace/config-mvs.h | 177 | ||||
-rw-r--r-- | examples/Threads/test_task_three.cpp | 4 | ||||
-rw-r--r-- | examples/Threads/test_tss2.cpp | 26 | ||||
-rw-r--r-- | include/makeinclude/rules.local.GNU | 2 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/collection.cpp | 12 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp | 5 | ||||
-rw-r--r-- | tests/Mutex_Test.cpp | 5 | ||||
-rw-r--r-- | tests/Priority_Buffer_Test.cpp | 7 | ||||
-rw-r--r-- | tests/UPIPE_SAP_Test.cpp | 4 |
17 files changed, 362 insertions, 111 deletions
diff --git a/ChangeLog-96b b/ChangeLog-96b index ecbe7b137ae..32a7b67f641 100644 --- a/ChangeLog-96b +++ b/ChangeLog-96b @@ -1,5 +1,32 @@ +Mon Nov 25 00:23:40 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/OS.cpp (thr_create): Came up with a remarkably clever scheme + that should make it possible to utilize the ACE library *without + change* on MVS, where the frigging C++ compiler requires all + functions passed to pthread_create() have an extern "C" linkage. + The trick was to generalize the thread adapter mechanism used + for Win32. + + * ace/OS: Added a new macro called ACE_PTHREAD_CLEANUP_PUSH that + selects the right mechanism (e.g., ace_spawn_adapter or not) for + passing functions to pthread_cleanup_push(). + + * ace/config-mvs.h: Added a new macro called ACE_HAS_THR_C_FUNC + which expresses the fact that the MVS C++ compiler *must* have + an extern "C" function passed to pthread_create(). + + * ace/OS.h: Modified all uses of ACE_OS::mutex_lock_cleanup() to + use the extern "C" ace_spawn_adapter() on platforms MVS like MVS + that can't deal with non-C functions to pthread_create. Thanks + to Chuck Gehr for reporting this. + + * ace/OS.cpp (thr_create): Added Chuck Gehr's patches for MVS. + Sun Nov 24 12:30:45 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * ace: Added Chuck Gehr's <gehr@sweng.stortek.com> config-mvs.h + file! + * ace: Began adding support for WinSock 2.0. Thanks to Luca for this. diff --git a/ace/OS.cpp b/ace/OS.cpp index b0aaac73e43..f143553a463 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -34,7 +34,7 @@ ACE_OS::flock_t::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -void +void ACE_OS::mutex_lock_cleanup (void *mutex) { // ACE_TRACE ("ACE_OS::mutex_lock_cleanup"); @@ -533,40 +533,46 @@ ACE_TSS_Cleanup::dump (void) key_info->dump (); } -// Special thread startup argument (used below in <thr_create>). +#endif // WIN32 -class ACE_Win32_Thread_Adapter +class ACE_Thread_Adapter + // = TITLE + // Converts a C++ function into a function <ace_thread_adapter> + // function that can be called from a thread creation routine + // (e.g., pthread_create() or _beginthreadex()) that expects an + // extern "C" entry point. + // + // = DESCRIPTION + // This is used below in <ACE_OS::thr_create> for Win32 and + // MVS. { public: - ACE_Win32_Thread_Adapter (ACE_THR_FUNC f, void *a); - // Constructor + ACE_Thread_Adapter (ACE_THR_FUNC f, void *a); + // Constructor. - static void *svc_run (ACE_Win32_Thread_Adapter *); - // Run the thread exit point. - -private: + // private: // = Arguments to thread startup. ACE_THR_FUNC func_; - // Thread startup function. + // Thread startup function (C++ linkage). void *arg_; // Argument to thread startup function. }; -ACE_Win32_Thread_Adapter::ACE_Win32_Thread_Adapter (ACE_THR_FUNC f, void *a) - : func_(f), - arg_(a) -{ -// ACE_TRACE ("ACE_Win32_Thread_Adapter::ACE_Win32_Thread_Adapter"); -} +// Run the thread exit point. This must be an extern "C" to make +// certain compilers happy... -void * -ACE_Win32_Thread_Adapter::svc_run (ACE_Win32_Thread_Adapter *thread_args) +extern "C" +void *ace_thread_adapter (void *args) { -// ACE_TRACE ("ACE_Win32_Thread_Adapter::svc_run"); + // ACE_TRACE ("ACE_Thread_Adapter::svc_run"); + ACE_Thread_Adapter *thread_args = (ACE_Thread_Adapter *) args; + ACE_THR_FUNC func = thread_args->func_; void *arg = thread_args->arg_; delete thread_args; + +#if defined (ACE_WIN32) void *status; ACE_SEH_TRY { @@ -583,12 +589,19 @@ ACE_Win32_Thread_Adapter::svc_run (ACE_Win32_Thread_Adapter *thread_args) // If dropped off end, call destructors for thread-specific storage // and exit. ACE_TSS_Cleanup::instance ()->exit (status); - /* NOTREACHED */ return status; +#else + return (*func) (arg); // Call thread entry point. +#endif /* ACE_WIN32 */ } -#endif // WIN32 +ACE_Thread_Adapter::ACE_Thread_Adapter (ACE_THR_FUNC f, void *a) + : func_(f), + arg_(a) +{ +// ACE_TRACE ("ACE_Thread_Adapter::ACE_Thread_Adapter"); +} int ACE_OS::thr_create (ACE_THR_FUNC func, @@ -615,6 +628,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (::pthread_attr_init (&attr) != 0) #endif /* ACE_HAS_SETKIND_NP */ return -1; +#if !defined (ACE_LACKS_SETSCHED) else if (priority != 0) { struct sched_param sparam; @@ -652,8 +666,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func, pthread_attr_destroy (&attr); return -1; } -#endif // ACE_HAS_FSU_PTHREADS +#endif /* ACE_HAS_FSU_PTHREADS */ } +#endif /* ACE_LACKS_SETSCHED */ #if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE) @@ -708,7 +723,11 @@ ACE_OS::thr_create (ACE_THR_FUNC func, #if defined (ACE_HAS_SETKIND_NP) if (::pthread_attr_setdetach_np (&attr, dstate) != 0) #else /* ACE_HAS_SETKIND_NP */ +#if defined (ACE_HAS_PTHREAD_DSTATE_PTR) + if (::pthread_attr_setdetachstate (&attr, &dstate) != 0) +#else if (::pthread_attr_setdetachstate (&attr, dstate) != 0) +#endif /* ACE_HAS_PTHREAD_DSTATE_PTR */ #endif /* ACE_HAS_SETKIND_NP */ { #if defined (ACE_HAS_SETKIND_NP) @@ -720,6 +739,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, } } #endif /* ACE_LACKS_SETDETACH */ +#if !defined (ACE_LACKS_SETSCHED) if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || ACE_BIT_ENABLED (flags, THR_SCHED_RR) || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) @@ -791,6 +811,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, return -1; } } +#endif /* ACE_LACKS_SETSCHED */ #if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING) if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM) || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS)) @@ -823,18 +844,28 @@ ACE_OS::thr_create (ACE_THR_FUNC func, p_thr = (thr_id == 0 ? &tmp_thr : thr_id); #if defined (ACE_HAS_SETKIND_NP) +#if defined (ACE_HAS_THR_C_FUNC) + ACE_Thread_Adapter *thread_args; + ACE_NEW_RETURN (thread_args, ACE_Thread_Adapter (func, args), -1); + + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (p_thr, attr, + ACE_THR_C_FUNC (&ace_thread_adapter), + thread_args), + result), + int, -1, result); +#else ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (p_thr, attr, func, args), result), int, -1, result); +#endif /* ACE_HAS_THR_C_FUNC */ + ::pthread_attr_delete (&attr); - if (thr_handle != 0) - *thr_handle = ACE_OS::NULL_hthread; #else /* !ACE_HAS_SETKIND_NP */ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (p_thr, &attr, func, args), result), int, -1, result); ::pthread_attr_destroy (&attr); - +#endif /* ACE_HAS_SETKIND_NP */ #if defined (ACE_HAS_STHREADS) // This is the Solaris implementation of pthreads, where // ACE_thread_t and ACE_hthread_t are the same. @@ -844,7 +875,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (thr_handle != 0) *thr_handle = ACE_OS::NULL_hthread; #endif /* ACE_HAS_STHREADS */ -#endif /* ACE_HAS_SETKIND_NP */ return result; #elif defined (ACE_HAS_STHREADS) int result; @@ -863,17 +893,14 @@ ACE_OS::thr_create (ACE_THR_FUNC func, if (thr_handle == 0) thr_handle = &handle; - ACE_Win32_Thread_Adapter *thread_args; - - ACE_NEW_RETURN (thread_args, ACE_Win32_Thread_Adapter (func, args), -1); - - typedef unsigned (__stdcall *ThreadFunc) (void*); + ACE_Thread_Adapter *thread_args; + ACE_NEW_RETURN (thread_args, ACE_Thread_Adapter (func, args), -1); #if defined (ACE_HAS_MFC) if (ACE_BIT_ENABLED (flags, THR_USE_AFX)) { CWinThread *cwin_thread = - ::AfxBeginThread ((ThreadFunc) (ACE_Win32_Thread_Adapter::svc_run), + ::AfxBeginThread (ACE_THR_C_FUNC (&ace_thread_adapter)), thread_args, 0, 0, flags | THR_SUSPENDED); // Have to duplicate the handle because // CWinThread::~CWinThread() closes the original handle. @@ -898,7 +925,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, *thr_handle = (void *) ::_beginthreadex (NULL, stacksize, - (ThreadFunc) (ACE_Win32_Thread_Adapter::svc_run), + ACE_THR_C_FUNC (&ace_thread_adapter), thread_args, flags, (unsigned int *) thr_id); @@ -906,7 +933,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, #if 0 *thr_handle = ::CreateThread (NULL, stacksize, - LPTHREAD_START_ROUTINE (ACE_Win32_Thread_Adapter::svc_run), + LPTHREAD_START_ROUTINE (ACE_THR_C_FUNC (ace_thread_adapter), thread_args, flags, thr_id); #endif /* 0 */ @@ -1333,3 +1360,12 @@ siginfo_t::siginfo_t (ACE_HANDLE handle) { } #endif /* ACE_HAS_SIGINFO_T */ + +// This is necessary to work around nasty problems with MVS C++. + +extern "C" void * +ace_mutex_lock_cleanup_adapter (void *args) +{ + ACE_OS::mutex_lock_cleanup (args); + return 0; +} @@ -591,6 +591,10 @@ typedef pthread_mutex_t ACE_thread_mutex_t; #endif /* PTHREAD_CREATE_UNDETACHED */ #endif /* PTHREAD_CREATE_JOINABLE */ +#if !defined (PTHREAD_CREATE_DETACHED) +#define PTHREAD_CREATE_DETACHED 1 +#endif /* PTHREAD_CREATE_DETACHED */ + #if !defined (PTHREAD_PROCESS_PRIVATE) #if defined (PTHREAD_MUTEXTYPE_FAST) #define PTHREAD_PROCESS_PRIVATE PTHREAD_MUTEXTYPE_FAST @@ -1755,12 +1759,19 @@ union semun #define ACE_MAXCLIENTIDLEN MAXHOSTNAMELEN + 20 // Create some useful typedefs. -#if defined (VXWORKS) -typedef FUNCPTR ACE_THR_FUNC; // where typedef int (*FUNCPTR) (...) -#else /* ! VXWORKS */ +typedef const char **SYS_SIGLIST; typedef void *(*ACE_THR_FUNC)(void *); + +extern "C" +{ +#if defined (VXWORKS) +typedef FUNCPTR ACE_THR_C_FUNC; // where typedef int (*FUNCPTR) (...) +#elif defined (ACE_WIN32) +typedef unsigned (__stdcall *ACE_THR_C_FUNC) (void*); +#else +typedef void *(*ACE_THR_C_FUNC)(void *); #endif /* ! VXWORKS */ -typedef const char **SYS_SIGLIST; +} #if !defined (MAP_FAILED) #define MAP_FAILED ((void *) -1) @@ -2307,11 +2318,12 @@ public: // Keeps track of whether we've already initialized WinSock... #endif /* ACE_WIN32 */ + static void mutex_lock_cleanup (void *mutex); + // Handle asynchronous thread cancellation cleanup. + private: ACE_OS (void); // Ensure we can't define an instance of this class. - - static void mutex_lock_cleanup (void *lock); }; #include "ace/Trace.h" @@ -134,6 +134,14 @@ extern "C" char *mktemp (char *); // put them inside of here to reduce compiler overhead if we're not // inlining... +#if defined (ACE_HAS_THR_C_FUNC) +// This is necessary to work around nasty problems with MVS C++. +extern "C" void *ace_mutex_lock_cleanup_adapter (void *args); +#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_THR_C_FUNC (ace_mutex_lock_cleanup_adapter), (void *) A)); +#else +#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_THR_FUNC (ACE_OS::mutex_lock_cleanup), (void *) A)); +#endif /* ACE_HAS_THR_C_FUNC */ + #if defined (ACE_HAS_REGEX) #include /**/ <regexpr.h> #endif /* ACE_HAS_REGEX */ @@ -677,27 +685,20 @@ ACE_OS::mutex_init (ACE_mutex_t *m, int result = -1; #if defined (ACE_HAS_SETKIND_NP) -#if defined (ACE_HAS_PTHREAD_ATTR_INIT) if (::pthread_mutexattr_init (&attributes) == 0 && ::pthread_mutexattr_setkind_np (&attributes, type) == 0 && ::pthread_mutex_init (m, &attributes) == 0) #else - if (::pthread_mutexattr_create (&attributes) == 0 - && ::pthread_mutexattr_setkind_np (&attributes, type) == 0 - && ::pthread_mutex_init (m, attributes) == 0) -#endif /* ACE_HAS_PTHREAD_ATTR_INIT */ -#else if (::pthread_mutexattr_init (&attributes) == 0 +#if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) + && ::pthread_mutexattr_setkind_np (&attributes, type) == 0 +#endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ && ::pthread_mutex_init (m, &attributes) == 0) #endif /* ACE_HAS_SETKIND_NP */ result = 0; #if defined (ACE_HAS_SETKIND_NP) -#if defined (ACE_HAS_PTHREAD_ATTR_DESTROY) - ::pthread_mutexattr_destroy (&attributes); -#else ::pthread_mutexattr_delete (&attributes); -#endif /* ACE_HAS_PTHREAD_ATTR_DESTROY */ #else ::pthread_mutexattr_destroy (&attributes); #endif /* ACE_HAS_SETKIND_NP */ @@ -1044,13 +1045,11 @@ ACE_OS::cond_init (ACE_cond_t *cv, int type, LPCTSTR name, void *arg) int result = -1; #if defined (ACE_HAS_SETKIND_NP) -#if defined (ACE_HAS_PTHREAD_ATTR_INIT) if (::pthread_condattr_init (&attributes) == 0 && ::pthread_cond_init (cv, &attributes) == 0 -#else - if (::pthread_condattr_create (&attributes) == 0 - && ::pthread_cond_init (cv, attributes) == 0 -#endif /* ACE_HAS_PTHREAD_ATTR_INIT */ +#if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP) + && ::pthread_condattr_setkind_np (&attributes, type) == 0 +#endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */ #else if (::pthread_condattr_init (&attributes) == 0 && ::pthread_cond_init (cv, &attributes) == 0 @@ -1062,11 +1061,7 @@ ACE_OS::cond_init (ACE_cond_t *cv, int type, LPCTSTR name, void *arg) result = 0; #if defined (ACE_HAS_SETKIND_NP) -#if defined (ACE_HAS_PTHREAD_ATTR_DESTROY) - ::pthread_condattr_destroy (&attributes); -#else ::pthread_condattr_delete (&attributes); -#endif /* ACE_HAS_PTHREAD_ATTR_DESTROY */ #else ::pthread_condattr_destroy (&attributes); #endif /* ACE_HAS_SETKIND_NP */ @@ -1347,7 +1342,7 @@ ACE_OS::rw_rdlock (ACE_rwlock_t *rw) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), ace_result_), int, -1); #else // NT, POSIX, and VxWorks don't support this natively. #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) - pthread_cleanup_push (ACE_OS::mutex_lock_cleanup, (void *) &rw->lock_); + ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); #endif /* ACE_HAS_DCETHREADS */ int result = 0; if (ACE_OS::mutex_lock (&rw->lock_) == -1) @@ -1503,8 +1498,8 @@ ACE_OS::rw_wrlock (ACE_rwlock_t *rw) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), ace_result_), int, -1); #else // NT, POSIX, and VxWorks don't support this natively. #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) - pthread_cleanup_push (ACE_OS::mutex_lock_cleanup, (void *) &rw->lock_); -#endif + ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); +#endif /* defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) */ int result = 0; if (ACE_OS::mutex_lock (&rw->lock_) == -1) result = -1; // -1 means didn't get the mutex. @@ -1529,7 +1524,7 @@ ACE_OS::rw_wrlock (ACE_rwlock_t *rw) ACE_OS::mutex_unlock (&rw->lock_); #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) pthread_cleanup_pop (0); -#endif +#endif /* defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) */ return 0; #endif /* ACE_HAS_STHREADS */ #else @@ -2815,7 +2810,7 @@ ACE_OS::sema_wait (ACE_sema_t *s) #elif defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) int result = 0; - pthread_cleanup_push (ACE_OS::mutex_lock_cleanup, (void *) &s->lock_); + ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); if (ACE_OS::mutex_lock (&s->lock_) != 0) result = -1; @@ -2914,7 +2909,7 @@ ACE_INLINE int ACE_OS::thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2) { #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) -#if defined (ACE_HAS_TID_T) && !defined (ACE_HAS_SETKIND_NP) +#if defined (ACE_HAS_TID_T) && !defined (ACE_HAS_SETKIND_NP) && !defined (ACE_HAS_PTHREAD_EQUAL) return t1 == t2; // I hope these aren't structs! #elif defined (pthread_equal) // If it's a macro we can't say "::pthread_equal"... @@ -2974,9 +2969,9 @@ ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) #if defined (ACE_HAS_STHREADS) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); #elif defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) -#if !defined (ACE_HAS_FSU_PTHREADS) && !defined (ACE_HAS_SETKIND_NP) +#if !defined (ACE_HAS_FSU_PTHREADS) && !defined (ACE_HAS_SETKIND_NP) && !defined (ACE_HAS_PTHREAD_GETSPECIFIC_DATAPTR) *data = ::pthread_getspecific (key); -#elif !defined (ACE_HAS_FSU_PTHREADS) && defined (ACE_HAS_SETKIND_NP) +#elif !defined (ACE_HAS_FSU_PTHREADS) && defined (ACE_HAS_SETKIND_NP) || defined (ACE_HAS_PTHREAD_GETSPECIFIC_DATAPTR) ::pthread_getspecific (key, data); #else /* ACE_HAS_FSU_PTHREADS */ // Is this really used anywhere? @@ -3157,7 +3152,7 @@ ACE_OS::sigwait (sigset_t *set, int *sig) ace_result_), int, -1); #elif defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) -#if defined (ACE_HAS_SETKIND_NP) +#if defined (ACE_HAS_SETKIND_NP) || defined (ACE_HAS_ONEARG_SIGWAIT) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigwait (set), ace_result_), int, -1); @@ -3271,8 +3266,11 @@ ACE_OS::thr_min_stack (void) #elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_HAS_SETKIND_NP) #if defined (ACE_HAS_IRIX62_THREADS) return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN); -#else +#if defined (PTHREAD_STACK_MIN) return PTHREAD_STACK_MIN; +#else + ACE_NOTSUP_RETURN (0); +#endif /* PTHREAD_STACK_MIN */ #endif /* ACE_HAS_IRIX62_THREADS */ #elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_HAS_SETKIND_NP) ACE_NOTSUP_RETURN (0); diff --git a/ace/Profile_Timer.cpp b/ace/Profile_Timer.cpp index 406623c37df..b8c5aba3e00 100644 --- a/ace/Profile_Timer.cpp +++ b/ace/Profile_Timer.cpp @@ -130,7 +130,7 @@ void ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage) { ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage"); -#if !defined (ACE_WIN32) +#if !defined (ACE_WIN32) && !defined (ACE_HAS_LIMITED_RUSAGE_T) // integral shared memory size usage.ru_ixrss = this->end_usage_.ru_ixrss - this->last_usage_.ru_ixrss; // integral unshared data " diff --git a/ace/README b/ace/README index a4d5eb6ebbe..d0e1010906c 100644 --- a/ace/README +++ b/ace/README @@ -57,8 +57,6 @@ ACE_HAS_POSIX_TIME Platform supports the POSIX timespec_t type ACE_HAS_PROC_FS Platform supports the /proc file system and defines tid_t in <sys/procfs.h> ACE_HAS_PRUSAGE_T Platform supports the prusage_t struct ACE_HAS_PTHREADS Platform supports POSIX Pthreads -ACE_HAS_PTHREAD_ATTR_INIT Platform requires pthread_*attr_init() rather than pthread_*attr_create() -ACE_HAS_PTHREAD_ATTR_DESTROY Platform requires pthread_*attr_destroy() rather than pthread_*attr_delete() ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP Platform has pthread_condattr_setkind_np(). ACE_HAS_PTHREAD_DSTATE_PTR pthread_attr_setdetachstate() takes pointer to 2nd arg. ACE_HAS_PTHREAD_EQUAL Platform has pthread_equal(). @@ -109,6 +107,7 @@ ACE_HAS_TEMPLATE_TYPEDEFS Compiler implements templates that support typedefs i ACE_HAS_TERM_IOCTLS Platform has terminal ioctl flags like TCGETS and TCSETS. ACE_HAS_THREADS Platform supports threads ACE_HAS_THREAD_SPECIFIC_STORAGE Compiler/platform has thread-specific storage +ACE_HAS_THR_C_FUNC The pthread_create() routine *must* take extern C functions. ACE_HAS_TID_T Platform supports the tid_t type (e.g., AIX) ACE_HAS_TIMEZONE_GETTIMEOFDAY Platform/compiler supports timezone * as second parameter to gettimeofday() ACE_HAS_TIMOD_H Platform supports TLI timod STREAMS module @@ -142,6 +141,7 @@ ACE_LACKS_RPC_H Platform lacks the ONC RPC header files. ACE_LACKS_SBRK Platform lacks a working sbrk() (e.g., Win32 and VxWorks) ACE_LACKS_SEMBUF_T Platform lacks struct sembuf (e.g., Win32 and VxWorks) ACE_LACKS_SETDETACH Platform lacks pthread_attr_setdetachstate() (e.g., HP/UX 10.x) +ACE_LACKS_SETSCHED Platform lacks pthread_attr_setsched() (e.g. MVS) ACE_LACKS_KEYDELETE Platform lacks TSS keydelete (e.g., HP/UX) ACE_LACKS_SENDMSG Platform lacks sendmsg() (e.g., Linux) ACE_LACKS_SI_ADDR Platform lacks the si_addr field of siginfo_t (e.g., VxWorks and HP/UX 10.x) diff --git a/ace/Task.cpp b/ace/Task.cpp index 55be9be4754..1743ebd2fe8 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -184,7 +184,7 @@ ACE_Task_Base::activate (long flags, this->thr_mgr_ = ACE_Service_Config::thr_mgr (); this->grp_id_ = this->thr_mgr_->spawn_n (n_threads, - ACE_THR_FUNC (&ACE_Task_Base::svc_run), + &ACE_Task_Base::svc_run, (void *) this, flags, priority, @@ -213,9 +213,11 @@ ACE_Task_Base::activate (long flags, // is executing it will do an ACE_Thread::exit() first! void * -ACE_Task_Base::svc_run (ACE_Task_Base *t) +ACE_Task_Base::svc_run (void *args) { - ACE_TRACE ("ACE_Task_Base::svc_run"); + ACE_TRACE ("ace_svc_run"); + + ACE_Task_Base *t = (ACE_Task_Base *) args; // Obtain our thread-specific exit hook and make sure that it knows // how to clean us up! diff --git a/ace/Task.h b/ace/Task.h index 536912c9045..ebb0911c6e1 100644 --- a/ace/Task.h +++ b/ace/Task.h @@ -105,9 +105,6 @@ public: void thr_mgr (ACE_Thread_Manager *); // Set the thread manager associated with this Task. - static void *svc_run (ACE_Task_Base *); - // Routine that runs the service routine as a daemon thread. - int is_reader (void); // True if queue is a reader, else false. @@ -122,6 +119,9 @@ public: // Atomically decrement the thread count by 1. This should only be // called by the <ACE_Task_Exit> class destructor. + // Routine that runs the service routine as a daemon thread. + void *svc_run (void *); + // = Internal data (should be private...). // private: diff --git a/ace/config-mvs.h b/ace/config-mvs.h new file mode 100644 index 00000000000..d9f7577c58a --- /dev/null +++ b/ace/config-mvs.h @@ -0,0 +1,177 @@ +// The following configuration file is designed to work for MVS with +// OpenEdition. + +#if !defined (ACE_CONFIG_H) +#define ACE_CONFIG_H + +// The following #defines are hacks to get around things +// that seem to be missing or different in MVS land +#define MAXPATHLEN 1024 // sys/param.h not on MVS +#define NSIG 44 // missing from Signal.h +#define MAXHOSTNAMELEN 256 // missing form netdb.h +#define howmany __howmany // MVS uses different names than most others +#define fd_mask __fd_mask +#define MAXNAMLEN __DIR_NAME_MAX + +// Compiler/platform uses macro for ctime +#define ACE_HAS_BROKEN_CTIME + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler supports the getrusage() system call +#define ACE_HAS_GETRUSAGE + +// The pthread_create() routine *must* take extern C functions. +#define ACE_HAS_THR_C_FUNC + +// The rusage_t structure has only two fields +#define ACE_HAS_LIMITED_RUSAGE_T + +// Platform supports IP MULTICAST +#define ACE_HAS_MULTICAST + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// sigwait() takes on argument +#define ACE_HAS_ONEARG_SIGWAIT + +// Compiler/platform supports poll(). +#define ACE_HAS_POLL + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Platform supports POSIX timers via timestruc_t. +#define ACE_HAS_POSIX_TIME + +// Platform supports POSIX threads +#define ACE_HAS_PTHREADS + +// Platform has pthread_condattr_setkind_np() +#define ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP + +// Platform has pthread_mutexattr_setkind_np() +#define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP + +// Platform has pthread_equal() +#define ACE_HAS_PTHREAD_EQUAL + +// Platform has struct pthread_t +#define ACE_HAS_PTHREAD_T + +// pthread_getspecific() takes a data pointer for 2nd argument +#define ACE_HAS_PTHREAD_GETSPECIFIC_DATAPTR + +// pthread_attr_setdetachstate() takes pointer to 2nd arg +#define ACE_HAS_PTHREAD_DSTATE_PTR + +// Platform has sigwait prototype +#define ACE_HAS_SIGWAIT + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler has siginfo_t typedef +#define ACE_HAS_SIGINFO_T + +// Platform supports inet_addr len field. +#define ACE_HAS_SIN_LEN + +// Compiler uses size_t rather than in for socket lenghts +#define ACE_HAS_SIZET_SOCKET_LEN + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Platform has strings.h +#define ACE_HAS_STRINGS + +// Platform supports System V IPC +#define ACE_HAS_SYSV_IPC + +// Compiler implements templates that support typedefs inside +// of classes used as formal arguments +//#define ACE_HAS_TEMPLATE_TYPEDEFS + +// Platform/compiler supports timezone * as second parameter to gettimeofday() +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// Platform supports threads +#define ACE_HAS_THREADS + +// Platform/compiler has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Platform has the sid_t type +#define ACE_HAS_TID_T + +// Platform has utime.h +#define ACE_HAS_UTIME + +// Platform uses void * arg 1 for mmap() +#define ACE_HAS_VOIDPTR_MMAP + +// Platform uses void * arg 4 for setsockopt() +#define ACE_HAS_VOIDPTR_SOCKOPT + +// Platform requrires pthread_yield() to take a NULL +#define ACE_HAS_YIELD_VOID_PTR + +// Platform doesn't have pthread_condattr_setpshared() +#define ACE_LACKS_CONDATTR_PSHARED + +// Platform doesn't have pthread_key_delete() +#define ACE_LACKS_KEYDELETE + +// Platform doesn't have madvise() +#define ACE_LACKS_MADVISE + +// Platform doesn't have malloc.h +#define ACE_LACKS_MALLOC_H + +// Platform doesn't have struct msgbuf_t +#define ACE_LACKS_MSGBUF_T + +// Platform doesn't have <sys/param.h> +#define ACE_LACKS_PARAM_H + +// Platform doesn't have pthread_setsched() and friends. +#define ACE_LACKS_SETSCHED + +// Compiler doesn't have <siginfo.h> +#define ACE_LACKS_SIGINFO_H + +// Platform doesn't define struct strrecvfd +#define ACE_LACKS_STRRECVFD + +// Platform doesn't have pthread_attr_setscope() +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +// Platform doesn't have pthread_attr_setstackaddr() +#define ACE_LACKS_THREAD_STACK_ADDR + +// Compiler doesn't have <ucontext.h> +#define ACE_LACKS_UCONTEXT_H + +// Compile using multi-threaded libraries +#define ACE_MT_SAFE + +// <time.h> doesn't automatically #include <sys/time.h> +#define ACE_NEEDS_SYSTIME_H + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +#if !defined (ACE_NTRACE) +#define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +#endif /* ACE_CONFIG_H */ diff --git a/examples/Threads/test_task_three.cpp b/examples/Threads/test_task_three.cpp index 8224bf2d868..a49094525c4 100644 --- a/examples/Threads/test_task_three.cpp +++ b/examples/Threads/test_task_three.cpp @@ -136,7 +136,7 @@ Test_Task::handle_input (ACE_HANDLE) return -1; } -void * +static void * dispatch (void *arg) { // every thread must register the same stream to write to file @@ -188,7 +188,7 @@ main (int argc, char **argv) Test_Task t1[TASK_COUNT]; Test_Task t2[TASK_COUNT]; - ACE_Thread::spawn (dispatch, reactor2); + ACE_Thread::spawn (ACE_THR_FUNC (dispatch), reactor2); reactor1->owner (ACE_OS::thr_self ()); diff --git a/examples/Threads/test_tss2.cpp b/examples/Threads/test_tss2.cpp index 0cdbc7fe029..2ce269e71f7 100644 --- a/examples/Threads/test_tss2.cpp +++ b/examples/Threads/test_tss2.cpp @@ -33,7 +33,7 @@ public: ~TSS_Obj (void); private: - static int count_; + static int count_; static ACE_Thread_Mutex lock_; }; @@ -65,8 +65,7 @@ public: int open (void *arg); - static void* svc (void *arg); - + void *svc (void *arg); static int wait_count_; static int max_count_; @@ -105,17 +104,8 @@ Test_Task::~Test_Task (void) wait_count_--; } -int Test_Task::open (void *arg) -{ - - ACE_Thread::spawn (Test_Task::svc, arg); - - return 0; -} - - -void * -Test_Task::svc (void *arg) +int +Test_Task::svc (void *) { ACE_TSS<TSS_Obj> tss (new TSS_Obj); @@ -155,6 +145,14 @@ Test_Task::svc (void *arg) } int +Test_Task::open (void *arg) +{ + ACE_Thread::spawn (Task_Task::svc, arg); + + return 0; +} + +int main (int argc, char **argv) { if (argc != 2) diff --git a/include/makeinclude/rules.local.GNU b/include/makeinclude/rules.local.GNU index 67c9dad95db..3a66ef68b1c 100644 --- a/include/makeinclude/rules.local.GNU +++ b/include/makeinclude/rules.local.GNU @@ -36,9 +36,11 @@ build.local: $(BUILD) $(VDIR)%.o: %.c $(COMPILE.c) -o $@ $< + ${MVCMD} $(VDIR)%.o: %.cpp $(COMPILE.cc) -o $@ $< + ${MVCMD} #$(VDIR)%.o: %.C # $(COMPILE.cc) -o $@ $< diff --git a/netsvcs/clients/Tokens/collection/collection.cpp b/netsvcs/clients/Tokens/collection/collection.cpp index a280f98cd20..5809d8e5649 100644 --- a/netsvcs/clients/Tokens/collection/collection.cpp +++ b/netsvcs/clients/Tokens/collection/collection.cpp @@ -129,12 +129,6 @@ parse_args (int argc, char *argv[]) return 0; } -#if defined (ACE_HAS_PTHREADS) -#define SUSPEND 0 -#else -#define SUSPEND THR_SUSPENDED -#endif - int main (int argc, char* argv[]) { @@ -185,15 +179,15 @@ main (int argc, char* argv[]) ACE_Thread_Manager *mgr = ACE_Service_Config::thr_mgr (); if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAR, THR_BOUND | SUSPEND) == -1) + (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1); if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAW, THR_BOUND | SUSPEND) == -1) + (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1); if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionBR, THR_BOUND | SUSPEND) == -1) + (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1); #if ! defined (ACE_HAS_PTHREADS) diff --git a/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp b/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp index 1e6f30f0982..625ccf7f9ab 100644 --- a/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp +++ b/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp @@ -216,7 +216,8 @@ mutex_test (void) { ACE_Thread_Manager thr_mgr; - Two_Tokens one (&thr_mgr), two (&thr_mgr); + Two_Tokens one (&thr_mgr); + Two_Tokens two (&thr_mgr); if (remote_mutexes == 0) { @@ -252,7 +253,7 @@ mutex_test (void) return 0; } -int +static int rwlock_test (void) { ACE_Thread_Manager thr_mgr; diff --git a/tests/Mutex_Test.cpp b/tests/Mutex_Test.cpp index 9846a495c52..931bf7a9650 100644 --- a/tests/Mutex_Test.cpp +++ b/tests/Mutex_Test.cpp @@ -23,9 +23,10 @@ #include "ace/Thread_Manager.h" #include "test_config.h" -static void -test (ACE_Process_Mutex *pm) +static void * +test (void *args) { + ACE_Process_Mutex *pm = (ACE_Process_Mutex *) args; ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); ACE_OS::srand (ACE_OS::time (0)); diff --git a/tests/Priority_Buffer_Test.cpp b/tests/Priority_Buffer_Test.cpp index a4e1e3128cd..c7119d51651 100644 --- a/tests/Priority_Buffer_Test.cpp +++ b/tests/Priority_Buffer_Test.cpp @@ -38,8 +38,9 @@ static const long max_queue = LONG_MAX; // reading and exit. static void * -consumer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +consumer (void *args) { + ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue = (ACE_Message_Queue<ACE_MT_SYNCH>) args; u_long cur_priority = 27; int local_count = 0; @@ -82,8 +83,10 @@ consumer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) // know when to exit. static void * -producer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue) +producer (void *args) { + ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue = (ACE_Message_Queue<ACE_MT_SYNCH>) args; + // Insert thread into thr_mgr. ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; diff --git a/tests/UPIPE_SAP_Test.cpp b/tests/UPIPE_SAP_Test.cpp index 2cd62cd4b9e..b2f2cff8127 100644 --- a/tests/UPIPE_SAP_Test.cpp +++ b/tests/UPIPE_SAP_Test.cpp @@ -159,11 +159,11 @@ main (int, char *argv[]) #if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_STREAM_PIPES) || defined (ACE_WIN32)) ACE_hthread_t thr_handle_acceptor; ACE_hthread_t thr_handle_connector; - ACE_UPIPE_Acceptor acceptor (addr); + ACE_UPIPE_Acceptor acc (addr); // Spawn a acceptor thread. if (ACE_Thread::spawn (ACE_THR_FUNC (acceptor), - (void *) &acceptor, + (void *) &acc, THR_NEW_LWP | THR_DETACHED, 0, &thr_handle_acceptor) == -1) |