I would like to propose a model for dealing with reentrant functions at the compiler level 我將提出一個(gè)在編譯器層次處理可重入函數(shù)的模型。
A reentrant function can be interrupted at any time and resumed at a later time without loss of data 可重入函數(shù)可以在任意時(shí)刻被中斷,稍后再繼續(xù)運(yùn)行,不會(huì)丟失數(shù)據(jù)。
Reentrant functions either use local variables or protect their data when global variables are used 可重入函數(shù)要么使用本地變量,要么在使用全局變量時(shí)保護(hù)自己的數(shù)據(jù)。
Note that this follows a standard convention for the naming of reentrant function by suffixing the function name with " r " 注意,這里遵循了標(biāo)準(zhǔn)慣例,通過(guò)向函數(shù)名添加“ _ r ”后綴來(lái)命名可重入函數(shù)。
Ensuring guideline 3 requires the compiler to have prior knowledge of all the reentrant functions , including the libraries used by the application 確保準(zhǔn)則3得到滿足,要求編譯器預(yù)先知道所有可重入函數(shù),包括應(yīng)用程序所使用的程序庫(kù)。
Due to the asynchronous nature of signals , it is difficult to point out the bug caused when a signal - handling function triggers a non - reentrant function 由于信號(hào)在本質(zhì)上是異步的,所以難以找出當(dāng)信號(hào)處理函數(shù)觸發(fā)某個(gè)不可重入函數(shù)時(shí)導(dǎo)致的bug 。
This proposed model would make the programmer s job easier in following the guidelines for reentrant functions , and by using this model , code would be protected against the unintentional reentrancy bug 提出的這個(gè)模型將簡(jiǎn)化程序員遵循可重入函數(shù)準(zhǔn)則的工作,而且使用此模型可以預(yù)防代碼出現(xiàn)無(wú)意的可重入性bug 。