a55a97621ecaaa84a0d0e339d7c0c0953b3d856c
[AROS.git] / rom / dos / delay.c
bloba55a97621ecaaa84a0d0e339d7c0c0953b3d856c
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
10 #include <proto/dos.h>
11 #include <proto/exec.h>
12 #include "dos_intern.h"
13 #include <devices/timer.h>
14 #include <string.h>
16 /*****************************************************************************
18 NAME */
19 #include <proto/dos.h>
21 AROS_LH1(void, Delay,
23 /* SYNOPSIS */
24 AROS_LHA(ULONG, timeout, D1),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 33, Dos)
29 /* FUNCTION
30 Waits for at least the time specified as timeout.
32 INPUTS
33 timeout - the minimum time to wait in ticks (1/50 seconds)
35 RESULT
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 struct timerequest timerio;
52 struct MsgPort timermp;
54 memset(&timermp, 0, sizeof(timermp));
56 timermp.mp_Node.ln_Type = NT_MSGPORT;
57 timermp.mp_Flags = PA_SIGNAL;
58 timermp.mp_SigBit = SIGB_SINGLE;
59 timermp.mp_SigTask = FindTask(NULL);
60 NEWLIST(&timermp.mp_MsgList);
62 /* clone timerequest in DOSBase */
63 CopyMem(DOSBase->dl_TimeReq, &timerio, sizeof(timerio));
65 timerio.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
66 timerio.tr_node.io_Message.mn_ReplyPort = &timermp;
67 timerio.tr_node.io_Command = TR_ADDREQUEST;
68 timerio.tr_time.tv_secs = timeout / TICKS_PER_SECOND;
69 timerio.tr_time.tv_micro = 1000000UL / TICKS_PER_SECOND * (timeout % TICKS_PER_SECOND);
71 SetSignal(0, SIGF_SINGLE);
73 DoIO(&timerio.tr_node);
75 AROS_LIBFUNC_EXIT
76 } /* Delay */