correct copyright
[AROS.git] / rom / exec / savetaskstorage.c
blob032fc053ed2aa03eb9a240cacba84771bf322d87
1 /*
2 Copyright © 2012-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/nodes.h>
7 #include <exec/lists.h>
9 #include "exec_intern.h"
10 #include "taskstorage.h"
12 #define DEBUG 0
13 #include <aros/debug.h>
15 /*****************************************************************************
17 NAME */
18 #include <proto/exec.h>
20 AROS_LH0(APTR, SaveTaskStorage,
22 /* LOCATION */
23 struct ExecBase *, SysBase, 182, Exec)
25 /* FUNCTION
26 This function remembers the current state of the task storage slots.
27 An ID will be returned with which the current state can be restored
28 using RestoreTaskStorage(). NULL is returned when not enough memory
29 is available.
31 INPUTS
32 None.
34 RESULT
35 id - ID for use with RestoreTaskStorage(), or NULL.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 RestoreTaskStorage()
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
52 struct ETask *et = GetETask(GET_THIS_TASK);
53 IPTR *taskstorage, *tsout;
54 IPTR slots;
56 if (!et || et->et_TaskStorage == NULL)
57 return NULL;
59 taskstorage = et->et_TaskStorage;
60 slots = taskstorage[__TS_FIRSTSLOT];
62 /* NOTE: Saved task storage *must not* be passed around
63 * to another task! This is why it is not MEMF_PUBLIC.
65 tsout = AllocMem(slots * sizeof(tsout[0]), MEMF_ANY);
66 if (tsout) {
67 CopyMemQuick(taskstorage, tsout, slots * sizeof(tsout[0]));
70 D(bug("SaveTaskStorage: taskstorage=%x, size=%d, tsout=%x\n",
71 taskstorage, size, tsout
72 ));
74 return tsout;
76 AROS_LIBFUNC_EXIT