sync.c

来自「S3C24A0的完整BSP包,对开发此芯片的开发者很有用.」· C语言 代码 · 共 79 行

C
79
字号
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#include <ndis.h>
#include <ntddndis.h>
#include <linklist.h>
#include "sync.h"

void CheckForEntryOnList(PLIST_ENTRY Head, PLIST_ENTRY Entry)
{
    PLIST_ENTRY ListEntry;

    for (ListEntry = Head->Flink;
         ListEntry != Head->Flink;
         ListEntry = ListEntry->Flink
        )
    {
        if (Entry==ListEntry)
        {
            DbgPrint("About to insert entry that is already on list!\n");
            DbgPrint("Head:%08X Entry:%08X\n", Head, Entry);
            DbgBreakPoint();
            break;
        }
    }
}
                     
BOOLEAN SynchronizedListFunc(IN PVOID Context)
{
    SynchronizeList *ListData = Context;

    switch (ListData->Command)
    {
        case SyncInsertHead:
//            CheckForEntryOnList(ListData->Head, ListData->Entry);
            InsertHeadList(ListData->Head, ListData->Entry);
            break;
        case SyncInsertTail:
//            CheckForEntryOnList(ListData->Head, ListData->Entry);
            InsertTailList(ListData->Head, ListData->Entry);
            break;
        case SyncRemoveHead:
            if (IsListEmpty(ListData->Head))
            {
                ListData->Entry = NULL;
            }
            else
            {
                ListData->Entry = RemoveHeadList(ListData->Head);
            }
            break;
        case SyncRemoveTail:
            if (IsListEmpty(ListData->Head))
            {
                ListData->Entry = NULL;
            }
            else
            {
                ListData->Entry = RemoveTailList(ListData->Head);
            }
            break;
        case SyncRemove:
            RemoveEntryList(ListData->Entry);
            break;
        default:
            ASSERT(0);
            break;
    }
    return TRUE;
}

⌨️ 快捷键说明

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