summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcorino <mcorino@users.noreply.github.com>2005-04-11 11:45:21 +0000
committermcorino <mcorino@users.noreply.github.com>2005-04-11 11:45:21 +0000
commitcae97fdef47205d8ad0e3e05e192c61f6e389ef4 (patch)
treecefac58ca5934552f0a56483f0c68e145c07c9dd
parent408a891ba4b8b92415cdc1748d3f76d1f4e45971 (diff)
downloadATCD-cae97fdef47205d8ad0e3e05e192c61f6e389ef4.tar.gz
ChangeLogTag: Mon Apr 11 11:38:12 UTC 2005 Martin Corino <mcorino@remedy.nl>
-rw-r--r--ChangeLog6
-rw-r--r--ace/OS_NS_Thread.cpp54
2 files changed, 60 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d0b85e7bb07..a1ef341b922 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Apr 11 11:38:12 UTC 2005 Martin Corino <mcorino@remedy.nl>
+
+ * ace/OS_NS_Thread.cpp:
+ Added new "C" function 'vx_execae' for VxWorks builds.
+ Used to run VxWorks tasks (tests) in a more controlled, synchronous way.
+
Mon Apr 11 11:27:12 UTC 2005 Martin Corino <mcorino@remedy.nl>
* ace/config-g++-common.h:
diff --git a/ace/OS_NS_Thread.cpp b/ace/OS_NS_Thread.cpp
index 9d13ad66cf0..843a97352ab 100644
--- a/ace/OS_NS_Thread.cpp
+++ b/ace/OS_NS_Thread.cpp
@@ -3964,6 +3964,60 @@ spaef (FUNCPTR entry, ...)
// Return the return value of the invoked ace_main routine.
return ret;
}
+
+// This global function can be used from the VxWorks shell to pass
+// arguments to and run a main () function (i.e. ace_main).
+//
+// usage: -> vx_execae ace_main, "arg1 arg2 \"arg3 with spaces\"", [prio, [opt, [stacksz]]]
+//
+// All arguments must be within double quotes, even numbers.
+// This routine spawns the main () function in a separate task and waits till the
+// task has finished.
+static int _vx_call_rc = 0;
+
+static int
+_vx_call_entry(FUNCPTR entry, int argc, char* argv[])
+{
+ _vx_call_rc = entry (argc, argv);
+ return _vx_call_rc;
+}
+
+int
+vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
+{
+ static const int MAX_ARGS = 128;
+ static char* argv[MAX_ARGS] = { "ace_main", 0 };
+ int argc = 1;
+
+ // Peel off arguments to run_main () and put into argv.
+
+ if (arg)
+ add_to_argv(argc, argv, MAX_ARGS, arg);
+
+ // fill unused argv slots with 0 to get rid of leftovers
+ // from previous invocations
+ for (int i = argc; i < 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).
+ const int 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);
+
+ while( ret > 0 && ::taskIdVerify (ret) != ERROR )
+ ::taskDelay (3 * ::sysClkRateGet ());
+
+ // ::taskSpawn () returns the taskID on success: return _vx_call_rc instead if
+ // successful
+ return ret > 0 ? _vx_call_rc : 255;
+}
#endif /* VXWORKS */
#if defined (__DGUX) && defined (ACE_HAS_THREADS) && defined (_POSIX4A_DRAFT10_SOURCE)