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

ffi/pthread: fix pthread_attr_t and PTHREAD_CREATE_DETACHED declarations #1958

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

benoit-pierre
Copy link
Contributor

@benoit-pierre benoit-pierre commented Oct 5, 2024

The declarations of pthread_attr_t and PTHREAD_CREATE_DETACHED depend on the arch / OS:

Target machine sizeof (pthread_attr_t) PTHREAD_CREATE_DETACHED
aarch64-linux-gnu-g++ 64 1
aarch64-unknown-linux-android21 56 1
arm-kindlepw2-linux-gnueabi 36 1
arm-linux-gnueabihf 36 1
arm64-apple-darwin23.6.0 64 2
armv7a-unknown-linux-android18 24 1
i386-pc-linux-gnu 36 1
i686-unknown-linux-android18 24 1
x86_64-apple-darwin22.6.0 64 2
x86_64-pc-linux-gnu 56 1

The following C++ compiler command can be used to print those values:

▸ g++ -x c++ -c -o /dev/null - <<\EOF
template <int val> struct PrintConst;
PrintConst<sizeof (pthread_attr_t)> sizeof_pthread_attr_t;
PrintConst<PTHREAD_CREATE_DETACHED> valueof_PTHREAD_CREATE_DETACHED;
EOF
<stdin>:3:37: error: aggregate ‘PrintConst<56> sizeof_pthread_attr_t’ has incomplete type and cannot be defined
<stdin>:4:37: error: aggregate ‘PrintConst<1> valueof_PTHREAD_CREATE_DETACHED’ has incomplete type and cannot be defined

Previous declarations were wrong on aarch64-linux, armv7a-android, i686-android, and macOS.


This change is Reviewable

…rations

The declarations of `pthread_attr_t` and `PTHREAD_CREATE_DETACHED` depend on the arch / OS:

| Target machine                  | `sizeof (pthread_attr_t)` | `PTHREAD_CREATE_DETACHED` |
|---------------------------------|--------------------------:|--------------------------:|
| aarch64-linux-gnu-g++           |                        64 |                         1 |
| aarch64-unknown-linux-android21 |                        56 |                         1 |
| arm-kindlepw2-linux-gnueabi     |                        36 |                         1 |
| arm-linux-gnueabihf             |                        36 |                         1 |
| arm64-apple-darwin23.6.0        |                        64 |                         2 |
| armv7a-unknown-linux-android18  |                        24 |                         1 |
| i386-pc-linux-gnu               |                        36 |                         1 |
| i686-unknown-linux-android18    |                        24 |                         1 |
| x86_64-apple-darwin22.6.0       |                        64 |                         2 |
| x86_64-pc-linux-gnu             |                        56 |                         1 |

The following C++ compiler command can be used to print those values:

```bash
▸ g++ -x c++ -c -o /dev/null - <<\EOF
template <int val> struct PrintConst;
PrintConst<sizeof (pthread_attr_t)> sizeof_pthread_attr_t;
PrintConst<PTHREAD_CREATE_DETACHED> valueof_PTHREAD_CREATE_DETACHED;
EOF
<stdin>:3:37: error: aggregate ‘PrintConst<56> sizeof_pthread_attr_t’ has incomplete type and cannot be defined
<stdin>:4:37: error: aggregate ‘PrintConst<1> valueof_PTHREAD_CREATE_DETACHED’ has incomplete type and cannot be defined
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants