Added 'Resident' field to ensure that the handler is included in the
[AROS.git] / rom / exec / replymsg.c
blobdcc437f6960468630ed1f10f1dcd542dd31ebd8e
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Reply a message
6 Lang: english
7 */
9 #include <aros/libcall.h>
10 #include <exec/ports.h>
11 #include <proto/exec.h>
13 #include "exec_intern.h"
14 #include "exec_util.h"
16 /*****************************************************************************
18 NAME */
20 AROS_LH1(void, ReplyMsg,
22 /* SYNOPSIS */
23 AROS_LHA(struct Message *, message, A1),
25 /* LOCATION */
26 struct ExecBase *, SysBase, 63, Exec)
28 /* FUNCTION
29 Send a message back to where it came from. It's generally not
30 wise to access the fields of a message after it has been replied.
32 INPUTS
33 message - a message got with GetMsg().
35 RESULT
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 WaitPort(), GetMsg(), PutMsg()
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
52 struct MsgPort *port;
54 /* handle FASTCALL before doing locking or anything else. yes, there's a
55 * potential race here if some task was to change mn_ReplyPort before/as
56 * we read it. thats why we fetch it again further down, after Disable().
57 * all bets are of when using FASTCALL */
58 port = message->mn_ReplyPort;
60 if (port != NULL && port->mp_Flags & PA_FASTCALL)
62 FastPutMsg(port, message, SysBase);
63 return;
66 /* Protect the message against access by other tasks. */
67 Disable();
69 /* Get replyport */
70 port=message->mn_ReplyPort;
72 /* Not set? Only mark the message as no longer sent. */
73 if(port==NULL)
74 message->mn_Node.ln_Type=NT_FREEMSG;
75 else
77 /* Mark the message as replied */
78 message->mn_Node.ln_Type=NT_REPLYMSG;
80 InternalPutMsg(port, message, SysBase);
83 /* All done */
84 Enable();
85 AROS_LIBFUNC_EXIT
86 } /* ReplyMsg() */