exec.library: Use the new AROS_UFIx() macros
[AROS.git] / rom / exec / savetaskstorage.c
blobfd3a92deaa23f1b8bc84df23958e7fb6ac360dff
1 /*
2 Copyright © 2012, 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 The will remember the current state of the task storage slots
28 INPUTS
29 None.
31 RESULT
32 An id will be returned whit which the current state can be restored
33 using RestoreTaskStorageSlots().
34 NULL is returned when not enough memory was available.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 RestoreTaskStorage()
45 INTERNALS
47 ******************************************************************************/
49 AROS_LIBFUNC_INIT
51 struct ETask *et = GetETask(FindTask(NULL));
52 IPTR *taskstorage, *tsout;
53 IPTR slots;
55 if (!et || et->et_TaskStorage == NULL)
56 return NULL;
58 taskstorage = et->et_TaskStorage;
59 slots = taskstorage[__TS_FIRSTSLOT];
61 /* NOTE: Saved task storage *must not* be passed around
62 * to another task! This is why it is not MEMF_PUBLIC.
64 tsout = AllocMem(slots * sizeof(tsout[0]), MEMF_ANY);
65 if (tsout) {
66 CopyMemQuick(taskstorage, tsout, slots * sizeof(tsout[0]));
69 D(bug("SaveTaskStorage: taskstorage=%x, size=%d, tsout=%x\n",
70 taskstorage, size, tsout
71 ));
73 return tsout;
75 AROS_LIBFUNC_EXIT