[MacPorts] #59772: python38: fails on Leopard: Undefined symbols: :info:build "_pthread_threadid_np"
MacPorts
noreply at macports.org
Fri Feb 28 08:22:15 UTC 2020
#59772: python38: fails on Leopard: Undefined symbols: :info:build
"_pthread_threadid_np"
-----------------------+---------------------------
Reporter: kencu | Owner: jmroot
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version:
Resolution: | Keywords: leopard tiger
Port: python38 |
-----------------------+---------------------------
Comment (by kencu):
This snippet is getting very close, just need to flesh out the details of
replicating the full functionality of {{{pthread_threadid_np}}}. This
might need to go into {{{legacysupport}}} as it is a tad complicated, but
perhaps the python source file will accept these headers being added ...
{{{
#include <unistd.h>
#include <errno.h>
#include <iostream>
#include <pthread.h>
#include <sys/syscall.h>
#include <mach/kern_return.h>
#include <mach/thread_info.h>
#include <mach/thread_act.h>
uint64_t my_pthread_threadid_np(pthread_t thread) {
mach_port_name_t port=pthread_mach_thread_np(thread);
thread_identifier_info_data_t info;
mach_msg_type_number_t info_count=THREAD_IDENTIFIER_INFO_COUNT;
kern_return_t kr=thread_info(port,
THREAD_IDENTIFIER_INFO,
(thread_info_t)&info,
&info_count);
if(kr!=KERN_SUCCESS) {
/* you can get a description of the error by calling
* mach_error_string(kr)
*/
return 0;
} else {
return info.thread_id;
}
}
int main() {
std::cout << "getpid()=" << getpid() << std::endl;
std::cout << "pthread_self()=" << pthread_self() << std::endl;
uint64_t tid;
pthread_threadid_np(NULL, &tid);
std::cout << "pthread_threadid_np()=" << tid << std::endl;
std::cout << "syscall(SYS_thread_selfid)=" << syscall(SYS_thread_selfid)
<< std::endl;
//for (int i=0; i < 100; i++) {
mach_port_t newtid = pthread_mach_thread_np(pthread_self());
std::cout << "pthread_mach_thread_np()=" << (uint64_t)newtid <<
std::endl;
//}
std::cout << "my_pthread_threadid_np()=" <<
my_pthread_threadid_np(pthread_self()) << std::endl;
return 0;
}
// getting very close to replicating the function
// check the man page for pthread_threadid_np for details on
implementation
// probably can find it in Apple Open Source as well
}}}
--
Ticket URL: <https://trac.macports.org/ticket/59772#comment:14>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list