clean the code a little by reducing amout of places where gcc decides to put ud2...
[AROS.git] / rom / exec / savetaskstorage.c
blob58eb04b521c4baeca233caebcf15412f96c2b000
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 Task *ThisTask = GET_THIS_TASK;
53 struct ETask *et = ThisTask ? GetETask(ThisTask) : NULL;
54 IPTR *taskstorage, *tsout;
55 IPTR slots;
57 if (!et || et->et_TaskStorage == NULL)
58 return NULL;
60 taskstorage = et->et_TaskStorage;
61 slots = taskstorage[__TS_FIRSTSLOT];
63 /* NOTE: Saved task storage *must not* be passed around
64 * to another task! This is why it is not MEMF_PUBLIC.
66 tsout = AllocMem(slots * sizeof(tsout[0]), MEMF_ANY);
67 if (tsout) {
68 CopyMemQuick(taskstorage, tsout, slots * sizeof(tsout[0]));
71 D(bug("SaveTaskStorage: taskstorage=%x, size=%d, tsout=%x\n",
72 taskstorage, size, tsout
73 );)
75 return tsout;
77 AROS_LIBFUNC_EXIT