only replace newaddtask since addtask calls it on aros anyhows
[AROS.git] / rom / task / execfuncs.c
blob5f2abfaddcd680653bb2d0e0aeef666743fa6120
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 <aros/symbolsets.h>
11 #include <proto/exec.h>
12 #include <proto/kernel.h>
14 #include "taskres_intern.h"
16 extern struct TaskResBase *internTaskResBase;
18 void TaskResAddTask(struct Task *task)
20 struct TaskListEntry *newEntry;
23 TODO:
24 if the list is locked, defer tasks addition until it is unlocked
26 if ((newEntry = AllocMem(sizeof(struct TaskListEntry), MEMF_CLEAR)) != NULL)
28 D(bug("[TaskRes] TaskResAddTask: taskentry @ 0x%p\n", newEntry));
29 newEntry->tle_Task = task;
30 AddTail(&internTaskResBase->trb_TaskList, &newEntry->tle_Node);
34 AROS_LH4(APTR, NewAddTask,
35 AROS_LHA(struct Task *, task, A1),
36 AROS_LHA(APTR, initialPC, A2),
37 AROS_LHA(APTR, finalPC, A3),
38 AROS_LHA(struct TagItem *, tagList, A4),
39 struct ExecBase *, SysBase, 176, Task)
41 AROS_LIBFUNC_INIT
43 APTR newTask;
45 D(bug("[TaskRes] NewAddTask()\n"));
47 newTask = AROS_CALL4(APTR, internTaskResBase->trb_NewAddTask,
48 AROS_LCA(struct Task *, task, A1),
49 AROS_LCA(APTR, initialPC, A2),
50 AROS_LCA(APTR, finalPC, A3),
51 AROS_LCA(struct TagItem *, tagList, A4),
52 struct ExecBase *, SysBase);
54 D(bug("[TaskRes] NewAddTask: task @ 0x%p\n", task));
56 if (newTask)
57 TaskResAddTask(newTask);
59 return newTask;
61 AROS_LIBFUNC_EXIT
64 AROS_LH1(void, RemTask,
65 AROS_LHA(struct Task *, task, A1),
66 struct ExecBase *, SysBase, 48, Task)
68 AROS_LIBFUNC_INIT
70 struct TaskListEntry *tmpEntry;
72 D(bug("[TaskRes] RemTask()\n"));
74 AROS_CALL1(APTR, internTaskResBase->trb_RemTask,
75 AROS_LCA(struct Task *, task, A1),
76 struct ExecBase *, SysBase);
78 ForeachNode(&internTaskResBase->trb_TaskList, tmpEntry)
80 if (tmpEntry->tle_Task == task)
83 TODO:
84 if the list is locked flag the entry to be removed,
85 else remove it immediately
87 Remove(&tmpEntry->tle_Node);
88 FreeMem(tmpEntry, sizeof(struct TaskListEntry));
89 break;
93 return;
95 AROS_LIBFUNC_EXIT