zoukankan      html  css  js  c++  java
  • 调用spin_lock_irqsave(&chip>lock,flags); 的下层实现是什么?

    调用spin_lock_irqsave(&chip->lock,flags); 的下层实现是什么?

     
    #define spin_lock_irqsave(lock, flags) \
    
    do { \
    
    typecheck(unsigned long, flags); \
    
    flags = _spin_lock_irqsave(lock); \
    
    } while (0)
     

     

       1:  /*
       2:  
       3:  * Check at compile time that something is of a particular type.
       4:  
       5:  * Always evaluates to 1 so you may use it easily in comparisons.
       6:  
       7:  */
       8:   
       9:  #define typecheck(type,x) \
      10:   
      11:  ({ type __dummy; \
      12:   
      13:  typeof(x) __dummy2; \
      14:   
      15:  (void)(&__dummy == &__dummy2); \
      16:   
      17:  1; \
      18:   
      19:  })
      20:   

     

    #define _spin_lock_irqsave(lock) __spin_lock_irqsave(lock)
    
    
    static inline unsigned long __spin_lock_irqsave(spinlock_t *lock)
    
    {
    
    unsigned long flags;
    
    local_irq_save(flags);
    
    preempt_disable();
    
    spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
    
    /*
    
    * On lockdep we dont want the hand-coded irq-enable of
    
    * _raw_spin_lock_flags() code, because lockdep assumes
    
    * that interrupts are not re-enabled during lock-acquire:
    
    */
    
    #ifdef CONFIG_LOCKDEP
    
    LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
    
    #else
    
    _raw_spin_lock_flags(lock, &flags);
    
    #endif
    
    return flags;
    
    }
     
    

    为了避免卷入过多的宏定义当中,展开级别暂时停留于此,后面我们将进行最终的展开,展开定义如下所示:

       1:  do { ( { unsigned long __dummy ; 
       2:   
       3:  typeof ( flags ) __dummy2 ; 
       4:   
       5:  ( void ) ( & __dummy == & __dummy2 ) ; 1 ; } ) ; 
       6:   
       7:  flags = __spin_lock_irqsave ( & chip -> lock ) ; 
       8:   
       9:  } while ( 0 )

  • 相关阅读:
    java ->IO流_打印流
    java ->IO流_序列化流与反序列化流
    java ->properties类
    java ->String、StringBuffer、StringBuilder三者之间的区别
    java-> 利用IO操作与递归实现目录的复制
    java
    java ->IO流_转换流
    java ->IO流_字符流
    java ->IO流_字节流
    死循环
  • 原文地址:https://www.cnblogs.com/justinzhang/p/2109926.html
Copyright © 2011-2022 走看看