⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spinlock.h

📁 红外接口串口仿真
💻 H
字号:
#ifndef _LINUX_SPINLOCK_H
#define _LINUX_SPINLOCK_H

#include <ntddk.h>
#include <ndis.h>

typedef NDIS_SPIN_LOCK spinlock_t;

inline void spin_lock_init(spinlock_t* pSpinlock)
{
    NdisAllocateSpinLock(pSpinlock);
}

#define spin_lock   NdisAcquireSpinLock
#define spin_unlock NdisReleaseSpinLock

#define spin_lock_irqsave(pLock, flags) do \
{ \
    flags = 0; \
    NdisAcquireSpinLock(pLock); \
} while (0)

#define spin_unlock_irqrestore(pLock, flags) do \
{ \
    NdisReleaseSpinLock(pLock); \
} while (0)

#define test_bit(bit, x)    (*(x) & (1 << bit))

__inline void set_bit(int nr, __u32* addr)
{
    __asm
    {
        mov  eax,nr
        mov  ebx,addr
        bts  [ebx],eax
    }
}

__inline void clear_bit(int nr, __u32* addr)
{
    __asm
    {
        mov  eax,nr
        mov  ebx,addr
        btr  [ebx],eax
    }
}

__inline int test_and_clear_bit(int nr, __u32* addr)
{
    int result;


    __asm
    {
        mov  eax,nr
        mov  ebx,addr
        btr  [ebx],eax
        sbb  eax,eax
        mov  result,eax
    }
    return result;
}

__inline int test_and_set_bit(int nr, __u32* addr)
{
    int result;


    __asm
    {
        mov  eax,nr
        mov  ebx,addr
        bts  [ebx],eax
        sbb  eax,eax
        mov  result,eax
    }
    return result;
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -