arch/m68k-amiga: Define the gcc symbol 'start' instead of using .bss
[AROS.git] / compiler / clib / usleep.c
blobe0603b46bbb1be8afbd5a24e35e83a5f8d238969
1 /*
2 Copyright © 2008, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX function usleep().
6 */
8 #include <aros/debug.h>
10 #include <exec/exec.h>
11 #include <proto/exec.h>
12 #include <devices/timer.h>
14 #include <errno.h>
16 /*****************************************************************************
18 NAME */
19 #include <unistd.h>
21 int usleep (
23 /* SYNOPSIS */
24 useconds_t usec)
26 /* FUNCTION
27 Suspends program execution for a given number of microseconds.
29 INPUTS
30 usec - number of microseconds to wait
32 RESULT
33 0 on success, -1 on error
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
43 INTERNALS
45 ******************************************************************************/
47 struct MsgPort *timerMsgPort;
48 struct timerequest *timerIO;
49 int retval = -1;
51 if((timerMsgPort = CreateMsgPort()))
53 timerIO = (struct timerequest *) CreateIORequest(timerMsgPort, sizeof (struct timerequest));
54 if(timerIO)
56 if(OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) timerIO, 0) == 0)
58 timerIO->tr_node.io_Command = TR_ADDREQUEST;
59 timerIO->tr_time.tv_secs = 0;
60 timerIO->tr_time.tv_micro = usec;
62 DoIO((struct IORequest *) timerIO);
63 retval = 0;
65 CloseDevice((struct IORequest *) timerIO);
67 DeleteIORequest((struct IORequest *) timerIO);
69 DeleteMsgPort(timerMsgPort);
71 return retval;
72 } /* usleep() */