grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / exec / setexcept.c
blobb724798003ab486d8f3319b562e21921b80cfca8
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Examine and/or modify the signals which cause an exception.
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 #include "exec_intern.h"
14 #if defined(__AROSEXEC_SMP__)
15 #include "etask.h"
16 #endif
18 /*****************************************************************************
20 NAME */
22 AROS_LH2(ULONG, SetExcept,
24 /* SYNOPSIS */
25 AROS_LHA(ULONG, newSignals, D0),
26 AROS_LHA(ULONG, signalSet, D1),
28 /* LOCATION */
29 struct ExecBase *, SysBase, 52, Exec)
31 /* FUNCTION
32 Change the mask of signals causing a task exception.
34 INPUTS
35 newSignals - Set of signals causing the exception.
36 signalSet - Mask of affected signals.
38 RESULT
39 Old mask of signals causing a task exception.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 AllocSignal(), FreeSignal(), Wait(), SetSignal(), Signal()
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 AROS_LIBFUNC_INIT
58 /* Get pointer to current task */
59 struct Task *ThisTask = GET_THIS_TASK;
60 ULONG old;
62 /* Protect mask of sent signals and task lists */
63 #if defined(__AROSEXEC_SMP__)
64 EXEC_SPINLOCK_LOCK(&IntETask(ThisTask->tc_UnionETask.tc_ETask)->iet_TaskLock, SPINLOCK_MODE_WRITE);
65 #endif
66 Disable();
68 /* Get returncode */
69 old = ThisTask->tc_SigExcept;
71 /* Change exception mask */
72 ThisTask->tc_SigExcept = (old & ~signalSet) | (newSignals & signalSet);
74 /* Does this change include an exception? */
75 if (ThisTask->tc_SigExcept & ThisTask->tc_SigRecvd)
77 /* Yes. Set the exception flag. */
78 ThisTask->tc_Flags |= TF_EXCEPT;
80 /* And order rescheduling */
81 Reschedule();
83 #if defined(__AROSEXEC_SMP__)
84 EXEC_SPINLOCK_UNLOCK(&IntETask(ThisTask->tc_UnionETask.tc_ETask)->iet_TaskLock);
85 #endif
86 Enable();
88 return old;
90 AROS_LIBFUNC_EXIT