diff options
author | Adam Mitz <mitza@ociweb.com> | 2015-03-02 13:01:41 -0600 |
---|---|---|
committer | Adam Mitz <mitza@ociweb.com> | 2015-03-02 13:01:41 -0600 |
commit | 1c912d7509d21be8cb0bf8f2eb3156c6ece385d9 (patch) | |
tree | 4a67a100998ac5565ee1c8e4237b1de8c2115059 | |
parent | 614a53d6ae063edda770c385fae7e757f73a5d8f (diff) | |
parent | 86986c5355d448bca828774a5593bf07451f2b09 (diff) | |
download | ATCD-1c912d7509d21be8cb0bf8f2eb3156c6ece385d9.tar.gz |
Merge branch 'master' of git://github.com/DOCGroup/ATCD
-rw-r--r-- | ACE/ace/OS_NS_Thread.cpp | 108 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.h | 5 | ||||
-rw-r--r-- | ACE/ace/OS_NS_signal.inl | 8 | ||||
-rw-r--r-- | ACE/ace/OS_NS_stdlib.cpp | 65 | ||||
-rw-r--r-- | ACE/ace/Stack_Trace.cpp | 30 | ||||
-rw-r--r-- | ACE/ace/config-vxworks.h | 19 |
6 files changed, 126 insertions, 109 deletions
diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp index a5bc7c4f836..b760a9a07a4 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 <char*> (*thr_name) : 0, priority, (int) flags, - (int) stacksize, + stacksize, thread_args->entry_point (), - (int) thread_args, + (ACE_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 == ACE_VX_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,10 +5132,12 @@ ACE_END_VERSIONED_NAMESPACE_DECL int spa (FUNCPTR entry, ...) { - static const unsigned int ACE_MAX_ARGS = 10; + // The called entrypoint can get the function name plus the normal 10 + // optional arguments. + static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 1 + 10; static char *argv[ACE_MAX_ARGS] = { 0 }; va_list pvar; - unsigned int argc; + ACE_VX_USR_ARG_T argc; // Hardcode a program name because the real one isn't available // through the VxWorks shell. @@ -5149,7 +5151,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 +5159,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 (ACE_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); + ACE_VX_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 () + (ACE_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 (ACE_VX_USR_ARG_T& argc, char** argv, int max_args, char* string) { char indouble = 0; size_t previous = 0; @@ -5267,10 +5273,10 @@ int spae (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static int const ACE_MAX_ARGS = 128; + static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 }; va_list pvar; - int argc = 1; + ACE_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 +5298,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); + ACE_VX_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 () + (ACE_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 +5327,10 @@ int spaef (FUNCPTR entry, ...) { static int const WINDSH_ARGS = 10; - static int const ACE_MAX_ARGS = 128; + static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 }; va_list pvar; - int argc = 1; + ACE_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 +5377,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 ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128; static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 }; - int argc = 1; + ACE_VX_USR_ARG_T argc = 1; // Peel off arguments to run_main () and put into argv. if (arg) @@ -5385,22 +5391,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 (ACE_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) + ACE_VX_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 + (ACE_VX_USR_ARG_T)entry, // entry point + argc, // first argument to main () + (ACE_VX_USR_ARG_T) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0); + + if (ret == ACE_VX_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..ce79d69198d 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 /**/ <sysLib.h> // for sysClkRateGet() +# include /**/ <types/vxTypes.h> # if !defined (__RTP__) # include /**/ <taskLib.h> # include /**/ <taskHookLib.h> @@ -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 ACE_VX_TASK_ID ACE_thread_t; +typedef ACE_VX_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..2872f27439a 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 ((ACE_VX_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..9836a0e1f8a 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, + ACE_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<unsigned int> (-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], "0x" ACE_VX_ARG_FORMAT, 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 ()); @@ -252,17 +253,6 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, const char *fnName = "(no symbols)"; static const int N_ARGS = 12; -#if (ACE_VXWORKS < 0x690) -# define ACE_VX_USR_ARG_T int -# define ACE_VX_ARG_FORMAT "%x" -#else -# define ACE_VX_USR_ARG_T _Vx_usr_arg_t -# ifdef _WRS_CONFIG_LP64 -# define ACE_VX_ARG_FORMAT "%lx" -# else -# define ACE_VX_ARG_FORMAT "%x" -# endif -#endif ACE_VX_USR_ARG_T buf[N_ARGS]; ACE_VX_USR_ARG_T *pArgs = 0; int numArgs = diff --git a/ACE/ace/config-vxworks.h b/ACE/ace/config-vxworks.h index ee4e2286c76..9d0ea65e25c 100644 --- a/ACE/ace/config-vxworks.h +++ b/ACE/ace/config-vxworks.h @@ -54,6 +54,25 @@ #error Unknown or unsupported VxWorks version #endif +// Adapt to system argument changes added at VxWorks 6.9 and 64-bit. +// It would be nicer to typedef the data types, but without including the +// applicable VxWorks headers here, that doesn't work. +#if (ACE_VXWORKS < 0x690) +# define ACE_VX_USR_ARG_T int +# define ACE_VX_TASK_ID int +# define ACE_VX_ARG_FORMAT "%x" +# define ACE_VX_TASK_ID_ERROR ERROR +#else +# define ACE_VX_USR_ARG_T _Vx_usr_arg_t +# define ACE_VX_TASK_ID TASK_ID +# ifdef _WRS_CONFIG_LP64 +# define ACE_VX_ARG_FORMAT "%lx" +# else +# define ACE_VX_ARG_FORMAT "%x" +# endif +# define ACE_VX_TASK_ID_ERROR TASK_ID_ERROR +#endif + #include /**/ "ace/post.h" #endif /* ACE_CONFIG_VXWORKS_H */ |