linux - 来自 Cython 的 syscall 或 gettid 系统函数

标签 linux cython

我需要从 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/

相关文章:

linux - ssh:端口 22 上的连接被拒绝

linux - mercurial 1.9 和 ssh 的问题

python - 将 numpy 数组的切片 View 传递给 cython - 复制发生在哪里?

python - cython prange 获取 pyeval_savethread : null tstate 错误

Java scsi访问

linux - 是否可以按确切日期查找文件然后对结果文件执行 tar 命令?

linux - 值得注意的是访问根目录中的文件夹

python - 减少python中的函数调用开销

inheritance - cython继承

python - cimport numpy 不能在 cython 中工作;错误信息不清楚(对我来说)