2 Copyright © 2015, The AROS Development Team. All rights reserved.
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 void TaskResAddTask(struct TaskResBase
*TaskResBase
, struct Task
*task
)
18 struct TaskListEntry
*newEntry
;
20 if ((newEntry
= AllocMem(sizeof(struct TaskListEntry
), MEMF_CLEAR
)) != NULL
)
22 D(bug("[TaskRes] TaskResAddTask: taskentry @ 0x%p for '%s'\n", newEntry
, task
->tc_Node
.ln_Name
));
23 newEntry
->tle_Task
= task
;
24 if (IsListEmpty(&TaskResBase
->trb_LockedLists
))
25 AddTail(&TaskResBase
->trb_TaskList
, &newEntry
->tle_Node
);
27 AddTail(&TaskResBase
->trb_NewTasks
, &newEntry
->tle_Node
);
31 AROS_LH4(APTR
, NewAddTask
,
32 AROS_LHA(struct Task
*, task
, A1
),
33 AROS_LHA(APTR
, initialPC
, A2
),
34 AROS_LHA(APTR
, finalPC
, A3
),
35 AROS_LHA(struct TagItem
*, tagList
, A4
),
36 struct ExecBase
*, SysBase
, 176, Task
)
41 struct TaskResBase
*TaskResBase
;
43 TaskResBase
= (struct TaskResBase
*)SysBase
->lb_TaskResBase
;
45 D(bug("[TaskRes] NewAddTask(0x%p)\n", task
));
47 newTask
= AROS_CALL4(APTR
, TaskResBase
->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", newTask
));
57 TaskResAddTask(TaskResBase
, newTask
);
64 AROS_LH1(void, RemTask
,
65 AROS_LHA(struct Task
*, task
, A1
),
66 struct ExecBase
*, SysBase
, 48, Task
)
70 struct TaskListEntry
*taskEntry
, *tmpEntry
;
71 struct TaskResBase
*TaskResBase
;
74 TaskResBase
= (struct TaskResBase
*)SysBase
->lb_TaskResBase
;
76 D(bug("[TaskRes] RemTask(0x%p)\n", task
));
78 ForeachNodeSafe(&TaskResBase
->trb_NewTasks
, taskEntry
, tmpEntry
)
80 if (taskEntry
->tle_Task
== task
)
82 D(bug("[TaskRes] RemTask: destroying new entry @ 0x%p\n", taskEntry
));
83 Remove(&taskEntry
->tle_Node
);
84 FreeMem(taskEntry
, sizeof(struct TaskListEntry
));
92 ForeachNodeSafe(&TaskResBase
->trb_TaskList
, taskEntry
, tmpEntry
)
94 if (taskEntry
->tle_Task
== task
)
96 D(bug("[TaskRes] RemTask: taskentry @ 0x%p for '%s'\n", taskEntry
, task
->tc_Node
.ln_Name
));
97 if (IsListEmpty(&TaskResBase
->trb_LockedLists
))
99 D(bug("[TaskRes] RemTask: destroying entry\n"));
100 Remove(&taskEntry
->tle_Node
);
101 FreeMem(taskEntry
, sizeof(struct TaskListEntry
));
105 D(bug("[TaskRes] RemTask: flag entry for removal\n"));
106 taskEntry
->tle_Task
= NULL
;
113 if (TaskResBase
->trb_RemTask
)
115 AROS_CALL1(APTR
, TaskResBase
->trb_RemTask
,
116 AROS_LCA(struct Task
*, task
, A1
),
117 struct ExecBase
*, SysBase
);