Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pthread_key_t is assumed to be an integer, which is against POSIX #287

Closed
carlo-bramini opened this issue Oct 23, 2021 · 1 comment
Closed
Assignees
Labels
bug Something isn't working platform issue Issue is specific to an OS or desktop priority-low
Milestone

Comments

@carlo-bramini
Copy link
Contributor

I compiled mxml on CYGWIN and I got these messages on screen:

mxml-private.c:143:37: warning: initialization of ‘pthread_key_t’ {aka ‘struct __pthread_key_t *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  143 | static pthread_key_t    _mxml_key = -1; /* Thread local storage key */
      |                                     ^
mxml-private.c: In function ‘_mxml_fini’:
mxml-private.c:171:17: warning: comparison between pointer and integer
  171 |   if (_mxml_key != -1)
      |                 ^~
mxml-private.c:177:15: warning: assignment to ‘pthread_key_t’ {aka ‘struct __pthread_key_t *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  177 |     _mxml_key = -1;
      |               ^

This happens because pthread_key_t is an opaque object and it should not be assumed to be an integer type.
In my opinion, this is not a good idea because, according to POSIX:

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html

All of the types shall be defined as arithmetic types of an appropriate length, with the following exceptions:

....
pthread_key_t
....

It is true that, at least on CYGWIN, I can bypass the trouble by simply using the TLS APIs for Windows (just need to test __CYGWIN__ in addition to _WIN32 into mxml-private.c) but it would be worth to fix it since other platforms could have this trouble.

@michaelrsweet michaelrsweet added the investigating Investigating the issue label Oct 26, 2021
@michaelrsweet
Copy link
Owner

[master 02f3310] Fix POSIX threading support on MingW (Issue #287)

@michaelrsweet michaelrsweet added bug Something isn't working platform issue Issue is specific to an OS or desktop priority-low and removed investigating Investigating the issue labels Oct 26, 2021
@michaelrsweet michaelrsweet self-assigned this Oct 26, 2021
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform issue Issue is specific to an OS or desktop priority-low
Projects
None yet
Development

No branches or pull requests

2 participants