Indentation fix, cleanup.
[AROS.git] / rom / task / LockTaskList.c
blob531ae4cdf40777da7d50d033ec19d356f234a556
1 /*
2 Copyright © 2015, 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 "taskres_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/task.h>
23 AROS_LH1(struct TaskList *, LockTaskList,
25 /* SYNOPSIS */
26 AROS_LHA(ULONG, flags, D1),
28 /* LOCATION */
29 struct TaskResBase *, TaskResBase, 1, Task)
31 /* FUNCTION
33 INPUTS
34 flags -
36 RESULT
37 Handle to the task list. This is not a direct pointer
38 to the first list element but to a pseudo element instead.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 UnLockTaskList(), NextTaskEntry()
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 struct TaskListPrivate *taskList = NULL;
57 D(bug("[TaskRes] LockTaskList: flags = $%lx\n", flags));
59 if (flags & LTF_WRITE)
60 ObtainSemaphore(&TaskResBase->trb_Sem);
61 else
62 ObtainSemaphoreShared(&TaskResBase->trb_Sem);
64 if ((taskList = AllocMem(sizeof(struct TaskListPrivate), MEMF_CLEAR)) != NULL)
66 D(bug("[TaskRes] LockTaskList: TaskList @ 0x%p\n", taskList));
67 taskList->tlp_Node.ln_Name = (char *)FindTask(NULL);
68 taskList->tlp_Flags = flags;
69 taskList->tlp_Tasks = &TaskResBase->trb_TaskList;
70 taskList->tlp_Next = (struct TaskListEntry *)GetHead(taskList->tlp_Tasks);
71 AddTail(&TaskResBase->trb_LockedLists, &taskList->tlp_Node);
74 return (struct TaskList *)taskList;
76 AROS_LIBFUNC_EXIT
77 } /* LockTaskList */