Skip to content

Thread_POSIX.cpp shouldn't convert thread IDs to long #3857

@arrowd

Description

@arrowd

According to the POSIX standard returning value of pthread_self() is opaque and can't be casted to long. See NOTES section of pthread_self(3) and pthread_equal(3) man pages.

The code of ThreadImpl::currentOsTidImpl() causes compilation to fail on FreeBSD with

poco/Foundation/src/Thread_POSIX.cpp:326:12: error: cannot initialize return object of type 'long' with an rvalue of type 'pthread_t' (aka 'pthread *')
    return ::pthread_self();
           ^~~~~~~~~~~~~~~~

On the other hand, the method is called currentOsTidImpl and on Linux it calls gettid() syscall. If this method is intended to return kernel thread identifier, then the #else case shouldn't call pthread_self() and instead have #error Implement this for your OS. I'm happy to prepare a pull request if my analysis is right.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions