1 /* Copyright (C) 1992 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8 
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Library General Public License for more details.
13 
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB.  If
16 not, see <https://www.gnu.org/licenses/>.  */
17 
18 #include "../include/sane/config.h"
19 
20 #ifndef HAVE_USLEEP
21 
22 #include <sys/types.h>
23 #ifdef HAVE_SYS_TIME_H
24 # include <sys/time.h>
25 #endif
26 
27 #ifdef HAVE_SYS_SELECT_H
28 # include <sys/select.h>
29 #endif
30 
31 #ifdef apollo
32 # include <apollo/base.h>
33 # include <apollo/time.h>
34   static time_$clock_t DomainTime100mS =
35     {
36 	0, 100000/4
37     };
38   static status_$t DomainStatus;
39 #endif
40 
41 /* Sleep USECONDS microseconds, or until a previously set timer goes off.  */
42 unsigned int
usleep(unsigned int useconds)43 usleep (unsigned int useconds)
44 {
45 #ifdef apollo
46   /* The usleep function does not work under the SYS5.3 environment.
47      Use the Domain/OS time_$wait call instead. */
48   time_$wait (time_$relative, DomainTime100mS, &DomainStatus);
49 #else
50   struct timeval delay;
51 
52   delay.tv_sec = 0;
53   delay.tv_usec = useconds;
54   select (0, 0, 0, 0, &delay);
55   return 0;
56 #endif
57 }
58 
59 #endif /* !HAVE_USLEEP */
60