use GET_THIS_TASK internally throughout exec - since it will result in faster/smaller...
[AROS.git] / rom / exec / setsignal.c
blob15dc2e04ca785b55aad31d042df4e8f7942a7aea
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Examine and/or modify the signals of a task.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 #include "exec_intern.h"
13 #if defined(__AROSEXEC_SMP__)
14 #include "etask.h"
15 #endif
17 /*****************************************************************************
19 NAME */
21 AROS_LH2(ULONG, SetSignal,
23 /* SYNOPSIS */
24 AROS_LHA(ULONG, newSignals, D0),
25 AROS_LHA(ULONG, signalSet, D1),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 51, Exec)
30 /* FUNCTION
31 Change or read the set of signals sent to the current task.
33 INPUTS
34 newSignals - New values for the signals.
35 signalSet - Mask of signals affected by 'newSignals'.
37 RESULT
38 Old signal set.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 AllocSignal(), FreeSignal(), Wait(), Signal(), SetExcept()
49 INTERNALS
51 ******************************************************************************/
53 AROS_LIBFUNC_INIT
55 struct Task *ThisTask = GET_THIS_TASK;
56 ULONG *sig;
57 ULONG old;
59 /* Protect the signal mask against access by other tasks. */
60 #if defined(__AROSEXEC_SMP__)
61 EXEC_SPINLOCK_LOCK(&IntETask(ThisTask->tc_UnionETask.tc_ETask)->iet_TaskLock, SPINLOCK_MODE_WRITE);
62 #endif
63 Disable();
65 /* Get address */
66 sig = &ThisTask->tc_SigRecvd;
68 /* Change only the bits in 'mask' */
69 old = *sig;
70 *sig = (old & ~signalSet) | (newSignals & signalSet);
72 #if defined(__AROSEXEC_SMP__)
73 EXEC_SPINLOCK_UNLOCK(&IntETask(ThisTask->tc_UnionETask.tc_ETask)->iet_TaskLock);
74 #endif
75 Enable();
77 return old;
78 AROS_LIBFUNC_EXIT
79 } /* SetSignal() */