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. Data stored in a slot will be duplicated when
34 a Task creates another Task. It is left up to the caller to implement
35 a mechanism to check if this copied value is invalid.
42 FreeTaskStorageSlot(), GetTaskStorageSlot(), SetTaskStorageSlot()
46 ******************************************************************************/
50 struct TaskStorageFreeSlot
*tsfs
;
52 struct IntETask
*iet
= GetIntETask(FindTask(NULL
));
58 tsfs
= (struct TaskStorageFreeSlot
*)
59 GetHead(&PrivExecBase(SysBase
)->TaskStorageSlots
);
61 Alert(AT_DeadEnd
|AN_MemoryInsane
);
63 slot
= tsfs
->FreeSlot
;
65 D(bug("[TSS] Task 0x%p (%s): Allocated slot %d\n", FindTask(NULL
), FindTask(NULL
)->tc_Node
.ln_Name
, slot
));
67 if (GetSucc(tsfs
) == NULL
)
69 /* Last element always points to highest element and is a new slot */
74 Remove((struct Node
*) tsfs
);
75 FreeMem(tsfs
, sizeof(struct TaskStorageFreeSlot
));