2 Copyright © 2011-2015, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 #include "exec_intern.h"
10 #include "taskstorage.h"
12 /*****************************************************************************
15 #include <proto/exec.h>
17 AROS_LH0(LONG
, AllocTaskStorageSlot
,
20 struct ExecBase
*, SysBase
, 180, Exec
)
23 This function will allocate a slot in the taskstorage.
29 slot - The allocated slot, or 0 if no slot could be allocated.
32 After this function SetTaskStorageSlot(slot) may be used to store
33 values with each slot.
40 FreeTaskStorageSlot(), GetTaskStorageSlot(), SetTaskStorageSlot()
44 ******************************************************************************/
48 struct Task
*ThisTask
= GET_THIS_TASK
;
49 struct TaskStorageFreeSlot
*tsfs
;
51 struct IntETask
*iet
= GetIntETask(ThisTask
);
57 tsfs
= (struct TaskStorageFreeSlot
*)
58 GetHead(&PrivExecBase(SysBase
)->TaskStorageSlots
);
60 Alert(AT_DeadEnd
|AN_MemoryInsane
);
62 slot
= tsfs
->FreeSlot
;
64 D(bug("[TSS] Task 0x%p (%s): Allocated slot %d\n", ThisTask
, ThisTask
->tc_Node
.ln_Name
, slot
);)
66 if (GetSucc(tsfs
) == NULL
)
68 /* Last element always points to highest element and is a new slot */
73 Remove((struct Node
*) tsfs
);
74 FreeMem(tsfs
, sizeof(struct TaskStorageFreeSlot
));