refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / task / UnLockTaskList.c
blobc34abe872079ac71d2de9927d70b24995b4b821a
1 /*
2 Copyright © 2015-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
8 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <aros/libcall.h>
11 #include <proto/utility.h>
12 #include <resources/task.h>
14 #include <resources/task.h>
16 #include "task_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/task.h>
23 AROS_LH2(void, UnLockTaskList,
25 /* SYNOPSIS */
26 AROS_LHA(struct TaskList *, tlist, A0),
27 AROS_LHA(ULONG, flags, D0),
29 /* LOCATION */
30 struct TaskResBase *, TaskResBase, 2, Task)
32 /* FUNCTION
33 Frees a lock on the task lists given by LockTaskList().
35 INPUTS
36 flags - the same value as given to LockTaskList().
38 RESULT
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 LockTaskList(), NextTaskEntry()
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 #ifdef TASKRES_ENABLE
56 struct TaskListPrivate *taskList, *tltmp;
57 struct Task *thisTask = FindTask(NULL);
58 #endif /* TASKRES_ENABLE */
60 D(bug("[TaskRes] UnLockTaskList: flags = $%lx\n", flags));
62 #ifdef TASKRES_ENABLE
63 ReleaseSemaphore(&TaskResBase->trb_Sem);
65 ForeachNodeSafe(&TaskResBase->trb_LockedLists, taskList, tltmp)
67 if (((struct Task *)taskList->tlp_Node.ln_Name == thisTask) &&
68 (taskList->tlp_Flags == flags))
70 D(bug("[TaskRes] UnLockTaskList: Releasing TaskList @ 0x%p\n", taskList));
71 Remove(&taskList->tlp_Node);
72 FreeMem(taskList, sizeof(struct TaskListPrivate));
73 break;
77 /* Purge expired entries from the list... */
78 task_CleanList(NULL, TaskResBase);
79 #else
80 Enable();
81 FreeVec(tlist);
82 #endif /* TASKRES_ENABLE */
84 AROS_LIBFUNC_EXIT
85 } /* UnLockTaskList */