Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.programming.threads > #1156
| From | Nick Bowler <nbowler@draconx.ca> |
|---|---|
| Newsgroups | comp.lang.c, comp.programming.threads |
| Subject | Re: Trivial C11 threads.h wrapper (public domain) |
| Date | 2012-10-01 19:28 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <k4cqt0$mo5$1@dont-email.me> (permalink) |
| References | (2 earlier) <5068B604.9020606@web.de> <lnwqzbryia.fsf@nuthaus.mib.org> <5068C9C3.6090502@loria.fr> <50696193.3090503@web.de> <506966CA.6080308@loria.fr> |
Cross-posted to 2 groups.
On Mon, 01 Oct 2012 11:47:54 +0200, Jens Gustedt wrote:
> Am 01.10.2012 11:25, schrieb Markus Elfring:
>>> Exactly, in particular there are some linux systems where the headers
>>> are annotated with gcc extensions that make it difficult to ignore the
>>> return of a system function.
>>
>> I would appreciate if such return value ignorance can be avoided.
>> http://stackoverflow.com/questions/12416604/failing-compilation-if-return-value-is-unused-for-a-certain-type#12416677
>
> The problem here is that this is not an interface that I/we design,
> but that this is supposed to emulate a C library interface. The
> description there is extremely concise, and in particular it doesn't
> foresee the possibility of failure of the call. (For other functions
> the standard would have some generic phrase "if you pass invalid input
> to the function the behavior is undefined".)
The standard is clear that if it does not specify the behaviour for some
particular input to a function, then the behaviour is undefined if the
program does such a thing (C11§4p2). I think the _intent_ is that the
description of mtx_destroy does not specify the behaviour if it is
passed a pointer to a mtx_t object which either
(a) has never been set by a successful call to mtx_init, or
(b) has been destroyed by a call to mtx_destroy with no subsequent
successful call to mtx_init.
and therefore the behaviour would be undefined.
On the other hand, the mutex specification appears to play fast and
loose with terminology which makes everything rather murky. For
instance (at least in the n1570 document), it does not use the word
"shall" (which has formal meaning in this standard) in its restriction
that there be no threads blocked on the mutex when calling mtx_destroy
(C11§7.26.4.1p2). It also uses the word "mutex" to refer to two
apparently different things:
(1) Objects of type mtx_t are described as "hold[ing] an identifier
for a mutex" (C11§7.26.1p4), but such objects of type mtx_t are
themselves called "mutex"es in the remainder of the section.
(2) But there is another thing called a "mutex", which is created by
mtx_init and is *not* an object of type mtx_t -- the mtx_init
assigns an identifier uniquely identifying this "mutex" to an
object of type mtx_t (which the specification also calls a
"mutex"!) Here's a gem (C11§7.26.4.2):
If the mtx_init function succeeds, it sets the mutex pointed
to by mtx to a value that identifies the newly created mutex.
Gross!
NB: I cannot find an italicised definition of mutex in the document, nor
does it appear in section 3, so I guess it's assumed that anyone reading
the document already knows exactly what it is. But given the above,
even the standard authors don't seem clear on this point. That being
said, I haven't read all of the normative references so it could
technically have a proper definition in one of those...
Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar
Trivial C11 threads.h wrapper (public domain) John Tsiombikas <nuclear@member.fsf.org> - 2012-09-27 03:38 +0000
Re: Trivial C11 threads.h wrapper (public domain) Keith Thompson <kst-u@mib.org> - 2012-09-26 20:50 -0700
Re: Trivial C11 threads.h wrapper (public domain) John Tsiombikas <nuclear@member.fsf.org> - 2012-09-27 04:15 +0000
Re: Trivial C11 threads.h wrapper (public domain) Lorenzo Beretta <lory.fulgi@infinito.it> - 2012-09-27 16:35 +0200
Re: Trivial C11 threads.h wrapper (public domain) John Tsiombikas <nuclear@member.fsf.org> - 2012-09-27 15:58 +0000
Re: Trivial C11 threads.h wrapper (public domain) Lorenzo Beretta <lory.fulgi@infinito.it> - 2012-09-27 18:27 +0200
Re: Trivial C11 threads.h wrapper (public domain) William Ahern <william@wilbur.25thandClement.com> - 2012-09-28 12:08 -0700
Re: Trivial C11 threads.h wrapper (public domain) Kaz Kylheku <kaz@kylheku.com> - 2012-09-28 19:38 +0000
Re: Trivial C11 threads.h wrapper (public domain) Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-28 15:50 -0400
Re: Trivial C11 threads.h wrapper (public domain) Lorenzo Beretta <lory.fulgi@infinito.it> - 2012-09-29 18:41 +0200
Re: Trivial C11 threads.h wrapper (public domain) Markus Elfring <Markus.Elfring@web.de> - 2012-09-27 13:45 +0200
Re: Trivial C11 threads.h wrapper (public domain) John Tsiombikas <nuclear@member.fsf.org> - 2012-09-27 16:14 +0000
Re: Trivial C11 threads.h wrapper (public domain) Markus Elfring <Markus.Elfring@web.de> - 2012-09-28 12:05 +0200
Re: Trivial C11 threads.h wrapper (public domain) Keith Thompson <kst-u@mib.org> - 2012-09-28 03:39 -0700
Re: Trivial C11 threads.h wrapper (public domain) James Kuyper <jameskuyper@verizon.net> - 2012-09-28 08:23 -0400
Re: Trivial C11 threads.h wrapper (public domain) John Tsiombikas <nuclear@member.fsf.org> - 2012-09-28 19:48 +0000
Re: Trivial C11 threads.h wrapper (public domain) Toby Douglass <a@b.com> - 2012-10-01 20:19 +0200
Re: Trivial C11 threads.h wrapper (public domain) James Kuyper <jameskuyper@verizon.net> - 2012-10-01 14:37 -0400
Re: Trivial C11 threads.h wrapper (public domain) Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-10-01 14:38 -0400
Re: Trivial C11 threads.h wrapper (public domain) Keith Thompson <kst-u@mib.org> - 2012-10-01 14:58 -0700
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-09-28 20:22 +0200
Re: Trivial C11 threads.h wrapper (public domain) Markus Elfring <Markus.Elfring@web.de> - 2012-09-30 23:13 +0200
Re: Trivial C11 threads.h wrapper (public domain) Keith Thompson <kst-u@mib.org> - 2012-09-30 14:28 -0700
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-01 00:37 +0200
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-01 00:44 +0200
Re: Trivial C11 threads.h wrapper (public domain) Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-30 19:48 -0400
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-01 08:26 +0200
Re: Trivial C11 threads.h wrapper (public domain) Markus Elfring <Markus.Elfring@web.de> - 2012-10-01 11:25 +0200
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-01 11:47 +0200
Re: Trivial C11 threads.h wrapper (public domain) Markus Elfring <Markus.Elfring@web.de> - 2012-10-01 12:05 +0200
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-01 13:15 +0200
Clarification for interface specification "C11 threads.h" Markus Elfring <Markus.Elfring@web.de> - 2012-10-03 11:02 +0200
Re: Clarification for interface specification "C11 threads.h" Keith Thompson <kst-u@mib.org> - 2012-10-03 13:29 -0700
Re: Clarification for interface specification "C11 threads.h" Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-04 13:35 +0200
Re: Clarification for interface specification "C11 threads.h" Markus Elfring <Markus.Elfring@web.de> - 2012-10-12 17:45 +0200
Re: Trivial C11 threads.h wrapper (public domain) Noob <root@127.0.0.1> - 2012-10-01 18:10 +0200
Re: Trivial C11 threads.h wrapper (public domain) Nick Bowler <nbowler@draconx.ca> - 2012-10-01 19:28 +0000
Re: Trivial C11 threads.h wrapper (public domain) Keith Thompson <kst-u@mib.org> - 2012-10-01 15:19 -0700
Re: Trivial C11 threads.h wrapper (public domain) Kaz Kylheku <kaz@kylheku.com> - 2012-10-01 23:57 +0000
Re: Trivial C11 threads.h wrapper (public domain) Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-02 14:48 +0200
csiph-web