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
= ThisTask
? GetIntETask(ThisTask
) : NULL
;
57 tsfs
= (struct TaskStorageFreeSlot
*)
58 GetHead(&PrivExecBase(SysBase
)->TaskStorageSlots
);
61 Alert(AT_DeadEnd
|AN_MemoryInsane
);
62 __builtin_unreachable();
65 slot
= tsfs
->FreeSlot
;
67 D(bug("[TSS] Task 0x%p (%s): Allocated slot %d\n", ThisTask
, ThisTask
->tc_Node
.ln_Name
, slot
);)
69 if (GetSucc(tsfs
) == NULL
)
71 /* Last element always points to highest element and is a new slot */
76 Remove((struct Node
*) tsfs
);
77 FreeMem(tsfs
, sizeof(struct TaskStorageFreeSlot
));