A buffer variable wasn't dereferenced in two similar comparisons in ResList
[AROS.git] / compiler / alib / timedelay.c
blob5ddf0505556bd91491079a5982054a01443ff187
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: TimeDelay() - wait a specified time.
6 Lang: english
7 */
10 #include <exec/types.h>
11 #include <aros/asmcall.h>
12 #include <devices/timer.h>
13 #include <exec/tasks.h>
14 #include <proto/exec.h>
16 /*****************************************************************************
18 NAME */
19 LONG TimeDelay(
21 /* SYNOPSIS */
22 LONG Unit,
23 ULONG Seconds,
24 ULONG MicroSeconds)
26 /* FUNCTION
27 TimeDelay() waits for the specified period of time before returning
28 to the caller.
30 INPUTS
31 Unit - The timer.device unit to use for this command.
32 Seconds - The number of seconds to wait.
33 MicroSeconds - The number of microseconds to wait.
35 RESULT
36 Zero if everything went ok, non-zero if there was a problem.
38 NOTES
39 If this function fails, the most likely reasons are:
40 - invalid timer.device unit numbers
42 This function uses the SIGF_SINGLE signal, strange things can
43 happen if you are waiting on this signal when you call this
44 function. Basically: Don't use it and call this function.
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 timer.device/TR_ADDREQUEST
53 INTERNALS
55 HISTORY
57 ******************************************************************************/
59 struct timerequest tr;
60 struct MsgPort mp;
61 UBYTE error = 0;
63 /* Create a message port */
64 mp.mp_Node.ln_Type = NT_MSGPORT;
65 mp.mp_Node.ln_Pri = 0;
66 mp.mp_Node.ln_Name = NULL;
67 mp.mp_Flags = PA_SIGNAL;
68 mp.mp_SigTask = FindTask(NULL);
69 mp.mp_SigBit = SIGB_SINGLE;
70 NEWLIST(&mp.mp_MsgList);
72 tr.tr_node.io_Message.mn_Node.ln_Type = NT_MESSAGE;
73 tr.tr_node.io_Message.mn_Node.ln_Pri = 0;
74 tr.tr_node.io_Message.mn_Node.ln_Name = NULL;
75 tr.tr_node.io_Message.mn_ReplyPort = &mp;
76 tr.tr_node.io_Message.mn_Length = sizeof(struct timerequest);
78 SetSignal(0, SIGF_SINGLE);
80 if(OpenDevice("timer.device", Unit, (struct IORequest *)&tr, 0) == 0)
82 tr.tr_node.io_Command = TR_ADDREQUEST;
83 tr.tr_node.io_Flags = 0;
84 tr.tr_time.tv_secs = Seconds;
85 tr.tr_time.tv_micro = MicroSeconds;
87 DoIO((struct IORequest *)&tr);
89 CloseDevice((struct IORequest *)&tr);
90 error = 1;
93 return error;
95 } /* TimeDelay() */