add args with ptid and ctid in ltp_clone().

Signed-off-by: Zeng Linggang <[email protected]>
---
 include/test.h |  2 +-
 lib/cloner.c   | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/test.h b/include/test.h
index 94fc721..ffc1c8c 100644
--- a/include/test.h
+++ b/include/test.h
@@ -200,7 +200,7 @@ int self_exec(char *argv0, char *fmt, ...);
 
 /* Functions from lib/cloner.c */
 int ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg,
-               size_t stack_size, void *stack);
+               size_t stack_size, void *stack, ...);
 int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
                void *arg, size_t stacksize);
 int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
diff --git a/lib/cloner.c b/lib/cloner.c
index a68ff1e..93e3f8c 100644
--- a/lib/cloner.c
+++ b/lib/cloner.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sched.h>
+#include <stdarg.h>
 #include "test.h"
 
 #undef clone                   /* we want to use clone() */
@@ -50,20 +51,31 @@ extern int __clone2(int (*fn) (void *arg), void 
*child_stack_base,
  */
 int
 ltp_clone(unsigned long clone_flags, int (*fn) (void *arg), void *arg,
-         size_t stack_size, void *stack)
+         size_t stack_size, void *stack, ...)
 {
        int ret;
+       pid_t *parent_tid, *child_tid;
+       void *tls;
+       va_list arg_clone;
+
+       va_start(arg_clone, stack);
+       parent_tid = va_arg(arg_clone, pid_t *);
+       tls = va_arg(arg_clone, void *);
+       child_tid = va_arg(arg_clone, pid_t *);
+       va_end(arg_clone);
 
 #if defined(__hppa__) || defined(__metag__)
-       ret = clone(fn, stack, clone_flags, arg);
+       ret = clone(fn, stack, clone_flags, arg, parent_tid, tls, child_tid);
 #elif defined(__ia64__)
-       ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, NULL);
+       ret = clone2(fn, stack, stack_size, clone_flags, arg,
+                    parent_tid, tls, child_tid);
 #else
        /*
         * For archs where stack grows downwards, stack points to the topmost
         * address of the memory space set up for the child stack.
         */
-       ret = clone(fn, (stack ? stack + stack_size : NULL), clone_flags, arg);
+       ret = clone(fn, (stack ? stack + stack_size : NULL), clone_flags, arg,
+                   parent_tid, tls, child_tid);
 #endif
 
        return ret;
-- 
1.8.2.1




------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to