linux - 来自 Cython 的 syscall 或 gettid 系统函数
问题描述
我需要gettid
从 Cython 打电话。根据其手册页,我应该使用该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
推荐阅读
- sql-server - 将多个订购的商品放在一条记录中
- c# - 为什么 VS 要求不使用内联代码?
- angular - 如何在Angular4中关闭浏览器窗口之前调用API
- python - 你会如何在 Tensorflow 中做 ReduceLROnPlateau?
- linux-kernel - kprobe_events 获取参数在 ARM 上不起作用
- regex - Perl 正则表达式替换与组
- javascript - javascript toISOString 返回不正确的日期问题
- codeigniter - 如何使用 Codeigniter 和 Websocket 在不刷新页面的情况下获取最新记录
- html - 如何设计具有 3 个正方形 (1:1) 和 1 个矩形(剩余高度)的 HTML 页面
- javascript - 使用javascript输入文本区域与div中的文本比较