Adapted to WinCE
[AROS.git] / test / taskstorage.c
blobed2aa35f7288e5a2dd613e5fe2dad349f2666a67
1 #include <proto/exec.h>
2 #include <proto/dos.h>
4 #include <assert.h>
6 static BPTR out;
7 static int slot1, slot2, slot3;
9 static void printslot1(void)
11 IPTR *ts = FindTask(NULL)->tc_UnionETask.tc_TaskStorage;
13 FPrintf(out, "Value slot %ld: %ld\n", slot1, (int)ts[slot1]);
16 int main(void)
18 IPTR *ts = FindTask(NULL)->tc_UnionETask.tc_TaskStorage;
20 out = Output();
22 slot1 = AllocTaskStorageSlot();
23 FPrintf(out, "Got slot %d\n", slot1);
25 slot2 = AllocTaskStorageSlot();
26 FPrintf(out, "Got slot %d\n", slot2);
28 FreeTaskStorageSlot(slot2);
29 FPrintf(out, "Freed slot %d\n", slot2);
31 slot2 = AllocTaskStorageSlot();
32 FPrintf(out, "Got slot %d\n", slot2);
34 slot3 = AllocTaskStorageSlot();
35 FPrintf(out, "Got slot %d\n", slot3);
37 ts[slot1] = (IPTR)69;
38 FPrintf(out, "Stored value 69 in slot %d\n", slot1);
40 FPrintf(out, "Checking value in subtask\n");
41 struct Process *proc =
42 CreateNewProcTags(
43 NP_Entry, printslot1, NP_Name, "Check slot1",
44 NP_Synchronous, TRUE, TAG_DONE
46 assert(proc != NULL);
48 FreeTaskStorageSlot(slot1);
49 FPrintf(out, "Freed slot %d\n", slot1);
51 slot1 = AllocTaskStorageSlot();
52 FPrintf(out, "Got slot %d\n", slot1);
54 FreeTaskStorageSlot(slot2);
55 FPrintf(out, "Freed slot %d\n", slot2);
57 FreeTaskStorageSlot(slot1);
58 FPrintf(out, "Freed slot %d\n", slot1);
60 FreeTaskStorageSlot(slot3);
61 FPrintf(out, "Freed slot %d\n", slot3);
63 return 0;