MIT 6.828 - 1.2 __acquires() 和 __releases()

在對 dup / dup2 的源碼分析中,我遇到了一對 annotation ,即 __acquires__releaseshtml

static int do_dup2(struct files_struct *files,
    struct file *file, unsigned fd, unsigned flags)
__releases(&files->file_lock) // <- 這個東西
{
    // ... omitted
}

經查閱,此爲內核代碼靜態分析工具 Sparse 的 annotation 。Sparse 經過 gcc 的擴展屬性 __attribute__ 以及本身定義的 __context__ 來對代碼進行靜態檢查 。工具

其餘可見 內核文檔一篇博客源碼分析

相關文章
相關標籤/搜索