From: Junio C Hamano <gitster@pobox.com>
To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH] builtin/index-pack.c: Fix some pthread_t misuse
Date: Wed, 07 Mar 2012 11:15:00 -0800 [thread overview]
Message-ID: <7vvcmgmde3.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4F57B04F.6050307@ramsay1.demon.co.uk> (Ramsay Jones's message of "Wed, 07 Mar 2012 19:00:31 +0000")
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> However, pthread_t is intended to be an opaque (implementation defined)
> type. For example, an implementation may choose to use a structure to
> implement the type. Therefore, assigning zero (or any other constant)
> to a pthread_t is not supported in general.
> ...
> Note that, for the same reason given above, you can not, in general,
> directly compare pthread_t handles with the built-in equality operator.
> In order to compare pthread_t's for equality, the POSIX standard requires
> the use of pthread_equal().
Thanks, the above analysis all sound sensible.
I do not think it matters in *this* case, but if a loop iterates
over an array of things with a field of type pthread_t in it, whose
element may or may not be valid, and wants to mark the validity of
an element with the value of its pthread_t field, what is the proper
way to do so? I.e.
for (i = 0; i < ARRAY_SIZE(thread_data); i++) {
if (pthread_invalid(thread_data[i].thread)
continue; /* not used */
if (!pthread_equal(self, thread_data[i].thread))
continue; /* not me */
/* ah, this is mine! */
...
}
Perhaps the answer is "Don't do it" and that is perfectly fine, but
does Nguyen's code rely on the final clean-up (assignment with 0 you
are removing with this patch) to mark that these elements are no
longer relevant?
next prev parent reply other threads:[~2012-03-07 19:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 19:00 [PATCH] builtin/index-pack.c: Fix some pthread_t misuse Ramsay Jones
2012-03-07 19:15 ` Junio C Hamano [this message]
2012-03-08 1:29 ` Nguyen Thai Ngoc Duy
2012-03-10 21:20 ` Ramsay Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vvcmgmde3.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=ramsay@ramsay1.demon.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).