1141cc406Sopenharmony_ci/* Copyright (C) 1992 Free Software Foundation, Inc. 2141cc406Sopenharmony_ciThis file is part of the GNU C Library. 3141cc406Sopenharmony_ci 4141cc406Sopenharmony_ciThe GNU C Library is free software; you can redistribute it and/or 5141cc406Sopenharmony_cimodify it under the terms of the GNU Library General Public License as 6141cc406Sopenharmony_cipublished by the Free Software Foundation; either version 2 of the 7141cc406Sopenharmony_ciLicense, or (at your option) any later version. 8141cc406Sopenharmony_ci 9141cc406Sopenharmony_ciThe GNU C Library is distributed in the hope that it will be useful, 10141cc406Sopenharmony_cibut WITHOUT ANY WARRANTY; without even the implied warranty of 11141cc406Sopenharmony_ciMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12141cc406Sopenharmony_ciLibrary General Public License for more details. 13141cc406Sopenharmony_ci 14141cc406Sopenharmony_ciYou should have received a copy of the GNU Library General Public 15141cc406Sopenharmony_ciLicense along with the GNU C Library; see the file COPYING.LIB. If 16141cc406Sopenharmony_cinot, see <https://www.gnu.org/licenses/>. */ 17141cc406Sopenharmony_ci 18141cc406Sopenharmony_ci#include "../include/sane/config.h" 19141cc406Sopenharmony_ci 20141cc406Sopenharmony_ci#ifndef HAVE_USLEEP 21141cc406Sopenharmony_ci 22141cc406Sopenharmony_ci#include <sys/types.h> 23141cc406Sopenharmony_ci#ifdef HAVE_SYS_TIME_H 24141cc406Sopenharmony_ci# include <sys/time.h> 25141cc406Sopenharmony_ci#endif 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_ci#ifdef HAVE_SYS_SELECT_H 28141cc406Sopenharmony_ci# include <sys/select.h> 29141cc406Sopenharmony_ci#endif 30141cc406Sopenharmony_ci 31141cc406Sopenharmony_ci#ifdef apollo 32141cc406Sopenharmony_ci# include <apollo/base.h> 33141cc406Sopenharmony_ci# include <apollo/time.h> 34141cc406Sopenharmony_ci static time_$clock_t DomainTime100mS = 35141cc406Sopenharmony_ci { 36141cc406Sopenharmony_ci 0, 100000/4 37141cc406Sopenharmony_ci }; 38141cc406Sopenharmony_ci static status_$t DomainStatus; 39141cc406Sopenharmony_ci#endif 40141cc406Sopenharmony_ci 41141cc406Sopenharmony_ci/* Sleep USECONDS microseconds, or until a previously set timer goes off. */ 42141cc406Sopenharmony_ciunsigned int 43141cc406Sopenharmony_ciusleep (unsigned int useconds) 44141cc406Sopenharmony_ci{ 45141cc406Sopenharmony_ci#ifdef apollo 46141cc406Sopenharmony_ci /* The usleep function does not work under the SYS5.3 environment. 47141cc406Sopenharmony_ci Use the Domain/OS time_$wait call instead. */ 48141cc406Sopenharmony_ci time_$wait (time_$relative, DomainTime100mS, &DomainStatus); 49141cc406Sopenharmony_ci#else 50141cc406Sopenharmony_ci struct timeval delay; 51141cc406Sopenharmony_ci 52141cc406Sopenharmony_ci delay.tv_sec = 0; 53141cc406Sopenharmony_ci delay.tv_usec = useconds; 54141cc406Sopenharmony_ci select (0, 0, 0, 0, &delay); 55141cc406Sopenharmony_ci return 0; 56141cc406Sopenharmony_ci#endif 57141cc406Sopenharmony_ci} 58141cc406Sopenharmony_ci 59141cc406Sopenharmony_ci#endif /* !HAVE_USLEEP */ 60