Web lists-archives.com

Re: [Mingw-users] GCC-4.9.3 is now our current release




Hello Ralph!

On Thu, Mar 17, 2016 at 1:37 AM, ralph engels <ralphengels@xxxxxxxxx> wrote:
> Final patch :) everything works now.
> ...
> +#ifdef PTW32_VERSION
> +    thread_id = (objc_thread_t) new_thread_handle.p;

Yes, this is basically what your previous version was doing.

   thread_id = *(objc_thread_t *) &new_thread_handle; /* fails with
      pthreads-w32, cannot convert to a pointer type, changed a bit so now it
      should */

First you get a pointer to new_thread_handle (pointer to struct), then
you cast it to (objc_thread_t *) (where I assume that objc_thread_t
itself resolves to a pointer).  This is presumably "undefined behavior"
(or maybe just becomes undefined behavior when the pointer is
dereferenced ...), but we do this sort of thing all the time.  Then you
dereference the pointer.  With luck, you hopefully end up setting
thread_id to new_thread_handle.p, presumably a pointer to a native
thread.  Maybe this is okay.

But doing it more explicitly, as you do with:

   thread_id = (objc_thread_t) new_thread_handle.p;

is just better, and (potentially) avoids undefined behavior (depending
on what the types of objc_thread_t and new_thread_handle.p turn
out to be).

I'm still a little nervous about this.  The pthreads-win32 people put
the x data member into pthread_t for some reason.  I can't see why
that would naturally be part of the thread id / thread handle, but that's
what they did, so one might worry that you don't have a fully proper
thread handle for objc_threat_t.

Anyway, I don't know anything about objective-c, so I'm speaking
beyond my competence.

> ...
> Thanks for the assistance, im not all to well versed in C++ syntax so
> that one would have taken me a while.

Thanks to you for sorting this all out for mingw!

> Cheers ill start gathering up the patches and ship them to Keith, i
> guess he will be majorly pleased ;)


Best regards.


K. Frank

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe