From: short <> Date: Thu, 16 Jan 2003 03:38:46 +0000 (+0000) Subject: +src/libcaptive/ex/list.c X-Git-Tag: captive-0_2~347 X-Git-Url: http://git.jankratochvil.net/?a=commitdiff_plain;h=97db354cb972b5f25ac1f9334e12ce5f23435ae7;p=captive.git +src/libcaptive/ex/list.c - +InterlockedPopEntrySList() - +InterlockedPushEntrySList() --- diff --git a/src/libcaptive/ex/list.c b/src/libcaptive/ex/list.c new file mode 100644 index 0000000..7f32dad --- /dev/null +++ b/src/libcaptive/ex/list.c @@ -0,0 +1,74 @@ +/* $Id$ + * reactos list functions emulation of libcaptive + * Copyright (C) 2002 Jan Kratochvil + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; exactly version 2 of June 1991 is required + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "config.h" + +#include "reactos/ddk/exfuncs.h" +#include +#include "reactos/ntos/types.h" /* for PSLIST_ENTRY */ + + +/** + * InterlockedPopEntrySList: + * @ListHead: List to remove the first entry from. + * %NULL value is forbidden. + * + * Function will remove the first item of @ListHead list and returns its entry @PSLIST_ENTRY. + * Function should behave in multiprocessing safe way - not handled by libcaptive. + * + * Returns: The first entry item of @ListHead. Passed @ListHead will have the first item removed. + * %NULL value if the list was empty. + */ +PSLIST_ENTRY InterlockedPopEntrySList(IN PSLIST_HEADER ListHead) +{ +KSPIN_LOCK SpinLock; + + g_return_val_if_fail(ListHead!=NULL,NULL); + + /* TODO:thread */ + KeInitializeSpinLock(&SpinLock); + return ExInterlockedPopEntrySList(ListHead,&SpinLock); +} + + +/** + * InterlockedPushEntrySList: + * @ListHead: List to insert @ListEntry item to its start. + * %NULL value is forbidden. + * @ListEntry: List item to insert to @ListHead. + * %NULL value is forbidden. + * + * Function will insert @ListEntry as the first item of @ListHead list. + * Function should behave in multiprocessing safe way - not handled by libcaptive. + * + * Returns: The previous first entry item of @ListHead (currently the second one). + * Passed @ListHead will have the first item @ListEntry. + * Returns %NULL value if the list was empty. + */ +PSLIST_ENTRY InterlockedPushEntrySList(IN PSLIST_HEADER ListHead,IN PSLIST_ENTRY ListEntry) +{ +KSPIN_LOCK SpinLock; + + g_return_val_if_fail(ListHead!=NULL,NULL); + g_return_val_if_fail(ListEntry!=NULL,NULL); + + /* TODO:thread */ + KeInitializeSpinLock(&SpinLock); + return ExInterlockedPushEntrySList(ListHead,ListEntry,&SpinLock); +}