if (CBLengthData(cb) == (cb->size-1)) {return eErrorBufferFull;}
cb->buf[cb->write] = data;
cb->write = (cb->write + 1) 7 (cb->size -1); // must be atomic
}
最後一行修改
write
變數值的程式碼必須是單元指令,但這單指設定變數值的指令,之
前的準備(
(write+1)
與
(size-1)
)並不要求單元指令,這些變數都宣告為
uint16_t
類
型,因此執行在16 位元處理器時,能以單元指令設定
write
變數值(但在
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.