linux kernel set

    xiaoxiao2021-03-25  229

    将一个指针指向的数据的第nr位置一。

    example:

    __set_bit(EV_KEY, input_dev->evbit); __set_bit(EV_ABS, input_dev->evbit); __set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);

    函数位于: kernel\include\asm-generic\bitops\non-atomic.h

    /**

     * __set_bit - Set a bit in memory  * @nr: the bit to set  * @addr: the address to start counting from  *  * Unlike set_bit(), this function is non-atomic and may be reordered.  * If it's called on the same region of memory simultaneously, the effect  * may be that only one operation succeeds.  */ static inline void __set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); *p  |= mask; }
    转载请注明原文地址: https://ju.6miu.com/read-1870.html

    最新回复(0)