2 Copyright © 2008, The AROS Development Team. All rights reserved.
5 POSIX function usleep().
8 #include <aros/debug.h>
10 #include <exec/exec.h>
11 #include <proto/exec.h>
12 #include <devices/timer.h>
16 /*****************************************************************************
27 Suspends program execution for a given number of microseconds.
30 usec - number of microseconds to wait
33 0 on success, -1 on error
45 ******************************************************************************/
47 struct MsgPort
*timerMsgPort
;
48 struct timerequest
*timerIO
;
51 if((timerMsgPort
= CreateMsgPort()))
53 timerIO
= (struct timerequest
*) CreateIORequest(timerMsgPort
, sizeof (struct timerequest
));
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
);
65 CloseDevice((struct IORequest
*) timerIO
);
67 DeleteIORequest((struct IORequest
*) timerIO
);
69 DeleteMsgPort(timerMsgPort
);