compiler/clib/strftime.c: Add note to autodoc that no localization is implemented.
[AROS.git] / compiler / clib / usleep.c
blob2f513b0ee5b6deeac556b0c6b58378d572b89e97
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 /* FIXME: share TimerBase with gettimeofday and don't open/close it for each usleep call */
52 if((timerMsgPort = CreateMsgPort()))
54 timerIO = (struct timerequest *) CreateIORequest(timerMsgPort, sizeof (struct timerequest));
55 if(timerIO)
57 if(OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) timerIO, 0) == 0)
59 timerIO->tr_node.io_Command = TR_ADDREQUEST;
60 timerIO->tr_time.tv_secs = 0;
61 timerIO->tr_time.tv_micro = usec;
63 DoIO((struct IORequest *) timerIO);
64 retval = 0;
66 CloseDevice((struct IORequest *) timerIO);
68 DeleteIORequest((struct IORequest *) timerIO);
70 DeleteMsgPort(timerMsgPort);
72 return retval;
73 } /* usleep() */