[haiku-commits] Re: r40701 - haiku/trunk/src/system/kernel

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 26 Feb 2011 12:09:40 -0500

On Sat, Feb 26, 2011 at 10:26 AM, <korli@xxxxxxxxxxxxxxxx> wrote:

> Author: korli
> Date: 2011-02-26 16:26:47 +0100 (Sat, 26 Feb 2011)
> New Revision: 40701
> Changeset: http://dev.haiku-os.org/changeset/40701
> Ticket: http://dev.haiku-os.org/ticket/7235
>
> Modified:
>   haiku/trunk/src/system/kernel/thread.cpp
> Log:
> copy sig_action structure from the current thread if we're the same team.
> Helps with #7235
>
>
> Modified: haiku/trunk/src/system/kernel/thread.cpp
> ===================================================================
> --- haiku/trunk/src/system/kernel/thread.cpp    2011-02-26 12:45:45 UTC
> (rev 40700)
> +++ haiku/trunk/src/system/kernel/thread.cpp    2011-02-26 15:26:47 UTC
> (rev 40701)
> @@ -463,6 +463,10 @@
>
>                // stop the new thread, if desired
>                debugNewThread = debugFlags &
> B_THREAD_DEBUG_STOP_CHILD_THREADS;
> +
> +               // copy signal handlers
> +               memcpy(thread->sig_action, currentThread->sig_action,
>

In The Practice of Programming by Kernighan and Pike the authors write:

"The ANSI C Standard defines two functions: memcpy, which is fast but might
overwrite memory if source and destination overlap, and memmove, which might
be slower but will always be correct. The burden of choosing correctness
over speed should not be placed upon the programmer, there should be only
one function. Pretend there is, and always use memmove."

I don't pretend to know the differences well enough to make an informed
decision, but, if Kernighan and Pike say that you should use memmove and not
memcpy I have to imagine that they know what they are talking about.

John Scipione


> +                       sizeof(thread->sig_action));
>        }
>
>        // insert into global list
>
>
>

Other related posts: