Cygwin C11 threads Implementation

Corinna Vinschen vinschen@redhat.com
Thu Apr 18 08:29:00 GMT 2019


On Apr 17 17:16, Joel Sherrill wrote:
> Hi
> 
> In looking at the C11 threads.h header to see how Cygwin defined thrd_t in
> comparison to RTEMS, I noticed that at least in the version of Cygwin I
> have installed, machine/threads.h
> is missing and there is no typedef for thrd_t in /usr/include.
> 
> RTEMS uses the FreeBSD implementation of these services and I would think
> Cygwin
> could also.
> 
> Is this functionality missing or am I missing something?

I'm not exactly familiar with this C11 stuff, but, yes, seems like this
functionality is missing.

I'm not sure if we can use the FreeBSD implementation, given how our
pthreads implementation differs, e.g., all pthread related types are
pointers to an opaque struct, but it's certainly worth a try.  At a
first glance, our machine/_threads.h would have to look like this:

--- SNIP ---
/* pthread_cond_t */
typedef void *cnd_t;

/* pthread_mutex_t */
typedef void *mtx_t;

/* pthread_t */
typedef void *thrd_t;

/* pthread_key_t */
typedef void *tss_t;

/* pthread_once_t */
typedef struct
{
  mtx_t mutex;
  int _flag;
} once_flag;

/* PTHREAD_ONCE_INIT */
#define ONCE_FLAG_INIT { 0 }

/* PTHREAD_DESTRUCTOR_ITERATIONS */
#define TSS_DTOR_ITERATIONS 1
--- SNAP ---

I guess the cnd_t/mtx_t definitions would make some problems
with the FreeBSD implementation?


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20190418/a4f30d3b/attachment.sig>


More information about the Newlib mailing list