我需要从 Cython 调用 gettid
。根据其手册页,我应该使用 syscall 函数。我正在运行 Linux。
我可以轻松获取gettid
函数编号:
cdef extern from "sys/syscall.h":
cdef int __NR_gettid
但我找不到如何导入,或者更好的 cimport,syscall
。
有什么想法吗?
谢谢。
最佳答案
您可以在 cython 的 github 存储库中查找如何最好地完成这些包含,例如:stdio.h 。
应用这个会导致:
%%cython
cdef extern from "<sys/syscall.h>" nogil:
int __NR_gettid
long syscall(long number, ...)
def gettid():
return syscall(__NR_gettid)
现在 gettid()
产生:
>>> gettid()
7231
关于linux - 来自 Cython 的 syscall 或 gettid 系统函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50201706/