pass -static-libstdc++ via LDFLAGS
[AROS.git] / rom / exec / getmsg.c
blob36cd6c0b56c9856019582eb79e6f002d7b561eba
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Get a message from a message port.
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <exec/ports.h>
11 #include <aros/libcall.h>
12 #include <proto/exec.h>
14 #include "exec_intern.h"
16 /*****************************************************************************
18 NAME */
20 AROS_LH1(struct Message *, GetMsg,
22 /* SYNOPSIS */
23 AROS_LHA(struct MsgPort *, port, A0),
25 /* LOCATION */
26 struct ExecBase *, SysBase, 62, Exec)
28 /* FUNCTION
29 Get a message from a given messageport. This function doesn't wait
30 and returns NULL if the messageport is empty. Therefore it's
31 generally a good idea to WaitPort() or Wait() on the given port first.
33 INPUTS
34 port - Pointer to messageport
36 RESULT
37 Pointer to message removed from the port.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 WaitPort(), PutMsg()
48 INTERNALS
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct Message *msg;
56 ASSERT_VALID_PTR(port);
59 * Protect the message list, and get the first node.
61 Disable();
62 #if defined(__AROSEXEC_SMP__)
63 EXEC_SPINLOCK_LOCK(&port->mp_SpinLock, NULL, SPINLOCK_MODE_WRITE);
64 #endif
65 msg=(struct Message *)RemHead(&port->mp_MsgList);
66 #if defined(__AROSEXEC_SMP__)
67 EXEC_SPINLOCK_UNLOCK(&port->mp_SpinLock);
68 #endif
69 Enable();
71 /* All done. */
72 ASSERT_VALID_PTR_OR_NULL(msg);
74 return msg;
75 AROS_LIBFUNC_EXIT
76 } /* GetMsg() */