第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

對(duì)一行C代碼的語法不明白,求解釋

對(duì)一行C代碼的語法不明白,求解釋

明月笑刀無情 2019-04-08 11:16:55
下面的代碼中for(pos=hlist_bl_first_rcu(head);pos&&({tpos=hlist_bl_entry(pos,typeof(*tpos),member);1;});pos=rcu_dereference_raw(pos->next)){...}第3行({tpos=hlist\_bl\_entry(pos,typeof(\*tpos),member);1;})的意思是執(zhí)行函數(shù)hlist\_bl\_entry()后再將這個(gè)括號(hào)的值設(shè)置為1,就是這個(gè)for循環(huán)只通過pos的值來判斷是否繼續(xù)執(zhí)行。現(xiàn)在不太清楚這一行的語法,為什么可以這么寫,求解釋。
查看完整描述

2 回答

?
料青山看我應(yīng)如是

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊

之前也沒見到過這樣的特殊用法,剛才搜了一下,找到了有關(guān)的描述。
({exp1;exp2;exp3;})
這樣的用法是復(fù)合語句的表達(dá)式用法,其值等于exp3的值。如果exp3不能求值,得到的結(jié)果就是void。
({inta=2+1;intb=0;b;})//0
({inta=2+1;intb=0;intc=0;})//void
我相信GNUC當(dāng)中有更多標(biāo)準(zhǔn)化的描述,你也可以自己尋找。
                            
查看完整回答
反對(duì) 回復(fù) 2019-04-08
?
jeck貓

TA貢獻(xiàn)1909條經(jīng)驗(yàn) 獲得超7個(gè)贊

好吧,我替你找到出處了:linux源碼。
/**
*hlist_bl_for_each_entry_rcu-iterateoverrculistofgiventype
*@tpos:thetype*touseasaloopcursor.
*@pos:the&structhlist_bl_nodetouseasaloopcursor.
*@head:theheadforyourlist.
*@member:thenameofthehlist_bl_nodewithinthestruct.
*
*/
#definehlist_bl_for_each_entry_rcu(tpos,pos,head,member)\
for(pos=hlist_bl_first_rcu(head);\
pos&&\
({tpos=hlist_bl_entry(pos,typeof(*tpos),member);1;});\
pos=rcu_dereference_raw(pos->next))
#endif
這是hlist_bl_for_each_entry_rcu的定義。我們?cè)趯?duì)比一下list_for_each_entry_rcu的定義:
/**
*list_for_each_entry_rcu-iterateoverrculistofgiventype
*@pos:thetype*touseasaloopcounter.
*@head:theheadforyourlist.
*@member:thenameofthelist_structwithinthestruct.
*
*Thislist-traversalprimitivemaysafelyrunconcurrentlywith
*the_rculist-mutationprimitivessuchaslist_add_rcu()
*aslongasthetraversalisguardedbyrcu_read_lock().
*/
#definelist_for_each_entry_rcu(pos,head,member)\
for(pos=list_entry((head)->next,typeof(*pos),member);\
prefetch(rcu_dereference(pos)->member.next),\
&pos->member!=(head);\
pos=list_entry(pos->member.next,typeof(*pos),member))
pos&&是短路求值,可以檢查是否為空NULL,此時(shí)返回1,可以防止提前結(jié)束。
                            
查看完整回答
反對(duì) 回復(fù) 2019-04-08
  • 2 回答
  • 0 關(guān)注
  • 621 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)