From 2cc51308d8f58ffb4f581a3db54cfe889961bc71 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Wed, 11 Feb 2015 16:42:51 -0500 Subject: Apply patches sent from Gordon Hulpieu --- ACE/ace/OS_NS_Thread.cpp | 104 ++++++++++++++++++++++++----------------------- ACE/ace/OS_NS_Thread.h | 5 ++- ACE/ace/OS_NS_signal.inl | 8 ++++ ACE/ace/OS_NS_stdlib.cpp | 65 +++++++++++++---------------- ACE/ace/Stack_Trace.cpp | 19 +++++---- 5 files changed, 104 insertions(+), 97 deletions(-) diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp index a5bc7c4f836..b2712110da7 100644 --- a/ACE/ace/OS_NS_Thread.cpp +++ b/ACE/ace/OS_NS_Thread.cpp @@ -4436,9 +4436,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func, tid = ::taskSpawn (thr_name && *thr_name ? const_cast (*thr_name) : 0, priority, (int) flags, - (int) stacksize, + stacksize, thread_args->entry_point (), - (int) thread_args, + (_Vx_usr_arg_t) thread_args, 0, 0, 0, 0, 0, 0, 0, 0, 0); # if 0 /* Don't support setting of stack, because it doesn't seem to work. */ } @@ -4472,7 +4472,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func, } # endif /* 0 */ - if (tid == ERROR) + if (tid == TASK_ID_ERROR) return -1; else { @@ -4560,8 +4560,8 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status) # endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ # elif defined (ACE_HAS_VXTHREADS) - ACE_thread_t tid = ACE_OS::thr_self (); - *((int *) status) = ::taskDelete (tid); + ACE_UNUSED_ARG (status); + ::taskDelete (ACE_OS::thr_self ()); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (status); @@ -5132,7 +5132,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL int spa (FUNCPTR entry, ...) { - static const unsigned int ACE_MAX_ARGS = 10; + static _Vx_usr_arg_t const ACE_MAX_ARGS = 10; static char *argv[ACE_MAX_ARGS] = { 0 }; va_list pvar; unsigned int argc; @@ -5149,7 +5149,7 @@ spa (FUNCPTR entry, ...) // number of arguments would have to be passed. va_start (pvar, entry); - for (argc = 1; argc <= ACE_MAX_ARGS; ++argc) + for (argc = 1; argc < ACE_MAX_ARGS; ++argc) { argv[argc] = va_arg (pvar, char *); @@ -5157,41 +5157,45 @@ spa (FUNCPTR entry, ...) break; } - if (argc > ACE_MAX_ARGS && argv[argc-1] != 0) + if (argc >= ACE_MAX_ARGS && argv[ACE_MAX_ARGS - 1] != 0) { - // try to read another arg, and warn user if the limit was exceeded + // Try to read another arg, and warn user if the limit was exceeded. + // + // Note that the VxWorks shell arguments change from int to long when + // using a 64bit compiler. Cast the argument up so that the format + // specifier remains correct for either build type. if (va_arg (pvar, char *) != 0) - ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n", - ACE_MAX_ARGS); + ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %ld\n", + (long)ACE_MAX_ARGS); } else { // fill unused argv slots with 0 to get rid of leftovers // from previous invocations - for (unsigned int i = argc; i <= ACE_MAX_ARGS; ++i) + for (_Vx_usr_arg_t i = argc; i < ACE_MAX_ARGS; ++i) argv[i] = 0; } // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - int const ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (int) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); + TASK_ID const ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (_Vx_usr_arg_t) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); va_end (pvar); // ::taskSpawn () returns the taskID on success: return 0 instead if // successful - return ret > 0 ? 0 : ret; + return ret > 0 ? 0 : -1; } // A helper function for the extended spa functions static void -add_to_argv (int& argc, char** argv, int max_args, char* string) +add_to_argv (_Vx_usr_arg_t& argc, char** argv, int max_args, char* string) { char indouble = 0; size_t previous = 0; @@ -5267,10 +5271,10 @@ int spae (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static int const ACE_MAX_ARGS = 128; + static _Vx_usr_arg_t const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; va_list pvar; - int argc = 1; + _Vx_usr_arg_t argc = 1; // Peel off arguments to spa () and put into argv. va_arg () isn't // necessarily supposed to return 0 when done, though since the @@ -5292,19 +5296,19 @@ spae (FUNCPTR entry, ...) // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - int const ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (int) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); + TASK_ID const ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (_Vx_usr_arg_t) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); va_end (pvar); // ::taskSpawn () returns the taskID on success: return 0 instead if // successful - return ret > 0 ? 0 : ret; + return ret > 0 ? 0 : -1; } // This global function can be used from the VxWorks shell to pass @@ -5321,10 +5325,10 @@ int spaef (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static int const ACE_MAX_ARGS = 128; + static _Vx_usr_arg_t const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; va_list pvar; - int argc = 1; + _Vx_usr_arg_t argc = 1; // Peel off arguments to spa () and put into argv. va_arg () isn't // necessarily supposed to return 0 when done, though since the @@ -5371,11 +5375,11 @@ _vx_call_entry(FUNCPTR entry, int argc, char* argv[]) } int -vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...) +vx_execae (FUNCPTR entry, char* arg, int prio, int opt, size_t stacksz, ...) { - static int const ACE_MAX_ARGS = 128; + static _Vx_usr_arg_t const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast ("ace_main"), 0 }; - int argc = 1; + _Vx_usr_arg_t argc = 1; // Peel off arguments to run_main () and put into argv. if (arg) @@ -5385,22 +5389,22 @@ vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...) // fill unused argv slots with 0 to get rid of leftovers // from previous invocations - for (int i = argc; i < ACE_MAX_ARGS; ++i) + for (_Vx_usr_arg_t i = argc; i < ACE_MAX_ARGS; ++i) argv[i] = 0; // The hard-coded options are what ::sp () uses, except for the // larger stack size (instead of ::sp ()'s 20000). - int const ret = ::taskSpawn (argv[0], // task name - prio==0 ? 100 : prio, // task priority - opt==0 ? VX_FP_TASK : opt, // task options - stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size - (FUNCPTR)_vx_call_entry, // entrypoint caller - (int)entry, // entry point - argc, // first argument to main () - (int) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0); - - if (ret == ERROR) + TASK_ID const ret = ::taskSpawn (argv[0], // task name + prio==0 ? 100 : prio, // task priority + opt==0 ? VX_FP_TASK : opt, // task options + stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size + (FUNCPTR)_vx_call_entry, // entrypoint caller + (_Vx_usr_arg_t)entry, // entry point + argc, // first argument to main () + (_Vx_usr_arg_t) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0); + + if (ret == TASK_ID_ERROR) return 255; while( ret > 0 && ::taskIdVerify (ret) != ERROR ) diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h index 42a48ee93e0..f3176c82396 100644 --- a/ACE/ace/OS_NS_Thread.h +++ b/ACE/ace/OS_NS_Thread.h @@ -160,6 +160,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL # elif defined (ACE_VXWORKS) # include /**/ // for sysClkRateGet() +# include /**/ # if !defined (__RTP__) # include /**/ # include /**/ @@ -228,8 +229,8 @@ typedef struct char *name_; } ACE_sema_t; # endif /* !ACE_HAS_POSIX_SEM */ -typedef int ACE_thread_t; -typedef int ACE_hthread_t; +typedef TASK_ID ACE_thread_t; +typedef TASK_ID ACE_hthread_t; // Key type: the ACE TSS emulation requires the key type be unsigned, // for efficiency. (Current POSIX and Solaris TSS implementations also // use u_int, so the ACE TSS emulation is compatible with them.) diff --git a/ACE/ace/OS_NS_signal.inl b/ACE/ace/OS_NS_signal.inl index 562d2701f33..087dbbf25da 100644 --- a/ACE/ace/OS_NS_signal.inl +++ b/ACE/ace/OS_NS_signal.inl @@ -15,6 +15,14 @@ kill (pid_t pid, int signum) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_VXWORKS) + /* + * The VxWorks kill interface is not really POSIX + * since they use a task id in place of a pid type. + * This only becomes an issue when using the 64bit compiler + * as the TASK_ID is no longer defined as an int. + */ + ACE_OSCALL_RETURN (::kill ((TASK_ID)pid, signum), int, -1); #else ACE_OSCALL_RETURN (::kill (pid, signum), int, -1); #endif /* ACE_LACKS_KILL */ diff --git a/ACE/ace/OS_NS_stdlib.cpp b/ACE/ace/OS_NS_stdlib.cpp index 0d8fd91ac7a..3526b9f74d6 100644 --- a/ACE/ace/OS_NS_stdlib.cpp +++ b/ACE/ace/OS_NS_stdlib.cpp @@ -283,47 +283,40 @@ ACE_OS::mktemp (ACE_TCHAR *s) if (s == 0) // check for null template string failed! return 0; - else - { - ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX")); - if (xxxxxx == 0) - // the template string doesn't contain "XXXXXX"! - return s; - else + ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX")); + if (xxxxxx == 0) + // the template string doesn't contain "XXXXXX"! + return s; + + // Find an unused filename for this process. It is assumed + // that the user will open the file immediately after + // getting this filename back (so, yes, there is a race + // condition if multiple threads in a process use the same + // template). This appears to match the behavior of the + // SunOS 5.5 mktemp(). + bool found = false; + for (ACE_TCHAR letter = ACE_TEXT ('a'); + letter <= ACE_TEXT ('z'); + ++letter) + { + ACE_stat sb; + ACE_OS::sprintf (xxxxxx, + ACE_TEXT ("%05d%c"), + (int)ACE_OS::getpid () % 100000, + letter); + if (ACE_OS::stat (s, &sb) < 0) { - ACE_TCHAR unique_letter = ACE_TEXT ('a'); - ACE_stat sb; - - // Find an unused filename for this process. It is assumed - // that the user will open the file immediately after - // getting this filename back (so, yes, there is a race - // condition if multiple threads in a process use the same - // template). This appears to match the behavior of the - // SunOS 5.5 mktemp(). - ACE_OS::sprintf (xxxxxx, - ACE_TEXT ("%05d%c"), - ACE_OS::getpid (), - unique_letter); - while (ACE_OS::stat (s, &sb) >= 0) - { - if (++unique_letter <= ACE_TEXT ('z')) - ACE_OS::sprintf (xxxxxx, - ACE_TEXT ("%05d%c"), - ACE_OS::getpid (), - unique_letter); - else - { - // maximum of 26 unique files per template, per process - ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT ("")); - return s; - } - } + found = true; + break; } - return s; } + if (!found) + // maximum of 26 unique files per template, per process + ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT ("")); + return s; } -#endif /* ACE_LACKS_MKTEMP &7 !ACE_DISABLE_MKTEMP */ +#endif /* ACE_LACKS_MKTEMP && !ACE_DISABLE_MKTEMP */ void * ACE_OS::realloc (void *ptr, size_t nbytes) diff --git a/ACE/ace/Stack_Trace.cpp b/ACE/ace/Stack_Trace.cpp index 582941a7b4b..f746c9041f8 100644 --- a/ACE/ace/Stack_Trace.cpp +++ b/ACE/ace/Stack_Trace.cpp @@ -123,9 +123,9 @@ static ACE_Stack_Trace_stackstate* ACE_Stack_Trace_stateptr = 0; static void ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller, - unsigned int func, - unsigned int nargs, - unsigned int *args) + INSTR *func, + int nargs, + _Vx_usr_arg_t *args) { if (ACE_Stack_Trace_stateptr == 0) return; @@ -143,20 +143,21 @@ ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller, // These are references so that the structure gets updated // in the code below. char*& buf = stackstate->buf; - unsigned int& len = stackstate->buflen; + size_t& len = stackstate->buflen; // At some point try using symFindByValue() to lookup func (and caller?) // to print out symbols rather than simply addresses. // VxWorks can pass -1 for "nargs" if there was an error - if (nargs == static_cast (-1)) nargs = 0; + if (nargs == -1) + nargs = 0; - len += ACE_OS::sprintf (&buf[len], "%#10x: %#10x (", (int)caller, func); - for (unsigned int i = 0; i < nargs; ++i) + len += ACE_OS::sprintf (&buf[len], "%p: %p (", caller, func); + for (int i = 0; i < nargs; ++i) { if (i != 0) len += ACE_OS::sprintf (&buf[len], ", "); - len += ACE_OS::sprintf(&buf [len], "%#x", args [i]); + len += ACE_OS::sprintf(&buf [len], "%#lx", (long)args [i]); } len += ACE_OS::sprintf(&buf[len], ")\n"); @@ -180,7 +181,7 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, REG_SET regs; - taskRegsGet ((int)taskIdSelf(), ®s); + taskRegsGet (taskIdSelf(), ®s); // Maybe we should take a lock here to guard stateptr? ACE_Stack_Trace_stateptr = &state; trcStack (®s, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ()); -- cgit v1.2.1