]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DRD: Allocate thread arguments again on the stack.
authorBart Van Assche <bvanassche@acm.org>
Sat, 12 Mar 2011 11:01:06 +0000 (11:01 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 12 Mar 2011 11:01:06 +0000 (11:01 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11630

drd/drd_pthread_intercepts.c

index 6b0b3fe41e98ecfa5d38637c2452f01733125346..f3ca791c643534880fef832f53e34f47b45b047f 100644 (file)
@@ -380,49 +380,36 @@ int pthread_create_intercept(pthread_t* thread, const pthread_attr_t* attr,
    int    res;
    int    ret;
    OrigFn fn;
-#if defined(ALLOCATE_THREAD_ARGS_ON_THE_STACK)
    DrdPosixThreadArgs thread_args;
-#endif
-   DrdPosixThreadArgs* thread_args_p;
 
    VALGRIND_GET_ORIG_FN(fn);
 
-#if defined(ALLOCATE_THREAD_ARGS_ON_THE_STACK)
-   thread_args_p = &thread_args;
-#else
-   thread_args_p = malloc(sizeof(*thread_args_p));
-#endif
-   assert(thread_args_p);
-
-   thread_args_p->start           = start;
-   thread_args_p->arg             = arg;
-   DRD_IGNORE_VAR(thread_args_p->wrapper_started);
-   thread_args_p->wrapper_started = 0;
+   thread_args.start           = start;
+   thread_args.arg             = arg;
+   DRD_IGNORE_VAR(thread_args.wrapper_started);
+   thread_args.wrapper_started = 0;
    /*
     * Find out whether the thread will be started as a joinable thread
     * or as a detached thread. If no thread attributes have been specified,
     * this means that the new thread will be started as a joinable thread.
     */
-   thread_args_p->detachstate = PTHREAD_CREATE_JOINABLE;
+   thread_args.detachstate = PTHREAD_CREATE_JOINABLE;
    if (attr)
    {
-      if (pthread_attr_getdetachstate(attr, &thread_args_p->detachstate) != 0)
-      {
+      if (pthread_attr_getdetachstate(attr, &thread_args.detachstate) != 0)
          assert(0);
-      }
    }
-   assert(thread_args_p->detachstate == PTHREAD_CREATE_JOINABLE
-          || thread_args_p->detachstate == PTHREAD_CREATE_DETACHED);
-
+   assert(thread_args.detachstate == PTHREAD_CREATE_JOINABLE
+          || thread_args.detachstate == PTHREAD_CREATE_DETACHED);
 
    DRD_(entering_pthread_create)();
-   CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), thread_args_p);
+   CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), &thread_args);
    DRD_(left_pthread_create)();
 
    if (ret == 0)
    {
       /* Wait until the thread wrapper started. */
-      while (! thread_args_p->wrapper_started)
+      while (!thread_args.wrapper_started)
          sched_yield();
    }