mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH 1/9] interface additions for the C thread implementation
Date: Sat, 6 Sep 2014 21:19:26 -0400	[thread overview]
Message-ID: <20140907011926.GY23797@brightrain.aerifal.cx> (raw)
In-Reply-To: <cb03e88ca7f717c106c0aa7283202fd2f7c7f327.1409524413.git.Jens.Gustedt@inria.fr>

On Mon, Sep 01, 2014 at 12:45:47AM +0200, Jens Gustedt wrote:
> This adds all the constant, type and function interfaces.
> 
> It makes pthread_mutex_t, mtx_t, pthread_cond_t and cnd_t different
> types.
> 
> This only works because
> 
>  - under hood the corresponding pairs of types use exactly the same
>    definition for the type
> 
>  - the types are a struct types without tag name
> 
>  - no comparison or assignment is allowed for any of these types. For
>    the POSIX types this interdiction is written in the standard. For the
>    C thread types, this is an extension that this implementation
>    imposes, but which might be integrated in a later version of the C
>    standard.

This would only matter if assignment (comparison of aggregates doesn't
even exist in C) were happening between objects of the corresponding
C11 and pthread type in the same TU, which is invalid anyway. Nothing
in the way these types are implemented precludes assignment between
objects of the same type (e.g. mtx_t and mtx_t) or assignment to the
opposite (but compatible) type from a different TU (think of
pthread_mutex_init writing to a mtx_t in the application via
assignment to the dereferenced pthread_mutex_t pointer, which would
have been a possible implementation choice for mtx_init).

BTW there's nothing in the standard to preclude assignment of mtx_t
objects or cnd_t objects that would otherwise be legal, but there's
also no reason to think you should be able to use such a copy with the
threads.h functions. POSIX explicitly spells out the fact that you
can't do this for POSIX sync objects, so if C11 doesn't do the same,
this is probably another defect you should file. Obviously it's
intended that mtx_t objects could hold handles to a system resource
_OR_ actually be the in-memory sync object, so there's no way
assignment could be expected to produce an object that well-defined
behavior.

>  - initialization is default initialization of an array of int. For the
>    POSIX types, initialization expressions are provided. For C thread
>    types the only initialization foreseen by the standard are the init
>    functions.

I didn't understand what this has to do with the choice of
implementation.

>  - any calls to standard functions use pointers, and because pointer
>    representations for struct types are the same.

The type compatibility rules would also apply to aggregates passed by
value between TUs.

Rich


  parent reply	other threads:[~2014-09-07  1:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-31 22:45 [PATCH 0/9] C thread patch series, v. 8.6 and 9.7 Jens Gustedt
2014-08-31 22:45 ` [PATCH 1/9] interface additions for the C thread implementation Jens Gustedt
2014-09-07  0:21   ` Rich Felker
2014-09-07  9:13     ` Jens Gustedt
2014-09-07 10:05       ` Alexander Monakov
2014-09-07 11:16         ` Jens Gustedt
2014-09-07 11:31           ` Alexander Monakov
2014-09-07 11:32           ` Rich Felker
2014-09-07 14:45             ` Jens Gustedt
2014-09-07 15:16               ` Rich Felker
2014-09-07 16:51                 ` Jens Gustedt
2014-09-07 16:55                   ` Rich Felker
2014-09-07  1:19   ` Rich Felker [this message]
2014-08-31 22:46 ` [PATCH 2/9] additions to src/time and some implied minor changes here and there Jens Gustedt
2014-09-06 17:44   ` Rich Felker
2014-08-31 22:46 ` [PATCH 3/9] use weak symbols for the POSIX functions that will be used by C threads Jens Gustedt
2014-09-06 18:52   ` Rich Felker
2014-08-31 22:46 ` [PATCH 4/9] add the functions for tss_t and once_flag Jens Gustedt
2014-08-31 22:46 ` [PATCH 5/9] add the functions for mtx_t Jens Gustedt
2014-09-07  1:51   ` Rich Felker
2014-09-07  1:54   ` Rich Felker
2014-08-31 22:47 ` [PATCH 6/9] add the functions for cnd_t Jens Gustedt
2014-08-31 22:47 ` [PATCH 7/9] add the thrd_xxxxxx functions Jens Gustedt
2014-09-07 14:24   ` Rich Felker
2014-09-07 14:52     ` Jens Gustedt
2014-09-07 15:17       ` Rich Felker
2014-08-31 22:47 ` [PATCH 8/9] separate pthread_create and pthread_exit in two different TU Jens Gustedt
2014-08-31 22:48 ` [PATCH 9/9] Separate pthread_create and thrd_create Jens Gustedt

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=20140907011926.GY23797@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).