Web lists-archives.com

Re: [Mingw-users] mingw error: redefinition of 'struct timespec'




On 11/10/15 16:13, Gisle Vanem wrote:
> Keith Marshall wrote:
> 
>> If you neglect that discrepancy, and your application calls any of the
>> pthreads-win32 functions which require a struct timespec * parameter,
>> then your application will exhibit undefined behaviour.
> 
> Look in PtW32 sources who this struct is used. Specifically how '*abstime'
> is filled (I have v2.9.1 here). So since 'tv_sec' there is 32-bit, Pthread
> programs could have problems in the year 2036. I assume you have fixed
> PtW32 till then :-)

You appear to be missing the point, (actually several related points),
entirely:--

1) HAVE_STRUCT_TIMESPEC is a configuration time macro; it has no
   business appearing in any installed header, such as <pthread.h>
   which might be considered as a system header, (or otherwise).

2) At libpthread.a build time, HAVE_STRUCT_TIMESPEC is undefined,
   by default, for a mingw32 target build; there is no configure
   time discovery, to automatically correct this anomaly.

3) If a user installs pthreads-win32 from an on-line resource, in
   preference to building it themselves, then it's likely that the
   library will have an inbuilt assumption that tv_sec is 32-bit.

4) When this same user builds a client application, and works around
   the HAVE_STRUCT_TIMESPEC issue, by forcibly defining it, then the
   user's client application will, (if using mingwrt-3.21.1 or later),
   construct timespec structures with 64-bit tv_sec; if these are
   then passed by reference, to any libpthread.a function, then the
   tv_sec and tv_nsec values may be misinterpreted within the library
   code; the outcome is unpredictable, and hence undefined.

5) That <pthread.h> defines struct timespec itself is a violation of
   POSIX.1.  It should be defined in <sched.h>, (which then makes it
   indirectly visible, when <pthread.h> is included).  However, the
   POSIX.1 requirement for <sched.h> is that it shall define struct
   timespec *exactly* as it is defined by <time.h> ... admittedly a
   thorny issue for a windows implementation, where the platform
   vendor doesn't define this structure in *any* header, AFAIK.  In
   this case, the pthreads-win32 implementation really shouldn't
   implement any function which refers to struct timespec, *unless*
   configuration time discovery shows it to be defined in a third
   party header (for exclusive use with a third party compiler suite)
   such as MinGW.org's.

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
_______________________________________________
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