2 * reactos list functions emulation of libcaptive
3 * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "reactos/ddk/exfuncs.h"
23 #include <glib/gmessages.h>
24 #include "reactos/ntos/types.h" /* for PSLIST_ENTRY */
28 * InterlockedPopEntrySList:
29 * @ListHead: List to remove the first entry from.
30 * %NULL value is forbidden.
32 * Function will remove the first item of @ListHead list and returns its entry @PSLIST_ENTRY.
33 * Function should behave in multiprocessing safe way - not handled by libcaptive.
35 * Returns: The first entry item of @ListHead. Passed @ListHead will have the first item removed.
36 * %NULL value if the list was empty.
38 PSLIST_ENTRY InterlockedPopEntrySList(IN PSLIST_HEADER ListHead)
42 g_return_val_if_fail(ListHead!=NULL,NULL);
45 KeInitializeSpinLock(&SpinLock);
46 return ExInterlockedPopEntrySList(ListHead,&SpinLock);
51 * InterlockedPushEntrySList:
52 * @ListHead: List to insert @ListEntry item to its start.
53 * %NULL value is forbidden.
54 * @ListEntry: List item to insert to @ListHead.
55 * %NULL value is forbidden.
57 * Function will insert @ListEntry as the first item of @ListHead list.
58 * Function should behave in multiprocessing safe way - not handled by libcaptive.
60 * Returns: The previous first entry item of @ListHead (currently the second one).
61 * Passed @ListHead will have the first item @ListEntry.
62 * Returns %NULL value if the list was empty.
64 PSLIST_ENTRY InterlockedPushEntrySList(IN PSLIST_HEADER ListHead,IN PSLIST_ENTRY ListEntry)
68 g_return_val_if_fail(ListHead!=NULL,NULL);
69 g_return_val_if_fail(ListEntry!=NULL,NULL);
72 KeInitializeSpinLock(&SpinLock);
73 return ExInterlockedPushEntrySList(ListHead,ListEntry,&SpinLock);