2 Copyright © 2011-2012, 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 TaskStorageFreeSlot
*tsfs
;
50 struct IntETask
*iet
= GetIntETask(FindTask(NULL
));
56 tsfs
= (struct TaskStorageFreeSlot
*)
57 GetHead(&PrivExecBase(SysBase
)->TaskStorageSlots
);
59 Alert(AT_DeadEnd
|AN_MemoryInsane
);
61 slot
= tsfs
->FreeSlot
;
63 D(bug("[TSS] Task 0x%p (%s): Allocated slot %d\n", FindTask(NULL
), FindTask(NULL
)->tc_Node
.ln_Name
, slot
));
65 if (GetSucc(tsfs
) == NULL
)
67 /* Last element always points to highest element and is a new slot */
72 Remove((struct Node
*) tsfs
);
73 FreeMem(tsfs
, sizeof(struct TaskStorageFreeSlot
));